diff options
author | Max Kellermann <max@duempel.org> | 2008-12-30 19:24:39 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-12-30 19:24:39 +0100 |
commit | 71e7ce5d8e3153342494685d60d7ff16d9b29101 (patch) | |
tree | ed9893562c16b7f8ab98a5c97bce79bcf1ae2267 /src/main_notify.c | |
parent | 03e650aa9e9a95575fccd51ec9f669abae52fe7e (diff) | |
download | mpd-71e7ce5d8e3153342494685d60d7ff16d9b29101.tar.gz mpd-71e7ce5d8e3153342494685d60d7ff16d9b29101.tar.xz mpd-71e7ce5d8e3153342494685d60d7ff16d9b29101.zip |
main: use the GLib main loop
This is a rather huge patch, which unfortunately cannot be splitted.
Instead of using our custom ioops.h library, convert everything to use
the GLib main loop.
Diffstat (limited to '')
-rw-r--r-- | src/main_notify.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/main_notify.c b/src/main_notify.c index f821f76aa..e9552efbc 100644 --- a/src/main_notify.c +++ b/src/main_notify.c @@ -20,25 +20,15 @@ #include "main_notify.h" #include "utils.h" -#include "ioops.h" #include "log.h" #include <assert.h> #include <glib.h> #include <string.h> -static struct ioOps main_notify_IO; static int main_pipe[2]; GThread *main_task; -static int ioops_fdset(fd_set * rfds, - G_GNUC_UNUSED fd_set * wfds, - G_GNUC_UNUSED fd_set * efds) -{ - FD_SET(main_pipe[0], rfds); - return main_pipe[0]; -} - static void consume_pipe(void) { char buffer[256]; @@ -48,20 +38,20 @@ static void consume_pipe(void) FATAL("error reading from pipe: %s\n", strerror(errno)); } -static int ioops_consume(int fd_count, fd_set * rfds, - G_GNUC_UNUSED fd_set * wfds, - G_GNUC_UNUSED fd_set * efds) +static gboolean +main_notify_event(G_GNUC_UNUSED GIOChannel *source, + G_GNUC_UNUSED GIOCondition condition, + G_GNUC_UNUSED gpointer data) { - if (FD_ISSET(main_pipe[0], rfds)) { - consume_pipe(); - FD_CLR(main_pipe[0], rfds); - fd_count--; - } - return fd_count; + consume_pipe(); + main_notify_triggered(); + return true; } void init_main_notify(void) { + GIOChannel *channel; + main_task = g_thread_self(); if (pipe(main_pipe) < 0) @@ -69,15 +59,15 @@ void init_main_notify(void) if (set_nonblocking(main_pipe[1]) < 0) g_error("Couldn't set non-blocking I/O: %s", strerror(errno)); - main_notify_IO.fdset = ioops_fdset; - main_notify_IO.consume = ioops_consume; - registerIO(&main_notify_IO); + channel = g_io_channel_unix_new(main_pipe[0]); + g_io_add_watch(channel, G_IO_IN, main_notify_event, NULL); + g_io_channel_unref(channel); + main_task = g_thread_self(); } void deinit_main_notify(void) { - deregisterIO(&main_notify_IO); xclose(main_pipe[0]); xclose(main_pipe[1]); } |