+#if defined(__TIZEN__) && !defined(SINGLE_THREAD)
+ // CAcloseSslConnection returns CAResult_t instead of void*, but the size is the same and crash shouldn't occur
+ pthread_t ccThread;
+ pthread_attr_t attr;
+ int initAttrRes = -1;
+ int pthreadCreateRes = -1;
+ int detachStatusRes = -1;
+ int memoryAllocationRes = -1;
+
+ do
+ {
+ initAttrRes = pthread_attr_init(&attr);
+ if (initAttrRes != 0)
+ {
+ break;
+ }
+ CAEndpoint_t *localEndpointCpyPtr = OICMalloc(sizeof(CAEndpoint_t));
+
+ if(NULL == localEndpointCpyPtr)
+ {
+ memoryAllocationRes = -1;
+ break;
+ }
+ else
+ {
+ memoryAllocationRes = 0;
+ }
+
+ (*localEndpointCpyPtr) = localEndpoint;
+ // this piece of code is reached on the main thread
+ // CAcloseSslConnection might wait for too long (network + mutexes) and watchdog might kill it
+ // Asynchronous call protects this function from watchdog
+ pthreadCreateRes = pthread_create(&ccThread, &attr, (void *(*)(void*))&CAcloseSslConnectionFreeEndpoint, (void*)localEndpointCpyPtr);
+
+ if (pthreadCreateRes != 0)
+ {
+ break;
+ }
+ detachStatusRes = pthread_detach(ccThread);
+ }while (0);
+
+ // regardless of CAcloseSslConnection result, the function will continue and g_connectionCallback will be called
+ OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "CAcloseSslConnection pthread_init [%d], mem_alloc [%d] pthread_create [%d], pthread_detach [%d]",
+ initAttrRes, memoryAllocationRes, pthreadCreateRes, detachStatusRes);
+#else