From 6019a5cd15d8aad1f78b415fe3aa468ee1131e7a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 29 Aug 2002 19:59:13 +0000 Subject: [PATCH] Don't crash if /SET irssiproxy_ports is changed while having connected clients git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2908 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/proxy/listen.c | 9 ++++++--- src/irc/proxy/module.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index 811d747f..a8ad518f 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -42,6 +42,7 @@ static void remove_client(CLIENT_REC *rec) g_return_if_fail(rec != NULL); proxy_clients = g_slist_remove(proxy_clients, rec); + rec->listen->clients = g_slist_remove(rec->listen->clients, rec); if (ctcp_client == rec) ctcp_client = NULL; @@ -337,7 +338,8 @@ static void sig_listen(LISTEN_REC *listen) rec->tag = g_input_add(handle, G_INPUT_READ, (GInputFunction) sig_listen_client, rec); - proxy_clients = g_slist_append(proxy_clients, rec); + proxy_clients = g_slist_prepend(proxy_clients, rec); + rec->listen->clients = g_slist_prepend(rec->listen->clients, rec); signal_emit("proxy client connected", 1, rec); printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE, @@ -583,6 +585,9 @@ static void remove_listen(LISTEN_REC *rec) { proxy_listens = g_slist_remove(proxy_listens, rec); + while (rec->clients != NULL) + remove_client(rec->clients->data); + net_disconnect(rec->handle); g_source_remove(rec->tag); g_free(rec->ircnet); @@ -644,8 +649,6 @@ void proxy_listen_init(void) void proxy_listen_deinit(void) { - while (proxy_clients != NULL) - remove_client(proxy_clients->data); while (proxy_listens != NULL) remove_listen(proxy_listens->data); g_string_free(next_line, TRUE); diff --git a/src/irc/proxy/module.h b/src/irc/proxy/module.h index 99f99e54..e2aca133 100644 --- a/src/irc/proxy/module.h +++ b/src/irc/proxy/module.h @@ -13,6 +13,8 @@ typedef struct { int tag; GIOChannel *handle; + + GSList *clients; } LISTEN_REC; typedef struct {