change the locaiton of callback 30/74330/3
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 14 Jun 2016 02:02:40 +0000 (11:02 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 15 Jun 2016 02:16:02 +0000 (19:16 -0700)
 from the process main context to a thread main context

Change-Id: I83d5af64c362488494bf96f89e2c44c1ba6620df

lib/icl-ioty-ocprocess.c
lib/icl-ioty.c
lib/icl-types.h

index 9ea1c851a721f6682c2e89188d4c76fdb948d160..92df4aa580ca6c1e23a9d06c97c1d690212a0f4e 100644 (file)
@@ -474,12 +474,13 @@ OCStackApplicationResult icl_ioty_ocprocess_crud_cb(void *ctx,
 {
        FN_CALL;
        int ret;
-       iotcon_response_result_e response_result;
+       GSource *idle_src;
        iotcon_options_h options;
-       icl_response_container_s *cb_container = ctx;
        iotcon_response_h response;
        iotcon_representation_h repr;
        icl_response_cb_s *response_cb_data;
+       iotcon_response_result_e response_result;
+       icl_response_container_s *cb_container = ctx;
 
        RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
        RETV_IF(NULL == resp, OC_STACK_DELETE_TRANSACTION);
@@ -549,7 +550,12 @@ OCStackApplicationResult icl_ioty_ocprocess_crud_cb(void *ctx,
                return OC_STACK_DELETE_TRANSACTION;
        }
 
-       g_idle_add(_icl_ioty_ocprocess_crud_idle_cb, response_cb_data);
+       idle_src = g_idle_source_new();
+       g_source_set_priority(idle_src, G_PRIORITY_DEFAULT);
+       g_source_set_callback(idle_src, _icl_ioty_ocprocess_crud_idle_cb, response_cb_data,
+                       NULL);
+       g_source_attach(idle_src, cb_container->thread_context);
+       g_source_unref(idle_src);
 
        /* DO NOT FREE ctx(cb_container). It MUST be freed in the ocstack */
        /* DO NOT FREE cb_data. It MUST be freed in the idle */
index 2b4cdb448ade7a4e9552cdc6701826f22f2dbf60..0bae741dba2c2f0a85402340678b025e751798d3 100644 (file)
@@ -744,6 +744,8 @@ static void _icl_ioty_free_response_container(void *data)
        }
 
        icl_remote_resource_unref(cb_container->resource);
+       g_main_context_unref(cb_container->thread_context);
+
        free(cb_container);
 }
 
@@ -850,6 +852,7 @@ static int _icl_ioty_remote_resource_crud(
        cb_container->req_type = req_type;
        cb_container->cb = cb;
        cb_container->user_data = user_data;
+       cb_container->thread_context = g_main_context_ref_thread_default();
 
        cbdata.context = cb_container;
        cbdata.cb = icl_ioty_ocprocess_crud_cb;
index 0ac9203d380a93d765e434767faade7008236fe7..3aaac16989b6f5343a136023fd90ffac2715467a 100644 (file)
@@ -18,6 +18,7 @@
 #define __IOT_CONNECTIVITY_LIBRARY_TYPES_H__
 
 #include <stdint.h>
+#include <glib.h>
 #include "iotcon-types.h"
 #include "icl-ioty.h"
 
@@ -65,6 +66,7 @@ typedef struct {
        int timeout;
        iotcon_remote_resource_h resource;
        iotcon_request_type_e req_type;
+       GMainContext *thread_context;
 } icl_response_container_s;
 
 typedef struct {