X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fcaqueueingthread.c;h=18da00d3898a70e6ad7cf9ae6c5d6005579c953e;hb=f51e556f8addb20922bc97d2a6f9a902cbf5bb0f;hp=11fbee20623afc063295fd85e9620c7ba62ce712;hpb=88df85f0c20992acba7c96a85a1007916923b448;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/caqueueingthread.c b/resource/csdk/connectivity/src/caqueueingthread.c index 11fbee2..18da00d 100644 --- a/resource/csdk/connectivity/src/caqueueingthread.c +++ b/resource/csdk/connectivity/src/caqueueingthread.c @@ -53,6 +53,7 @@ static void CAQueueingThreadBaseRoutine(void *threadValue) if (u_queue_get_size(thread->dataQueue) <= 0) { OIC_LOG_V(DEBUG, TAG, "wait.."); + // wait u_cond_wait(thread->threadCond, thread->threadMutex); @@ -109,7 +110,7 @@ CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, u_thread_pool_ 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; @@ -138,6 +139,8 @@ CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread) return res; } + thread->isStop = CA_FALSE; + return res; } @@ -212,19 +215,22 @@ CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread) 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; }