#include "oic_malloc.h"
#include "NSStructs.h"
+#include "NSConstants.h"
#include "NSConsumerCommon.h"
#include "NSThread.h"
if (NS_OK != NSConsumerListenerInit())
{
- NS_CONSUMER_LOG(ERROR, "listener init fail");
+ NS_LOG(ERROR, "listener init fail");
return NS_ERROR;
}
if (NS_OK != NSConsumerSystemInit())
{
- NS_CONSUMER_LOG(ERROR, "system init fail");
+ NS_LOG(ERROR, "system init fail");
return NS_ERROR;
}
handle = NSThreadInit(NSConsumerMsgHandleThreadFunc, NULL);
if (!handle)
{
- NS_CONSUMER_LOG(ERROR, "msg handle thread init fail");
+ NS_LOG(ERROR, "msg handle thread init fail");
return NS_ERROR;
}
NSSetMsgHandleThreadHandle(handle);
queue = NSCreateQueue();
if (!queue)
{
- NS_CONSUMER_LOG(ERROR, "msg handle queue create fail");
+ NS_LOG(ERROR, "msg handle queue create fail");
return NS_ERROR;
}
NSSetMsgHandleQueue(queue);
{
if (!NSThreadInit(NSConsumerMsgPushThreadFunc, (void *) task))
{
- NS_CONSUMER_LOG(ERROR, "insert to queue thread init fail");
+ NS_LOG(ERROR, "insert to queue thread init fail");
return NS_ERROR;
}
NSConsumerQueue * queue = NULL;
NSConsumerQueueObject * obj = NULL;
NSThreadHandle * handle = (NSThreadHandle *) threadHandle;
- NS_CONSUMER_LOG(DEBUG, "created thread for consumer message handle");
+ NS_LOG(DEBUG, "created thread for consumer message handle");
if (!handle)
{
- NS_CONSUMER_LOG(ERROR, "thread handle is null");
+ NS_LOG(ERROR, "thread handle is null");
return NULL;
}
{
if (!handle->isStarted)
{
- NS_CONSUMER_LOG(ERROR, "msg handler thread will be terminated");
+ NS_LOG(ERROR, "msg handler thread will be terminated");
break;
}
}
NSThreadLock(handle);
- NS_CONSUMER_LOG(DEBUG, "msg handler working");
+ NS_LOG(DEBUG, "msg handler working");
obj = NSPopQueue(queue);
- // TODO processing obj
- NSConsumerHandleMsg((NSTask *)(obj->data));
+ if (obj)
+ {
+ NSConsumerHandleMsg((NSTask *)(obj->data));
+ }
NSThreadUnlock(handle);
NSThreadHandle * handle = *(NSGetMsgHandleThreadHandle());
if (!handle)
{
- NS_CONSUMER_LOG(ERROR, "NSThreadHandle is null. can not insert to queue");
+ NS_LOG(ERROR, "NSThreadHandle is null. can not insert to queue");
return NULL;
}
obj = (NSConsumerQueueObject *)OICMalloc(sizeof(NSConsumerQueueObject));
if (!obj)
{
- NS_CONSUMER_LOG(ERROR, "NSConsumerQueueObject allocation fail");
+ NS_LOG(ERROR, "NSConsumerQueueObject allocation fail");
return NULL;
}
queue = *(NSGetMsgHandleQueue());
if (!queue)
{
- NS_CONSUMER_LOG(ERROR, "NSQueue is null. can not insert to queue");
+ NS_LOG(ERROR, "NSQueue is null. can not insert to queue");
OICFree(data);
OICFree(obj);
}
break;
}
case TASK_CONSUMER_REQ_SUBSCRIBE:
+ case TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL:
case TASK_SEND_READ:
case TASK_SEND_DISMISS:
{
break;
}
default:
- NS_CONSUMER_LOG(ERROR, "Unknown type of task");
+ NS_LOG(ERROR, "Unknown type of task");
break;
}
}