From ed229def4d41d07ebbea02260bebaebe1491d256 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Mon, 24 Oct 2016 12:06:35 +0900 Subject: [PATCH] Fix enrollee sample application's crach issue Before OCStop() is called, listen thread for calling OCProcess() should be terminated. Change-Id: Ibe4f702bb7c71beaf8bb58a8fe21acb873ad06d6 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/13583 Tested-by: jenkins-iotivity Reviewed-by: Heewon Park Reviewed-by: Madan Lanka (cherry picked from commit 9331e5eddab194f9f17bf09c3b0c70da5c87ab77) Reviewed-on: https://gerrit.iotivity.org/gerrit/13593 Reviewed-by: Uze Choi --- service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c index 0f2450e..a3126c0 100755 --- a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c +++ b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c @@ -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) { -- 2.7.4