[wifi] Modified logic so that callback is sent to their respective thread 23/56323/1
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 6 Jan 2016 10:06:05 +0000 (15:36 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Wed, 6 Jan 2016 10:06:05 +0000 (15:36 +0530)
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: If9a52eff79a9684edf572e6707372f630f3cac61
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/libnetwork.c

index 1118035..b4b0c63 100755 (executable)
@@ -1287,6 +1287,8 @@ guint _wifi_callback_add(GSourceFunc func, gpointer user_data)
 {
        guint id;
        struct managed_idle_data *data;
+       GMainContext *context;
+       GSource *src;
 
        if (!func)
                return 0;
@@ -1298,8 +1300,12 @@ guint _wifi_callback_add(GSourceFunc func, gpointer user_data)
        data->func = func;
        data->user_data = user_data;
 
-       id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __wifi_idle_cb, data,
-                       __wifi_idle_destroy_cb);
+       context = g_main_context_get_thread_default();
+       src = g_idle_source_new();
+       g_source_set_callback(src, __wifi_idle_cb, data, __wifi_idle_destroy_cb);
+       id = g_source_attach(src, context);
+       g_source_unref(src);
+
        if (!id) {
                g_free(data);
                return id;