mot-agent: Remove mot device list before discovering
authorSaurav Babu <saurav.babu@samsung.com>
Thu, 1 Feb 2018 12:30:33 +0000 (18:00 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:48 +0000 (19:38 +0900)
This patch also removes checking of pending call to OCF method when
discovering mot enabled devices and my owned devices

Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/mot-agent/ma-subowner.c

index 18550c8b8a54f5e5187175b20d87755bba0975a9..794e2e4da7ebf39ecd7266e65feb5c13dc32c895 100644 (file)
@@ -861,6 +861,9 @@ static gpointer _disc_mot_env_devs_func(gpointer data)
 
        MA_LOGI("Discovering Multiple Ownership Transfer enabled Devices on Network..");
 
+       /* delete mot device lists before updating them */
+       _remove_mot_client();
+
        g_mutex_lock(&iotivity_mutex);
        OCDiscoverMultipleOwnerEnabledDevices(con->timeout, &g_client->g_motdev_list);
        g_mutex_unlock(&iotivity_mutex);
@@ -891,6 +894,13 @@ static int _disc_mot_enb_devs(ma_service *service, int timeout)
                return MA_ERROR_OUT_OF_MEMORY;
        }
 
+       con->userdata = service;
+       con->cid = MA_DISC_MOT_ENB_DEVS;
+
+       if (timeout < 1)
+               timeout = DISCOVERY_TIMEOUT;
+       con->timeout = timeout;
+
        con->thread = g_thread_try_new("disc_mot_env_devs", _disc_mot_env_devs_func, con, NULL);
        if (!con->thread) {
                MA_LOGE("Failed to create thread");
@@ -899,16 +909,6 @@ static int _disc_mot_enb_devs(ma_service *service, int timeout)
        }
        g_thread_unref(con->thread);
 
-       /* delete un/owned device lists before updating them */
-       _remove_mot_client();
-
-       con->userdata = service;
-       con->cid = MA_DISC_MOT_ENB_DEVS;
-
-       if (timeout < 1)
-               timeout = DISCOVERY_TIMEOUT;
-       con->timeout = timeout;
-
 #ifdef TIMEOUT_USED
        con->tid = g_timeout_add_seconds(timeout * 2, _ma_timeout_cb, con);
 #endif
@@ -2523,11 +2523,13 @@ int ma_request_disc_mot_enb_devs(ma_service *service, int timeout)
        MA_LOGD("[IPC] Discovery MOT enabled devices");
 
        /* If we are working now? */
+       /*
        if (g_atomic_int_get(&service->pending))
                return MA_ERROR_IN_PROGRESS;
+               */
 
        /* Set d2ds status 'pending' */
-       g_atomic_int_set(&service->pending, 1);
+       //g_atomic_int_set(&service->pending, 1);
 
        ret = _disc_mot_enb_devs(service, timeout);
 
@@ -2543,11 +2545,13 @@ int ma_request_disc_owned_devs(ma_service *service, int timeout)
        MA_LOGD("[IPC] Discovery Owned devices");
 
        /* If we are working now? */
+       /*
        if (g_atomic_int_get(&service->pending))
                return MA_ERROR_IN_PROGRESS;
+               */
 
        /* Set d2ds status 'pending' */
-       g_atomic_int_set(&service->pending, 1);
+       //g_atomic_int_set(&service->pending, 1);
 
        ret = _disc_owned_devs(service, timeout);