#include "mapzen_util.h"
#define RESTCURL_USE_MULTI_CURL
+#define TIZEN_CFG_CURL_TIMEOUT 120
CURLM *__cm_handle;
pthread_t __CurlThread;
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;
}
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);
/* some servers don't like requests that are made without a user-agent field, so we provide one */
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
+ /* Timeout for the entire request */
+ curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, TIZEN_CFG_CURL_TIMEOUT);
+
pMultiCurlArg->curl_handle = curl_handle;
pMultiCurlArg->req_type = type;
pMultiCurlArg->request_id = req_id;
static void *__curl_thread_handler(void *user_data)
{
- __thread_running_for_curlmulti = true;
+ //__thread_running_for_curlmulti = true;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
#ifdef RESTCURL_USE_MULTI_CURL
}
}
+ pthread_mutex_lock(&__curl_deliver_mutex);
if (__thread_running_for_curlmulti && !__MultiCurlArgsRemain) {
- pthread_mutex_lock(&__curl_deliver_mutex);
+ #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);
- pthread_mutex_unlock(&__curl_deliver_mutex);
+ #endif
}
+ pthread_mutex_unlock(&__curl_deliver_mutex);
}
-
#else
/* curl_easy_perform */
#endif
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;
int deinit_curl()
{
#ifdef RESTCURL_USE_MULTI_CURL
+ pthread_mutex_lock(&__curl_deliver_mutex);
__thread_running_for_curlmulti = false;
__MultiCurlArgsRemain = 0;
-
- pthread_mutex_lock(&__curl_deliver_mutex);
pthread_cond_signal(&__curl_delivered_cond);
pthread_mutex_unlock(&__curl_deliver_mutex);
- pthread_cancel(__CurlThread);
+ //pthread_cancel(__CurlThread);
pthread_join(__CurlThread, NULL);