[NS] Notification consumer valgrind invalid read/write fix.
authorJay Sharma <jay.sharma@samsung.com>
Fri, 9 Jun 2017 06:39:31 +0000 (12:09 +0530)
committerRick Bell <richard.s.bell@intel.com>
Mon, 19 Jun 2017 18:36:43 +0000 (18:36 +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>
(cherry picked from commit bdc2263c344879854b914ec5efd0e232137c49c2)
Reviewed-on: https://gerrit.iotivity.org/gerrit/20663
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: George Nash <george.nash@intel.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;
 }