X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fplugin.c;h=dcca7b817d4a345a3d181a6ec5dfca74a83023a6;hb=7e8c276165ab8de4d579076a56fab65c8b816039;hp=8701d1e02ee8f2ad8eb74722d6676cdddebf38c8;hpb=fd22b41f7c6f05373312899b9c7a025610299374;p=ncmpc.git diff --git a/src/plugin.c b/src/plugin.c index 8701d1e..dcca7b8 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -34,9 +34,7 @@ struct plugin_pipe { /** the pipe to the plugin process, or -1 if none is currently open */ int fd; - /** the GLib channel of #fd */ - GIOChannel *channel; - /** the GLib IO watch of #channel */ + /** the GLib IO watch of #fd */ guint event_id; /** the output of the current plugin */ GString *data; @@ -129,7 +127,6 @@ next_plugin(struct plugin_cycle *cycle); static void plugin_eof(struct plugin_cycle *cycle, struct plugin_pipe *p) { - g_io_channel_unref(p->channel); close(p->fd); p->fd = -1; @@ -217,9 +214,10 @@ plugin_fd_add(struct plugin_cycle *cycle, struct plugin_pipe *p, int fd) p->cycle = cycle; p->fd = fd; p->data = g_string_new(NULL); - p->channel = g_io_channel_unix_new(fd); - p->event_id = g_io_add_watch(p->channel, G_IO_IN|G_IO_HUP, + GIOChannel *channel = g_io_channel_unix_new(fd); + p->event_id = g_io_add_watch(channel, G_IO_IN|G_IO_HUP, plugin_data, cycle); + g_io_channel_unref(channel); } static int @@ -296,7 +294,7 @@ next_plugin(struct plugin_cycle *cycle) if (cycle->next_plugin >= cycle->list->plugins->len) { /* no plugins left */ - g_timeout_add(0, plugin_delayed_fail, cycle); + g_idle_add(plugin_delayed_fail, cycle); return; } @@ -304,7 +302,7 @@ next_plugin(struct plugin_cycle *cycle) cycle->next_plugin++); if (start_plugin(cycle, plugin_path) < 0) { /* system error */ - g_timeout_add(0, plugin_delayed_fail, cycle); + g_idle_add(plugin_delayed_fail, cycle); return; } } @@ -361,7 +359,6 @@ plugin_fd_remove(struct plugin_pipe *p) { if (p->fd >= 0) { g_source_remove(p->event_id); - g_io_channel_unref(p->channel); close(p->fd); } }