[NS] Notification consumer valgrind invalid read/write fix. 31/20831/2
authorJay Sharma <jay.sharma@samsung.com>
Fri, 9 Jun 2017 06:39:31 +0000 (12:09 +0530)
committerHabib Virji <habib.virji@samsung.com>
Thu, 15 Jun 2017 12:17:57 +0000 (12:17 +0000)
Bug: https://jira.iotivity.org/browse/IOT-2373
Change-Id: Ifd3789538c3d368b7ca3da52d274bb7ed531c126
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20831
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
service/notification/src/consumer/NSConsumerScheduler.c

index 9d706e6..c313453 100644 (file)
@@ -207,12 +207,14 @@ void * NSConsumerMsgHandleThreadFunc(void * threadHandle)
 
 void * NSConsumerMsgPushThreadFunc(void * data)
 {
+    pthread_mutex_lock(&g_start_mutex);
     NSConsumerQueueObject * obj = NULL;
 
     NS_LOG(DEBUG, "get queueThread handle");
     if (NULL == g_handle)
     {
         NSOICFree(data);
+        pthread_mutex_unlock(&g_start_mutex);
         return NULL;
     }
     NSThreadLock(g_handle);
@@ -222,6 +224,7 @@ void * NSConsumerMsgPushThreadFunc(void * data)
     NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(obj, NULL,
               {
                       NSThreadUnlock(g_handle);
+                      pthread_mutex_unlock(&g_start_mutex);
                       NSOICFree(data);
               });
 
@@ -241,6 +244,7 @@ void * NSConsumerMsgPushThreadFunc(void * data)
     }
 
     NSThreadUnlock(g_handle);
+    pthread_mutex_unlock(&g_start_mutex);
 
     return NULL;
 }