fix the problem when structures are destoried, repeatedly accepted/tizen/mobile/20151207.123349 accepted/tizen/tv/20151207.123404 accepted/tizen/wearable/20151207.123422 submit/tizen/20151207.045529
authoryoungman <yman.jung@samsung.com>
Thu, 3 Dec 2015 03:09:02 +0000 (12:09 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 7 Dec 2015 04:51:42 +0000 (13:51 +0900)
Change-Id: I2f7983126f7864fe9945b6a8d82cf647f3da7c50
Signed-off-by: youngman <yman.jung@samsung.com>
daemon/icd-ioty-ocprocess.c
lib/icl-device.c
lib/icl-lite-resource.c
lib/icl-presence.c
lib/icl-remote-resource-caching.c
lib/icl-remote-resource-crud.c
lib/icl-remote-resource-monitoring.c
lib/icl-remote-resource.c
lib/icl-resource.c

index 960a51dd35f769612d507b57ea9c9eef867ae76f..bfa8804276d2adb393e9b7120632e4e37c278cee 100644 (file)
@@ -785,14 +785,19 @@ OCStackApplicationResult icd_ioty_ocprocess_observe_cb(void *ctx,
        GVariantBuilder *options;
        struct icd_observe_context *observe_ctx;
        icd_sig_ctx_s *sig_context = ctx;
+       OCStackApplicationResult cb_result;
 
        RETV_IF(NULL == ctx, OC_STACK_KEEP_TRANSACTION);
+       RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION);
+
+       cb_result = (OC_OBSERVE_DEREGISTER == resp->sequenceNumber)?
+               OC_STACK_DELETE_TRANSACTION:OC_STACK_KEEP_TRANSACTION;
 
        if (NULL == resp->payload) {
                ERR("payload is empty");
                _observe_cb_response_error(sig_context->bus_name, sig_context->signal_number,
                                IOTCON_ERROR_IOTIVITY);
-               return OC_STACK_KEEP_TRANSACTION;
+               return cb_result;
        }
 
        observe_ctx = calloc(1, sizeof(struct icd_observe_context));
@@ -800,7 +805,7 @@ OCStackApplicationResult icd_ioty_ocprocess_observe_cb(void *ctx,
                ERR("calloc() Fail(%d)", errno);
                _observe_cb_response_error(sig_context->bus_name, sig_context->signal_number,
                                IOTCON_ERROR_OUT_OF_MEMORY);
-               return OC_STACK_KEEP_TRANSACTION;
+               return cb_result;
        }
 
        res = _ocprocess_parse_oic_result(resp->result);
@@ -824,13 +829,13 @@ OCStackApplicationResult icd_ioty_ocprocess_observe_cb(void *ctx,
                        g_variant_unref(observe_ctx->payload);
                g_variant_builder_unref(observe_ctx->options);
                free(observe_ctx);
-               return OC_STACK_KEEP_TRANSACTION;
+               return cb_result;
        }
 
        /* DO NOT FREE sig_context. It MUST be freed in the ocstack */
        /* DO NOT FREE observe_ctx. It MUST be freed in the _worker_observe_cb func */
 
-       return OC_STACK_KEEP_TRANSACTION;
+       return cb_result;
 }
 
 
index 50238f239a478847e9b4829c651862056c016caf..4a12c246e97df2013651e257e2b229ebf0e879d6 100644 (file)
@@ -125,6 +125,7 @@ static gboolean _icl_timeout_get_device_info(gpointer p)
                cb_container->cb(&info, IOTCON_ERROR_TIMEOUT, cb_container->user_data);
 
        icl_dbus_unsubscribe_signal(cb_container->id);
+       cb_container->id = 0;
 
        return G_SOURCE_REMOVE;
 }
@@ -304,6 +305,7 @@ static gboolean _icl_timeout_get_platform_info(gpointer p)
                cb_container->cb(&info, IOTCON_ERROR_TIMEOUT, cb_container->user_data);
 
        icl_dbus_unsubscribe_signal(cb_container->id);
+       cb_container->id = 0;
 
        return G_SOURCE_REMOVE;
 }
index 8233a956092c7a19a8370d86335fcc7fa0071225..beb71a0bb5fa5e9b28b3a063c32dddf9dd36be6e 100644 (file)
@@ -385,6 +385,7 @@ API int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource)
        resource->handle = 0;
 
        icl_dbus_unsubscribe_signal(resource->sub_id);
+       resource->sub_id = 0;
 
        return IOTCON_ERROR_NONE;
 }
index 8ae81c9eb84cbac0e2da7af4e0b6ef0e983a97a0..8b9dab2a2bca3a75c90538dfaa4c69a48638bdfa 100644 (file)
@@ -281,6 +281,7 @@ API int iotcon_remove_presence_cb(iotcon_presence_h presence)
        presence->handle = 0;
 
        icl_dbus_unsubscribe_signal(presence->sub_id);
+       presence->sub_id = 0;
 
        return IOTCON_ERROR_NONE;
 }
index ba9fe32c0d20fe75b9de254c550b4e5981acf34d..e39380d7a18d227f063f2d02985ee02fd5013ace 100644 (file)
@@ -180,6 +180,7 @@ API int iotcon_remote_resource_stop_caching(iotcon_remote_resource_h resource)
        }
 
        icl_dbus_unsubscribe_signal(resource->caching_sub_id);
+       resource->caching_sub_id = 0;
 
        return IOTCON_ERROR_NONE;
 }
index b97329ccb8187674b0a938a72b8dc7fa83d5d1eb..0724b00cd278361b614a3fa6d8f38f81e1812fde 100644 (file)
@@ -550,8 +550,11 @@ API int iotcon_remote_resource_observe_deregister(iotcon_remote_resource_h resou
                ERR("iotcon-daemon Fail(%d)", ret);
                return icl_dbus_convert_daemon_error(ret);
        }
+       resource->observe_handle = 0;
 
        icl_dbus_unsubscribe_signal(resource->observe_sub_id);
+       resource->observe_sub_id = 0;
+
 
        return IOTCON_ERROR_NONE;
 }
index 600e8e760ccb8f7105893158869a41cf33759733..5bdcd7c1efae635a146c6140345d83a2582ba38d 100644 (file)
@@ -156,6 +156,7 @@ API int iotcon_remote_resource_stop_monitoring(iotcon_remote_resource_h resource
        }
 
        icl_dbus_unsubscribe_signal(resource->monitoring_sub_id);
+       resource->monitoring_sub_id = 0;
 
        return IOTCON_ERROR_NONE;
 }
index 5bb01767f67bc50e01539935e5b145ae81456716..0337060d9d3b270dbfce6222cd769c62e4677262 100644 (file)
@@ -88,6 +88,7 @@ static gboolean _icl_timeout_find_resource(gpointer p)
                cb_container->cb(NULL, IOTCON_ERROR_TIMEOUT, cb_container->user_data);
 
        icl_dbus_unsubscribe_signal(cb_container->id);
+       cb_container->id = 0;
 
        return G_SOURCE_REMOVE;
 }
index 2e54af52712735d58d90878d860f9d1e291acab0..b077a6c6a852dfc487c7f4164ce86eb678e598c7 100644 (file)
@@ -265,7 +265,9 @@ API int iotcon_resource_destroy(iotcon_resource_h resource)
                return ret;
        }
        resource->handle = 0;
+
        icl_dbus_unsubscribe_signal(resource->sub_id);
+       resource->sub_id = 0;
 
        return IOTCON_ERROR_NONE;
 }