From e6905cabf5c739491937edf7fb382991057d2dbd Mon Sep 17 00:00:00 2001 From: chanywa Date: Fri, 24 Nov 2017 16:41:02 +0900 Subject: [PATCH] Fix crashes when terminating threads Change-Id: I5c90d3c8cdcb2ea46deb0f5a2fe9a4b2045a0fce --- maps-plugin-mapzen.changes | 5 +++++ packaging/maps-plugin-mapzen.spec | 2 +- src/mapzen/mapzen_restcurl.c | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/maps-plugin-mapzen.changes b/maps-plugin-mapzen.changes index 585f2d2..d1532af 100644 --- a/maps-plugin-mapzen.changes +++ b/maps-plugin-mapzen.changes @@ -1,3 +1,8 @@ +[Version] maps-plugin-mapzen_0.0.7 +[Date] 24 Nov 2017 +[Title] Fix crashes when terminating threads +[Developer] Seechan Kim + [Version] maps-plugin-mapzen_0.0.6 [Date] 30 Oct 2017 [Title] Revise timeout limits for downloading map tiles. diff --git a/packaging/maps-plugin-mapzen.spec b/packaging/maps-plugin-mapzen.spec index bfc045d..bae28a1 100644 --- a/packaging/maps-plugin-mapzen.spec +++ b/packaging/maps-plugin-mapzen.spec @@ -1,6 +1,6 @@ Name: maps-plugin-mapzen Summary: Tizen Mapzen Maps Plug-in Library -Version: 0.0.6 +Version: 0.0.7 Release: 1 Group: Location/Libraries License: Apache-2.0 and MIT diff --git a/src/mapzen/mapzen_restcurl.c b/src/mapzen/mapzen_restcurl.c index 913a717..b025a92 100644 --- a/src/mapzen/mapzen_restcurl.c +++ b/src/mapzen/mapzen_restcurl.c @@ -537,11 +537,17 @@ static void *__curl_thread_handler(void *user_data) } } - if (__thread_running_for_curlmulti && !__MultiCurlArgsRemain) { - pthread_mutex_lock(&__curl_deliver_mutex); - pthread_cond_wait(&__curl_delivered_cond, &__curl_deliver_mutex); - pthread_mutex_unlock(&__curl_deliver_mutex); - } + + struct timeval now; + struct timespec timeout; + gettimeofday(&now, NULL); + timeout.tv_sec = now.tv_sec + 3; + timeout.tv_nsec = now.tv_usec * 1000; + + pthread_mutex_lock(&__curl_deliver_mutex); + if (__thread_running_for_curlmulti && !__MultiCurlArgsRemain) + pthread_cond_timedwait(&__curl_delivered_cond, &__curl_deliver_mutex, &timeout); + pthread_mutex_unlock(&__curl_deliver_mutex); } #else @@ -604,7 +610,7 @@ int deinit_curl() pthread_cond_signal(&__curl_delivered_cond); pthread_mutex_unlock(&__curl_deliver_mutex); - pthread_cancel(__CurlThread); + //pthread_cancel(__CurlThread); pthread_join(__CurlThread, NULL); -- 2.7.4