Fix crashes and blocking with curl threads 40/162540/2 accepted/tizen/4.0/unified/20171205.060622 submit/tizen_4.0/20171204.082851
authorchanywa <cbible.kim@samsung.com>
Mon, 4 Dec 2017 06:56:49 +0000 (15:56 +0900)
committerchanywa <cbible.kim@samsung.com>
Mon, 4 Dec 2017 07:04:08 +0000 (16:04 +0900)
Change-Id: Ie9e1ebbc92d1d47de2a1394f752d96d06be4cece
Signed-off-by: chanywa <cbible.kim@samsung.com>
maps-plugin-mapzen.changes
packaging/maps-plugin-mapzen.spec
src/mapzen/mapzen_restcurl.c

index 107e3e6..9f9ee80 100644 (file)
@@ -1,3 +1,8 @@
+[Version]   maps-plugin-mapzen_0.0.9
+[Date]      04 Dec 2017
+[Title]     Fix crashes and blocking with curl threads
+[Developer] Seechan Kim <cbible.kim@samsung.com>
+
 [Version]   maps-plugin-mapzen_0.0.8
 [Date]      30 Nov 2017
 [Title]     Fix crashes when terminating threads
index 85b6264..a0081a8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       maps-plugin-mapzen
 Summary:    Tizen Mapzen Maps Plug-in Library
-Version:    0.0.8
+Version:    0.0.9
 Release:    1
 Group:      Location/Libraries
 License:    Apache-2.0 and MIT
index 91b799d..3414298 100644 (file)
@@ -306,8 +306,8 @@ static size_t __write_memory_callback(void *contents, size_t size, size_t nmemb,
 
        mem->size += realsize;
 
-       MAP_DEBUG("REal size : %d", realsize);
-       MAP_DEBUG("response size :: %d", strlen(mem->memory));
+       MAP_DEBUG("Real size : %d", realsize);
+       MAP_DEBUG("Response size :: %d", strlen(mem->memory));
 
        return realsize;
 }
@@ -407,7 +407,7 @@ int add_handle(const char *url, mapzen_req_type type, void *user_data)
 
        curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 0L);
 
-       curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
+       curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1L);
 
        curl_easy_setopt(curl_handle, CURLOPT_PROXY, __proxy_address);
 
@@ -542,11 +542,21 @@ static void *__curl_thread_handler(void *user_data)
                }
 
                pthread_mutex_lock(&__curl_deliver_mutex);
-               if (__thread_running_for_curlmulti && !__MultiCurlArgsRemain)
+               if (__thread_running_for_curlmulti && !__MultiCurlArgsRemain) {
+                       #if 1
+                       struct timeval  now;
+                       struct timespec timeout;
+                       gettimeofday(&now, NULL);
+                       timeout.tv_sec = now.tv_sec + 3;
+                       timeout.tv_nsec = now.tv_usec * 1000;
+
+                       pthread_cond_timedwait(&__curl_delivered_cond, &__curl_deliver_mutex, &timeout);
+                       #else
                        pthread_cond_wait(&__curl_delivered_cond, &__curl_deliver_mutex);
+                       #endif
+               }
                pthread_mutex_unlock(&__curl_deliver_mutex);
        }
-
 #else
        /* curl_easy_perform */
 #endif
@@ -590,8 +600,8 @@ int init_curl()
        curl_multi_setopt(__cm_handle, CURLMOPT_MAXCONNECTS, (long)CURL_MAX_CONNECTS);
 
        __MultiCurlArgsRemain = 0;
-       int ret = pthread_create(&__CurlThread, NULL, &__curl_thread_handler, NULL);
        __thread_running_for_curlmulti = true;
+       int ret = pthread_create(&__CurlThread, NULL, &__curl_thread_handler, NULL);
 #endif
 
        return ret;
@@ -606,7 +616,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);