static ca_thread_pool_t g_threadPool = NULL;
/**
- * An unique identifier of receive thread.
- */
-static uint32_t g_recvThreadId = 0;
-
-/**
* Mutex to synchronize device object list.
*/
static oc_mutex g_mutexObjectList = NULL;
CAResult_t res = CA_STATUS_OK;
#ifndef __TIZENRT__
- res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, &g_recvThreadId);
+ res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, NULL);
#else
- res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, &g_recvThreadId,
+ res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, NULL,
"IoT_TCPReceive", CONFIG_IOTIVITY_TCPRECEIVE_PTHREAD_STACKSIZE);
#endif
if (CA_STATUS_OK != res)
{
- g_recvThreadId = 0;
oc_mutex_unlock(g_mutexObjectList);
OIC_LOG(ERROR, TAG, "thread_pool_add_task failed");
CATCPStopServer();
// set terminate flag.
caglobals.tcp.terminate = true;
+#ifdef __TIZENRT__
+ if (caglobals.tcp.started)
+ {
+ oc_cond_wait(g_condObjectList, g_mutexObjectList);
+ caglobals.tcp.started = false;
+ }
+#endif
+
// close accept socket.
#ifndef __WITH_TLS__
CLOSE_SOCKET(ipv4);
caglobals.tcp.shutdownFds[1] = OC_INVALID_SOCKET;
// receive thread will stop immediately
}
-#endif
if (caglobals.tcp.started)
{
oc_cond_wait(g_condObjectList, g_mutexObjectList);
caglobals.tcp.started = false;
}
-#ifndef __TIZENRT__
if (caglobals.tcp.shutdownFds[0] != OC_INVALID_SOCKET)
{
close(caglobals.tcp.shutdownFds[0]);
caglobals.tcp.shutdownFds[0] = OC_INVALID_SOCKET;
}
#endif
- CAResult_t res = ca_thread_pool_remove_task(g_threadPool, g_recvThreadId);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "ca_thread_pool_remove_task failed");
- }
- g_recvThreadId = 0;
oc_mutex_unlock(g_mutexObjectList);
CATCPDisconnectAll();