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;
}
else
{
+ oc_mutex_lock(g_mutexObjectList);
uint32_t length = u_arraylist_length(caglobals.tcp.svrlist);
for (size_t i = 0; i < length; i++)
{
}
}
}
+ oc_mutex_unlock(g_mutexObjectList);
}
}
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();
CATCPSessionInfo_t *CAGetSessionInfoFromFD(int fd, size_t *index)
{
- oc_mutex_lock(g_mutexObjectList);
// check from the last item.
CATCPSessionInfo_t *svritem = NULL;
}
}
- oc_mutex_unlock(g_mutexObjectList);
return NULL;
}