From: Saurav Babu Date: Wed, 6 Jan 2016 09:26:19 +0000 (+0530) Subject: [connection] Modified logic so that callback is sent to their respective thread X-Git-Tag: accepted/tizen/common/20160302.203300~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b01eea35eff794e559431b1fb43d60efbcfc2133;p=platform%2Fcore%2Fapi%2Fconnection.git [connection] Modified logic so that callback is sent to their respective thread Currently for sending few callbacks to application g_idle_add_full() is used. g_idle_add_full() adds the callback in global main context of the application and not the context in which thread was operating. See description at https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-idle-add-full This patch modifies the logic to create a g_idle_source_new() and then attach this source to the thread's context rather than global main context of application. Change-Id: I5b9b927760ab2281cfd3878a3c7583bc4a00e74f Signed-off-by: Saurav Babu --- diff --git a/src/libnetwork.c b/src/libnetwork.c index 8f30b58..46df5f7 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -1444,6 +1444,8 @@ guint _connection_callback_add(GSourceFunc func, gpointer user_data) { guint id; struct managed_idle_data *data; + GMainContext *context; + GSource *src; if (!func) return 0; @@ -1455,8 +1457,12 @@ guint _connection_callback_add(GSourceFunc func, gpointer user_data) data->func = func; data->user_data = user_data; - id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __connection_idle_cb, data, - __connection_idle_destroy_cb); + context = g_main_context_get_thread_default(); + src = g_idle_source_new(); + g_source_set_callback(src, __connection_idle_cb, data, + __connection_idle_destroy_cb); + id = g_source_attach(src, context); + g_source_unref(src); if (!id) { g_free(data); return id;