mot-agent: replace usleep with nanosleep
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 5 Feb 2018 12:44:04 +0000 (21:44 +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 794e2e4..bb9c350 100644 (file)
@@ -438,7 +438,9 @@ int _init_proc(PROC *proc, void *(*routine) (void *)) {
 static int _wait_cb_ret(int msec)
 {
        OCStackResult ret = OC_STACK_OK;
-
+       struct timespec tim, tim2;
+       tim.tv_sec = 0;
+       tim.tv_nsec = 100 * 1000000;
 #ifndef THREAD_COND_WAIT_USED
        struct timespec request, remaining;
        request.tv_sec = msec / 1000;
@@ -460,12 +462,15 @@ 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+=10) {
+       for (int i=0; !g_client->g_doneCB && msec > i; i+=100) {
                /*
                  * Basically, nanosleep is more thread-safe function,
                  * But, in our case, nanosleep cause crash frequently
                  */
-               usleep(10000);
+               ret = nanosleep(&tim, &tim2);
+               if ( 0 > ret) {
+                       MA_LOGE("nanosleep failed=%d", errno);
+               }
 
                g_mutex_lock(&iotivity_mutex);
                ret = OCProcess();