From: sung.goo.kim Date: Tue, 20 Oct 2015 05:43:22 +0000 (+0900) Subject: (fix bug) free handle regardless of dbus connection X-Git-Tag: submit/tizen/20151130.235229~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ab3546779d4d2771d16221e01221ef02e7b059d;p=platform%2Fcore%2Fiot%2Fiotcon.git (fix bug) free handle regardless of dbus connection Change-Id: I6337388365259a682c4cbc042b6f4404bef315e9 --- diff --git a/lib/icl-presence.c b/lib/icl-presence.c index 5dba296..5345cd8 100644 --- a/lib/icl-presence.c +++ b/lib/icl-presence.c @@ -209,15 +209,19 @@ API int iotcon_unsubscribe_presence(iotcon_presence_h presence) int ret; GError *error = NULL; - RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS); RETV_IF(NULL == presence, IOTCON_ERROR_INVALID_PARAMETER); - if (0 == presence->id) { + if (0 == presence->id) { /* disconnected iotcon dbus */ WARN("Invalid Presence handle"); free(presence); return IOTCON_ERROR_NONE; } + if (NULL == icl_dbus_get_object()) { + ERR("icl_dbus_get_object() return NULL"); + return IOTCON_ERROR_DBUS; + } + ic_dbus_call_unsubscribe_presence_sync(icl_dbus_get_object(), presence->handle, &ret, NULL, &error); if (error) { diff --git a/lib/icl-resource.c b/lib/icl-resource.c index bae3ae4..2efa040 100644 --- a/lib/icl-resource.c +++ b/lib/icl-resource.c @@ -243,10 +243,9 @@ API int iotcon_resource_destroy(iotcon_resource_h resource) int ret; GError *error = NULL; - RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS); RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); - if (0 == resource->sub_id) { + if (0 == resource->handle) { /* iotcon dbus disconnected */ WARN("Invalid Resource handle"); iotcon_resource_types_destroy(resource->types); if (resource->observers) @@ -256,6 +255,11 @@ API int iotcon_resource_destroy(iotcon_resource_h resource) return IOTCON_ERROR_NONE; } + if (NULL == icl_dbus_get_object()) { + ERR("icl_dbus_get_object() return NULL"); + return IOTCON_ERROR_DBUS; + } + ic_dbus_call_unregister_resource_sync(icl_dbus_get_object(), resource->handle, NULL, &error); if (error) { @@ -264,9 +268,7 @@ API int iotcon_resource_destroy(iotcon_resource_h resource) g_error_free(error); return ret; } - resource->handle = 0; - icl_dbus_unsubscribe_signal(resource->sub_id); return IOTCON_ERROR_NONE;