From 54074040bc9c8ff5d71ca11e07a5d936b537b2bf Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 9 Nov 2011 17:53:15 +0100 Subject: Cleanup socket objects when finished So that we explicitly disconnect. --- src/pjctl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pjctl.c b/src/pjctl.c index 0069c9d..58e120e 100644 --- a/src/pjctl.c +++ b/src/pjctl.c @@ -46,7 +46,6 @@ struct pjctl { GSocketConnection *con; GPollableInputStream *in; GOutputStream *out; - GSource *insrc; }; struct queue_command { @@ -605,6 +604,8 @@ main(int argc, char **argv) int port = 4352; GError *error = NULL; int i; + GSource *src; + guint src_id; memset(&pjctl, 0, sizeof pjctl); @@ -653,14 +654,20 @@ main(int argc, char **argv) return 1; } - pjctl.insrc = g_pollable_input_stream_create_source(pjctl.in, NULL); - g_source_set_callback(pjctl.insrc, (GSourceFunc) read_cb, &pjctl, NULL); - g_source_attach(pjctl.insrc, NULL); - g_source_unref(pjctl.insrc); + src = g_pollable_input_stream_create_source(pjctl.in, NULL); + g_source_set_callback(src, (GSourceFunc) read_cb, &pjctl, NULL); + src_id = g_source_attach(src, NULL); + g_source_unref(src); pjctl.state = PJCTL_AWAIT_INITIAL; g_main_loop_run(pjctl.loop); + + g_source_remove(src_id); + g_object_unref(pjctl.in); + g_object_unref(pjctl.out); + g_object_unref(pjctl.con); + g_object_unref(pjctl.sc); g_main_loop_unref(pjctl.loop); return 0; -- cgit