[UTC][IoTCon][Non-ACR][Fix failed TC (stop_monitoring_p, sometimes)]
authorsung.goo.kim <sung.goo.kim@samsung.com>
Wed, 29 Jun 2016 23:16:55 +0000 (08:16 +0900)
committersung.goo.kim <sung.goo.kim@samsung.com>
Wed, 29 Jun 2016 23:16:59 +0000 (08:16 +0900)
Change-Id: I221df19b96e615146b15a0b5515f8954eeee6156

src/utc/iotcon/utc-iotcon-encap.c

index ee0d103..1e86db5 100755 (executable)
@@ -233,6 +233,20 @@ static void _encap_monitoring_cb(iotcon_remote_resource_h resource,
        }
 }
 
+static gboolean _destroy_lite_light_resource(gpointer p)
+{
+       FN_CALL;
+       int ret;
+
+       ret = iotcon_lite_resource_destroy(g_lite_light_resource);
+       if (IOTCON_ERROR_NONE != ret)
+               ICUTC_ERR("iotcon_lite_resource_destroy() Fail(%d)", ret);
+
+       g_lite_light_resource = NULL;
+
+       return G_SOURCE_REMOVE;
+}
+
 static bool _encap_found_resource(iotcon_remote_resource_h resource,
                iotcon_error_e err, void *user_data)
 {
@@ -354,6 +368,7 @@ static bool _encap_found_resource(iotcon_remote_resource_h resource,
                        _encap_main_loop_quit(false);
                        return IOTCON_FUNC_STOP;
                }
+               g_timeout_add_seconds(3, _destroy_lite_light_resource, NULL);
                return IOTCON_FUNC_STOP;
        case ENCAP_START_MONITORING_N:
                ret = iotcon_remote_resource_start_monitoring(NULL, _encap_monitoring_cb,
@@ -415,20 +430,6 @@ static bool _encap_found_resource(iotcon_remote_resource_h resource,
        return IOTCON_FUNC_STOP;
 }
 
-static gboolean _destroy_lite_light_resource(gpointer p)
-{
-       FN_CALL;
-       int ret;
-
-       ret = iotcon_lite_resource_destroy(g_lite_light_resource);
-       if (IOTCON_ERROR_NONE != ret)
-               ICUTC_ERR("iotcon_lite_resource_destroy() Fail(%d)", ret);
-
-       g_lite_light_resource = NULL;
-
-       return G_SOURCE_REMOVE;
-}
-
 static int _encap_handle_async(int tc_index)
 {
        FN_CALL;
@@ -439,9 +440,6 @@ static int _encap_handle_async(int tc_index)
        ret = _encap_create_lite_resource();
        ICUTC_ASSERT_EQ(ret, 0);
 
-       if (ENCAP_STOP_MONITORING_P == tc_index)
-               g_timeout_add_seconds(3, _destroy_lite_light_resource, NULL);
-
        ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
                        ENCAP_LIGHT_RESOURCE_TYPE, false, _encap_found_resource, (void *)tc_index);
        ICUTC_ASSERT_EQ(ret, IOTCON_ERROR_NONE);