summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-10-20 18:21:21 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-10-20 18:21:21 +0200
commit1da471abba1a64b691b8c90ac13bae81daa1c698 (patch)
tree1a85fb5e8ef2697972c64a5511a5c5b9c26aa59f /common
parent5a87fb337dc034c6d96ff74d20c5c257c0a65b77 (diff)
downloadqtlocation-mapboxgl-1da471abba1a64b691b8c90ac13bae81daa1c698.tar.gz
curl fixes
[skip ci]
Diffstat (limited to 'common')
-rw-r--r--common/http_request_baton_curl.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp
index 772aeb86e1..d4753266c0 100644
--- a/common/http_request_baton_curl.cpp
+++ b/common/http_request_baton_curl.cpp
@@ -52,7 +52,7 @@
// Handles the request thread + messaging to the thread.
static uv_once_t once;
-static uv_loop_t loop;
+static uv_loop_t *loop = nullptr;
static uv_messenger_t start_messenger;
static uv_messenger_t stop_messenger;
static uv_thread_t thread;
@@ -228,7 +228,7 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
context->sockfd = sockfd;
assert(!context->poll_handle);
context->poll_handle = new uv_poll_t;
- uv_poll_init_socket(&loop, context->poll_handle, sockfd);
+ uv_poll_init_socket(loop, context->poll_handle, sockfd);
context->poll_handle->data = context;
curl_multi_assign(multi, sockfd, context);
}
@@ -253,7 +253,11 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
return 0;
}
+#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
+void on_timeout(uv_timer_t *, int = 0) {
+#else
void on_timeout(uv_timer_t *) {
+#endif
int running_handles;
CURLMcode error = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles);
if (error != CURLM_OK) {
@@ -275,7 +279,7 @@ void thread_init(void *) {
#endif
thread_id = uv_thread_self();
- uv_timer_init(&loop, &timeout);
+ uv_timer_init(loop, &timeout);
CURLSHcode share_error;
share = curl_share_init();
@@ -305,7 +309,7 @@ void thread_init(void *) {
}
// Main event loop. This will not return until the request loop is terminated.
- uv_run(&loop, UV_RUN_DEFAULT);
+ uv_run(loop, UV_RUN_DEFAULT);
curl_multi_cleanup(multi);
multi = nullptr;
@@ -442,9 +446,14 @@ void stop_request(void *const ptr) {
void create_thread() {
uv_mutex_init(&share_mutex);
- uv_loop_init(&loop);
- uv_messenger_init(&loop, &start_messenger, start_request);
- uv_messenger_init(&loop, &stop_messenger, stop_request);
+#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
+ loop = uv_loop_new();
+#else
+ loop = new uv_loop_t;
+ uv_loop_init(loop);
+#endif
+ uv_messenger_init(loop, &start_messenger, start_request);
+ uv_messenger_init(loop, &stop_messenger, stop_request);
uv_thread_create(&thread, thread_init, nullptr);
}