From dc3be0a6533be782c76f23ce653f4fc683b3b4f1 Mon Sep 17 00:00:00 2001 From: "Andreas.Eversberg" Date: Sun, 6 Nov 2011 20:09:28 +0100 Subject: vty/telnet_interface: Add telnet_exit function This frees socket and pending connections Written-by: Andreas Eversberg Signed-off-by: Sylvain Munaut --- include/osmocom/vty/telnet_interface.h | 2 ++ src/vty/telnet_interface.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/osmocom/vty/telnet_interface.h b/include/osmocom/vty/telnet_interface.h index 9a7c9e52..2de4f192 100644 --- a/include/osmocom/vty/telnet_interface.h +++ b/include/osmocom/vty/telnet_interface.h @@ -48,6 +48,8 @@ struct telnet_connection { int telnet_init(void *tall_ctx, void *priv, int port); +void telnet_exit(void); + /*! }@ */ #endif /* TELNET_INTERFACE_H */ diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c index ed64cdab..167acc18 100644 --- a/src/vty/telnet_interface.c +++ b/src/vty/telnet_interface.c @@ -221,4 +221,16 @@ void vty_event(enum event event, int sock, struct vty *vty) } } +void telnet_exit(void) +{ + struct telnet_connection *tc, *tc2; + + llist_for_each_entry_safe(tc, tc2, &active_connections, entry) + telnet_close_client(&tc->fd); + + osmo_fd_unregister(&server_socket); + close(server_socket.fd); + talloc_free(tall_telnet_ctx); +} + /*! }@ */ -- cgit v1.2.3