CAResult_t CADisconnectTCPSession(size_t index)
{
+ oc_mutex_lock(g_mutexObjectList);
CATCPSessionInfo_t *removedData = u_arraylist_remove(caglobals.tcp.svrlist, index);
if (!removedData)
{
OIC_LOG(DEBUG, TAG, "there is no data to be removed");
+ oc_mutex_unlock(g_mutexObjectList);
return CA_STATUS_OK;
}
-
+ oc_mutex_unlock(g_mutexObjectList);
// close the socket and remove session info in list.
if (removedData->fd >= 0)
{
g_connectionCallback(&(removedData->sep.endpoint), false, removedData->isClient);
}
}
- OICFree(removedData->data);
- removedData->data = NULL;
-
- OICFree(removedData->tlsdata);
- removedData->tlsdata = NULL;
+ if (removedData->data)
+ {
+ OICFree(removedData->data);
+ removedData->data = NULL;
+ }
- OICFree(removedData);
- removedData = NULL;
+ if (removedData->tlsdata)
+ {
+ OICFree(removedData->tlsdata);
+ removedData->tlsdata = NULL;
+ }
+ if (removedData)
+ {
+ OICFree(removedData);
+ removedData = NULL;
+ }
OIC_LOG(DEBUG, TAG, "data is removed from session list");
#ifndef DISABLE_TCP_SERVER