diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-09-02 21:47:35 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-02-13 17:37:49 +0100 |
commit | 835766d6bcc006bd41b9a983dcf21c43d96caa73 (patch) | |
tree | 1ed81d04bfe601beeba4735c725d3316881bc27e /server/dispatcher.c | |
parent | 556063275cccd8a13a2448301721efb9b6168e61 (diff) |
server: move dispatcher GSource handling code
Diffstat (limited to 'server/dispatcher.c')
-rw-r--r-- | server/dispatcher.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/dispatcher.c b/server/dispatcher.c index 220f6e4f..1f4c68f6 100644 --- a/server/dispatcher.c +++ b/server/dispatcher.c @@ -301,3 +301,28 @@ int dispatcher_get_recv_fd(Dispatcher *dispatcher) { return dispatcher->recv_fd; } + +static gboolean dispatch_cb(GIOChannel *source, GIOCondition condition, + gpointer data) +{ + Dispatcher *dispatcher = data; + + spice_debug(NULL); + dispatcher_handle_recv_read(dispatcher); + + /* FIXME: remove source cb if error */ + return TRUE; +} + +void dispatcher_attach(Dispatcher *dispatcher, GMainContext *main_context) +{ + spice_return_if_fail(dispatcher != NULL); + spice_return_if_fail(main_context != NULL); + + GIOChannel *channel = g_io_channel_unix_new(dispatcher->recv_fd); + GSource *source = g_io_create_watch(channel, G_IO_IN); + + g_source_set_callback(source, (GSourceFunc)dispatch_cb, dispatcher, NULL); + g_source_attach(source, main_context); + g_source_unref(source); +} |