mot-agent: fix waiting time as 100ms
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 1 Feb 2018 02:34:38 +0000 (11:34 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:48 +0000 (19:38 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/mot-agent/ma-subowner.c

index 2a00ada..9f30dd2 100644 (file)
@@ -435,14 +435,14 @@ int _init_proc(PROC *proc, void *(*routine) (void *)) {
        return MA_ERROR_NONE;
 }
 #endif
-static int _wait_cb_ret(int msec)
+static int _wait_cb_ret(unsigned int msec)
 {
        OCStackResult ret = OC_STACK_OK;
-
+       unsigned int i, times = msec  /100;
 #ifndef THREAD_COND_WAIT_USED
        struct timespec request, remaining;
-       request.tv_sec = msec / 1000;
-       request.tv_nsec = (msec % 1000) * 1000000;
+       request.tv_sec = 0;
+       request.tv_nsec = 1000000;
 #endif
 
        ma_check_null_ret_error("g_client", g_client, OC_STACK_INVALID_PARAM);
@@ -460,15 +460,18 @@ static int _wait_cb_ret(int msec)
 
        pthread_join(proc_a.thread, (void*) &result_a);
 #else
-       for (int i=0; !g_client->g_doneCB && msec > i; ++i) {
+       for (i = 0; !g_client->g_doneCB && times >  i; ++i) {
+
                ret = nanosleep(&request, &remaining);
                if (-1 == ret && EINTR == errno) {
                        MA_LOGE( "Onanosleep error = %d", errno);
                        break;
                }
+
                g_mutex_lock(&iotivity_mutex);
                ret = OCProcess();
                g_mutex_unlock(&iotivity_mutex);
+
                if (OC_STACK_OK != ret) {
                        MA_LOGE( "OCStack process error = %d", ret);
                        break;