From ee68c091a858d70b8c66277cb4d3d9cbec1a9b14 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 13:25:26 -0400 Subject: [PATCH] adjust file_request_baton and http_request for libuv 0.10 api --- src/storage/file_request_baton.cpp | 11 ++++++----- 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 127c78f3e..af4497689 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(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(req->ptr)->st_size > std::numeric_limits::max()) { + if (static_cast(req->ptr)->st_size > std::numeric_limits::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(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(req->ptr)->st_size); + (unsigned int)(static_cast(req->ptr)->st_size); ptr->body.resize(size); ptr->buffer = uv_buf_init(const_cast(ptr->body.data()), size); uv_fs_req_cleanup(req); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 1b799d489..4dcb12604 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -77,7 +77,7 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr &&res) { http_baton->response = std::move(res); http_baton->async->data = new util::ptr(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 &http_baton = *(util::ptr *)async->data; if (http_baton->request) { @@ -193,7 +193,7 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr &&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 pair { static_cast(timer->data) }; pair->first->startHTTPRequest(std::move(pair->second)); pair->first->backoff_timer = nullptr;