aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-10 18:55:33 +0100
committerMax Kellermann <max@duempel.org>2009-01-10 18:55:33 +0100
commitca5432a79b6fe16a9e14dfbd0d3880d9c60eac73 (patch)
tree78f55a4eb0e39b9ef8ab2d1ae67b7e5fabf54076
parentd60cf67d1972dcf176117b7b3b1f5077c906353e (diff)
downloadmpd-ca5432a79b6fe16a9e14dfbd0d3880d9c60eac73.tar.gz
mpd-ca5432a79b6fe16a9e14dfbd0d3880d9c60eac73.tar.xz
mpd-ca5432a79b6fe16a9e14dfbd0d3880d9c60eac73.zip
listen: remove the socket source from the main context
Free memory before exiting.
-rw-r--r--src/listen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/listen.c b/src/listen.c
index 62d4e2e60..d0dfa3c71 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -58,6 +58,8 @@ struct listen_socket {
struct listen_socket *next;
int fd;
+
+ guint source_id;
};
static struct listen_socket *listen_sockets;
@@ -101,8 +103,8 @@ static int establishListen(int pf, const struct sockaddr *addrp,
ls->fd = sock;
channel = g_io_channel_unix_new(sock);
- g_io_add_watch(channel, G_IO_IN,
- listen_in_event, GINT_TO_POINTER(sock));
+ ls->source_id = g_io_add_watch(channel, G_IO_IN,
+ listen_in_event, GINT_TO_POINTER(sock));
g_io_channel_unref(channel);
ls->next = listen_sockets;
@@ -281,6 +283,7 @@ void closeAllListenSockets(void)
struct listen_socket *ls = listen_sockets;
listen_sockets = ls->next;
+ g_source_remove(ls->source_id);
close(ls->fd);
g_free(ls);
}