summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-11-09 17:53:15 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-11-09 17:53:15 +0100
commit54074040bc9c8ff5d71ca11e07a5d936b537b2bf (patch)
tree5dff075df7e9f853aea0d3e2edc3a52aa909c435 /src
parent0699e7170171221710626c8c70966a34ea0455ec (diff)
downloadpjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.tar.gz
pjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.tar.bz2
pjctl-54074040bc9c8ff5d71ca11e07a5d936b537b2bf.zip
Cleanup socket objects when finished
So that we explicitly disconnect.
Diffstat (limited to 'src')
-rw-r--r--src/pjctl.c17
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;