diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-09 17:53:15 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-09 17:53:15 +0100 |
commit | 54074040bc9c8ff5d71ca11e07a5d936b537b2bf (patch) | |
tree | 5dff075df7e9f853aea0d3e2edc3a52aa909c435 | |
parent | 0699e7170171221710626c8c70966a34ea0455ec (diff) | |
download | pjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.tar.gz pjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.tar.bz2 pjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.zip |
Cleanup socket objects when finished
So that we explicitly disconnect.
-rw-r--r-- | src/pjctl.c | 17 |
1 files 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; |