diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-10-10 13:25:26 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-10-10 13:25:26 -0400 |
commit | ee68c091a858d70b8c66277cb4d3d9cbec1a9b14 (patch) | |
tree | 13e5c933f4944f1bd02d4384712deff0e3f6768e /src | |
parent | c458f246fa965407dd4cde44444f6017eac20171 (diff) | |
download | qtlocation-mapboxgl-ee68c091a858d70b8c66277cb4d3d9cbec1a9b14.tar.gz |
adjust file_request_baton and http_request for libuv 0.10 api
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/file_request_baton.cpp | 11 | ||||
-rw-r--r-- | src/storage/http_request.cpp | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index 127c78f3e5..af44976898 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -29,7 +29,7 @@ void FileRequestBaton::notify_error(uv_fs_t *req) { if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) { ptr->request->response = std::unique_ptr<Response>(new Response); ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500; - ptr->request->response->message = uv_strerror(int(req->result)); + ptr->request->response->message = uv_strerror(uv_last_error(req->loop)); ptr->request->notify(); } } @@ -71,13 +71,14 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_req_cleanup(req); uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { - if (static_cast<const uv_stat_t *>(req->ptr)->st_size > std::numeric_limits<int>::max()) { + if (static_cast<const uv_statbuf_t *>(req->ptr)->st_size > std::numeric_limits<int>::max()) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. + const uv_err_t error = {UV_EFBIG, 0}; if (ptr->request) { ptr->request->response = std::unique_ptr<Response>(new Response); - ptr->request->response->code = UV_EFBIG; - ptr->request->response->message = uv_strerror(UV_EFBIG); + ptr->request->response->code = error.code; + ptr->request->response->message = uv_strerror(error); ptr->request->notify(); } @@ -85,7 +86,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { const unsigned int size = - (unsigned int)(static_cast<const uv_stat_t *>(req->ptr)->st_size); + (unsigned int)(static_cast<const uv_statbuf_t *>(req->ptr)->st_size); ptr->body.resize(size); ptr->buffer = uv_buf_init(const_cast<char *>(ptr->body.data()), size); uv_fs_req_cleanup(req); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 1b799d4895..4dcb12604a 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -77,7 +77,7 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) { http_baton->response = std::move(res); http_baton->async->data = new util::ptr<HTTPRequestBaton>(http_baton); - uv_async_init(loop, http_baton->async, [](uv_async_t *async) { + uv_async_init(loop, http_baton->async, [](uv_async_t *async, int status) { util::ptr<HTTPRequestBaton> &http_baton = *(util::ptr<HTTPRequestBaton> *)async->data; if (http_baton->request) { @@ -193,7 +193,7 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr<Response> &&res, uint64_t tim backoff_timer = new uv_timer_t(); uv_timer_init(loop, backoff_timer); backoff_timer->data = new RetryBaton(this, std::move(res)); - uv_timer_start(backoff_timer, [](uv_timer_t *timer) { + uv_timer_start(backoff_timer, [](uv_timer_t *timer, int status) { std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(timer->data) }; pair->first->startHTTPRequest(std::move(pair->second)); pair->first->backoff_timer = nullptr; |