comp-manager: Reset retry count when device discovery is in progress
authorSaurav Babu <saurav.babu@samsung.com>
Fri, 2 Feb 2018 04:31:19 +0000 (10:01 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:48 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/companion-manager/src/comp_group.c

index 96e1749..86073e8 100644 (file)
@@ -355,9 +355,12 @@ void comp_group_notify_mot_enable_device_done(int device_count)
 
        notify_device_found(count, device_data);
 
-       if (find_mot_enb_dev_retry_cnt < RETRY_COUNT) {
-               find_mot_enb_dev_retry_cnt += 1;
+       if (find_mot_enb_dev_retry_cnt <= RETRY_COUNT) {
                g_timeout_add(RETRY_INTERVAL, __retry_find_mot_enable_device, NULL);
+               find_mot_enb_dev_retry_cnt += 1;
+       } else {
+               LOG_DEBUG("Find MOT enabled device finished");
+               find_mot_enb_dev_retry_cnt = 0;
        }
 
        LOG_END();
@@ -373,7 +376,11 @@ int comp_group_find_mot_enabled_devices(int timeout)
        g_list_free_full (mot_enb_dev_list, _mot_enb_dev_list_free_func);
        mot_enb_dev_list = NULL;
 
-       find_mot_enb_dev_retry_cnt = 0;
+       if (find_mot_enb_dev_retry_cnt != 0) {
+               find_mot_enb_dev_retry_cnt = 1;
+               LOG_DEBUG("Find MOT enables devices in progress, reset retry count");
+               return COMP_ERROR_NONE;
+       }
 
        ret = agent_find_mot_enable_devices(timeout);
        if (ret != COMP_ERROR_NONE) {
@@ -797,9 +804,12 @@ void comp_group_notify_mowned_device_find_done(int device_count)
 
        notify_mowned_device_found(count, device_data);
 
-       if (find_mowned_dev_retry_cnt < RETRY_COUNT) {
-               find_mowned_dev_retry_cnt += 1;
+       if (find_mowned_dev_retry_cnt <= RETRY_COUNT) {
                g_timeout_add(RETRY_INTERVAL, __retry_find_mowned_devices, NULL);
+               find_mowned_dev_retry_cnt += 1;
+       } else {
+               LOG_DEBUG("Find My owned devices finished");
+               find_mowned_dev_retry_cnt = 0;
        }
 
        LOG_END();
@@ -815,7 +825,11 @@ int comp_group_find_mowned_devices(int timeout)
        g_list_free_full(mowned_dev_list, _mot_enb_dev_list_free_func);
        mowned_dev_list = NULL;
 
-       find_mowned_dev_retry_cnt = 0;
+       if (find_mowned_dev_retry_cnt != 0) {
+               find_mowned_dev_retry_cnt = 1;
+               LOG_DEBUG("Find My owned devices in progress, reset retry count");
+               return COMP_ERROR_NONE;
+       }
 
        ret = agent_find_mowned_devices(timeout);
        if (ret != COMP_ERROR_NONE) {