projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implementation of connectivity abstraction feature Release v0.5
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
connectivity
/
src
/
caqueueingthread.c
diff --git
a/resource/csdk/connectivity/src/caqueueingthread.c
b/resource/csdk/connectivity/src/caqueueingthread.c
index
11fbee2
..
18da00d
100644
(file)
--- 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..");
if (u_queue_get_size(thread->dataQueue) <= 0)
{
OIC_LOG_V(DEBUG, TAG, "wait..");
+
// wait
u_cond_wait(thread->threadCond, thread->threadMutex);
// 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->dataQueue = u_queue_create();
thread->threadMutex = u_mutex_new();
thread->threadCond = u_cond_new();
- thread->isStop = CA_
FALS
E;
+ thread->isStop = CA_
TRU
E;
thread->threadTask = task;
return CA_STATUS_OK;
thread->threadTask = task;
return CA_STATUS_OK;
@@
-138,6
+139,8
@@
CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread)
return res;
}
return res;
}
+ thread->isStop = CA_FALSE;
+
return res;
}
return res;
}
@@
-212,19
+215,22
@@
CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread)
OIC_LOG_V(DEBUG, TAG, "thread stop request!!");
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;
}
return CA_STATUS_OK;
}