Fix enrollee sample application's crach issue
authorJihun Ha <jihun.ha@samsung.com>
Mon, 24 Oct 2016 03:06:35 +0000 (12:06 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 24 Oct 2016 05:00:51 +0000 (05:00 +0000)
Before OCStop() is called, listen thread for calling OCProcess() should
be terminated.

Change-Id: Ibe4f702bb7c71beaf8bb58a8fe21acb873ad06d6
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13583
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Heewon Park <h_w.park@samsung.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c

index 0f2450e..a3126c0 100755 (executable)
@@ -32,6 +32,7 @@
 #define TAG "ENROLLEE_SAMPLE"
 
 void *listeningFunc(void *);
+pthread_t thread_handle = NULL;
 
 /**
  * Secure Virtual Resource database for Iotivity Server
@@ -159,7 +160,6 @@ void StartEasySetup()
     }
     printf("ESInitEnrollee Success\n");
 
-    pthread_t thread_handle = NULL;
     if (pthread_create(&thread_handle, NULL, listeningFunc, NULL))
     {
         printf("Thread creation failed\n");
@@ -200,6 +200,12 @@ void StopEasySetup()
         return;
     }
 
+    if (0 != pthread_cancel(thread_handle))
+    {
+        printf("Thread cancellation failed\n");
+        return;
+    }
+
     //stop OC Stack
     if (OCStop() != OC_STACK_OK)
     {