1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-13 05:03:45 -04:00

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.
This commit is contained in:
dequis 2015-06-14 16:41:52 -03:00
parent a47f45b5b7
commit 51496cd09f

View File

@ -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)