}
else
{
- NSPushConsumerQueue(queue, obj);
+ if (msgHandleThread != NULL && msgHandleThread->isStarted)
+ {
+ NSPushConsumerQueue(queue, obj);
+ }
+ else
+ {
+ NSOICFree(data);
+ NSOICFree(obj);
+ }
}
NSThreadUnlock(msgHandleThread);
#include <memory.h>
#include "oic_malloc.h"
-static pthread_mutex_t g_create_mutex;
-
NSConsumerThread * NSThreadInit(NSThreadFunc func, void * data)
{
NS_VERIFY_NOT_NULL(func, NULL);
- pthread_mutex_init(&g_create_mutex, NULL);
-
NSConsumerThread * handle = (NSConsumerThread *)OICMalloc(sizeof(NSConsumerThread));
NS_VERIFY_NOT_NULL(handle, NULL);
NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(pthreadResult == 0 ? (void *)1 : NULL,
NULL, NSDestroyThreadHandle(handle));
- pthread_mutex_lock(&g_create_mutex);
-
handle->isStarted = true;
pthread_attr_t attrDetached = {};
pthread_attr_destroy(& attrDetached);
- pthread_mutex_unlock(&g_create_mutex);
-
return handle;
}
pthread_mutex_destroy(&(handle->mutex));
pthread_mutexattr_destroy(&(handle->mutex_attr));
-
- pthread_mutex_unlock(&g_create_mutex);
}
void NSThreadDetach()