+ // Dont invoke callback locking mutex
+ unsigned char *mesBuf = svritem->tlsdata;
+ svritem->tlsdata = NULL;
+ oc_mutex_unlock(g_mutexObjectList);
+
+ res = g_packetReceivedCallback(&peerEP, mesBuf, len);
+
+ // Check for the svritem and reset buffer
+ oc_mutex_lock(g_mutexObjectList);
+ svritem = CAGetSessionInfoFromFDAsOwner(fd, &index);
+ if (svritem)
+ {
+ svritem->tlsdata = mesBuf;
+ svritem->tlsLen = 0;
+ }
+ else
+ {
+ // svritem does not exist, thus free the message buffer
+ OIC_LOG(ERROR, TAG, "svritem not found. Freeing message buffer!");
+ OICFree(mesBuf);
+ }