summaryrefslogtreecommitdiff
path: root/src/irc/proxy
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-06-14 16:41:52 -0300
committerdequis <dx@dxzone.com.ar>2015-06-14 17:00:35 -0300
commit51496cd09f5d2f2da0a4ae678663c66e2ceae17c (patch)
treebf597dc751b40623f8a633c99132ca72671a9283 /src/irc/proxy
parenta47f45b5b7438209177d76f3efde559e61e5bdb7 (diff)
downloadirssi-51496cd09f5d2f2da0a4ae678663c66e2ceae17c.zip
Fix 'address already in use' when changing irssiproxy_ports
When changing the value of irssiproxy_ports to use a different network name in a port that was already bound (so like changing from asd=6667 to sdf=6667) it would throw "address already in use". This fixes it by delaying the add_listen() calls after all the remove_listen() were called.
Diffstat (limited to 'src/irc/proxy')
-rw-r--r--src/irc/proxy/listen.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c
index a560801d..dc354c30 100644
--- a/src/irc/proxy/listen.c
+++ b/src/irc/proxy/listen.c
@@ -642,7 +642,8 @@ static void remove_listen(LISTEN_REC *rec)
static void read_settings(void)
{
LISTEN_REC *rec;
- GSList *remove_listens;
+ GSList *remove_listens = NULL;
+ GSList *add_listens = NULL;
char **ports, **tmp, *ircnet, *port;
int portnum;
@@ -661,17 +662,30 @@ static void read_settings(void)
continue;
rec = find_listen(ircnet, portnum);
- if (rec == NULL)
- add_listen(ircnet, portnum);
- else
+ if (rec == NULL) {
+ rec = g_new0(LISTEN_REC, 1);
+ rec->ircnet = ircnet; /* borrow */
+ rec->port = portnum;
+ add_listens = g_slist_prepend(add_listens, rec);
+ } else {
+ /* remove from the list of listens to remove == keep it */
remove_listens = g_slist_remove(remove_listens, rec);
+ }
}
- g_strfreev(ports);
while (remove_listens != NULL) {
- remove_listen(remove_listens->data);
+ remove_listen(remove_listens->data);
remove_listens = g_slist_remove(remove_listens, remove_listens->data);
}
+
+ while (add_listens != NULL) {
+ rec = add_listens->data;
+ add_listen(rec->ircnet, rec->port);
+ g_free(rec);
+ add_listens = g_slist_remove(add_listens, add_listens->data);
+ }
+
+ g_strfreev(ports);
}
static void sig_dump(CLIENT_REC *client, const char *data)