if (u_queue_get_size(thread->dataQueue) <= 0)
{
OIC_LOG_V(DEBUG, TAG, "wait..");
+
// wait
u_cond_wait(thread->threadCond, thread->threadMutex);
thread->dataQueue = u_queue_create();
thread->threadMutex = u_mutex_new();
thread->threadCond = u_cond_new();
- thread->isStop = CA_FALSE;
+ thread->isStop = CA_TRUE;
thread->threadTask = task;
return CA_STATUS_OK;
return res;
}
+ thread->isStop = CA_FALSE;
+
return res;
}
OIC_LOG_V(DEBUG, TAG, "thread stop request!!");
- // mutex lock
- u_mutex_lock(thread->threadMutex);
+ if (!thread->isStop)
+ {
+ // mutex lock
+ u_mutex_lock(thread->threadMutex);
- // set stop flag
- thread->isStop = CA_TRUE;
+ // set stop flag
+ thread->isStop = CA_TRUE;
- // notity the thread
- u_cond_signal(thread->threadCond);
+ // notity the thread
+ u_cond_signal(thread->threadCond);
- u_cond_wait(thread->threadCond, thread->threadMutex);
+ u_cond_wait(thread->threadCond, thread->threadMutex);
- // mutex unlock
- u_mutex_unlock(thread->threadMutex);
+ // mutex unlock
+ u_mutex_unlock(thread->threadMutex);
+ }
return CA_STATUS_OK;
}