Fix a bug caused by wrong context in the g_source_remove().
g_source_remove() assumes default main context, but some
gsource are attached to the specific context instead of
default main context.
In conclusion, find the gsource from each context first before
freeing source.
Change-Id: I8ec20108750a28ce1c7a4a5d829f0a1842ab4baa
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
void *data;
release_cb free_func;
fd_handler_h *handler_p;
+ GMainContext *context;
};
int remove_fd_read_handler(fd_handler_h *handler)
if (h->free_func)
h->free_func(h->data);
- if (h->id)
- g_source_remove(h->id);
+ if (h->id) {
+ GSource *source = g_main_context_find_source_by_id (h->context, h->id);
+ if (source)
+ g_source_destroy(source);
+ }
if (h->ch)
g_io_channel_unref(h->ch);
h->ch = ch;
h->id = id;
h->handler_p = handler;
+ h->context = context;
if (handler != NULL)
*handler = h;