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 960a51d..bfa8804 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 50238f2..4a12c24 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 8233a95..beb71a0 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 8ae81c9..8b9dab2 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 ba9fe32..e39380d 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 b97329c..0724b00 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 600e8e7..5bdcd7c 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 5bb0176..0337060 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 2e54af5..b077a6c 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;
 }