diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | common/curl_request.cpp | 14 | ||||
-rw-r--r-- | common/headless_view.cpp | 2 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/platform/request.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/util/uv_detail.hpp | 13 | ||||
-rwxr-xr-x | setup-libraries.sh | 20 | ||||
-rw-r--r-- | src/map/map.cpp | 8 | ||||
-rw-r--r-- | src/platform/request.cpp | 4 | ||||
-rw-r--r-- | src/util/uv.cpp | 2 | ||||
-rw-r--r-- | test/fixtures/fixture_request.cpp | 34 |
11 files changed, 64 insertions, 44 deletions
diff --git a/.travis.yml b/.travis.yml index b641c11589..d2d77a43bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ env: - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" + - AWS_S3_BUCKET=mapbox-gl-testing before_install: - source ./scripts/flags.sh diff --git a/common/curl_request.cpp b/common/curl_request.cpp index 416ed90cd1..3370c0a859 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -216,7 +216,7 @@ int handle_socket(CURL * /*easy*/, curl_socket_t s, int action, void * /*userp*/ return 0; } -void on_timeout(uv_timer_t * /*req*/) { +void on_timeout(uv_timer_t *, int status /*req*/) { int running_handles; CURLMcode error = curl_multi_socket_action(curl_multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); @@ -227,9 +227,9 @@ void on_timeout(uv_timer_t * /*req*/) { void start_timeout(CURLM * /*multi*/, long timeout_ms, void * /*userp*/) { if (timeout_ms <= 0) { - on_timeout(&timeout); + on_timeout(&timeout, -1); } else { - uv_timer_start(&timeout, on_timeout, timeout_ms, 0); + uv_timer_start(&timeout, &on_timeout, timeout_ms, 0); } } @@ -289,7 +289,7 @@ size_t curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp) { // This callback is called in the request event loop (on the request thread). // It initializes newly queued up download requests and adds them to the CURL // multi handle. -void async_add_cb(uv_async_t * /*async*/) { +void async_add_cb(uv_async_t *, int status /*async*/) { std::shared_ptr<Request> *req = nullptr; while (add_queue.pop(req)) { // Make sure that we're not starting requests that have been cancelled @@ -321,7 +321,7 @@ void async_add_cb(uv_async_t * /*async*/) { } } -void async_cancel_cb(uv_async_t * /*async*/) { +void async_cancel_cb(uv_async_t *, int status /*async*/) { std::shared_ptr<Request> *req = nullptr; while (cancel_queue.pop(req)) { // It is possible that the request has not yet been started, but that it already has been @@ -343,8 +343,8 @@ void thread_init_cb() { curl_global_init(CURL_GLOBAL_ALL); loop = uv_loop_new(); - uv_async_init(loop, &async_add, async_add_cb); - uv_async_init(loop, &async_cancel, async_cancel_cb); + uv_async_init(loop, &async_add, &async_add_cb); + uv_async_init(loop, &async_cancel, &async_cancel_cb); uv_thread_create(&thread, thread_init, nullptr); } } // end namespace request diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 34326ae29c..0b4d7ce64a 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -113,6 +113,8 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { + make_active(); + #if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 0d2926d04b..ac33dba0ef 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -132,10 +132,10 @@ public: private: // uv async callbacks - static void render(uv_async_t *async); - static void terminate(uv_async_t *async); - static void cleanup(uv_async_t *async); - static void delete_async(uv_handle_t *handle); + static void render(uv_async_t *async, int status); + static void terminate(uv_async_t *async, int status); + static void cleanup(uv_async_t *async, int status); + static void delete_async(uv_handle_t *handle, int status); // Setup void setup(); diff --git a/include/mbgl/platform/request.hpp b/include/mbgl/platform/request.hpp index 0cbacf645d..2a231769c1 100644 --- a/include/mbgl/platform/request.hpp +++ b/include/mbgl/platform/request.hpp @@ -24,7 +24,7 @@ public: void complete(); private: - static void complete(uv_async_t *async); + static void complete(uv_async_t *async, int status); public: const std::string url; diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index c65c247ba1..b3fdbb3719 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -31,18 +31,13 @@ private: class loop { public: - inline loop() { - if (uv_loop_init(&l) != 0) { - throw std::runtime_error("failed to initialize loop"); - } - } - - inline ~loop() { uv_loop_close(&l); } + inline loop() : l(uv_loop_new()) {} + inline ~loop() { uv_loop_delete(l); } - inline uv_loop_t *operator*() { return &l; } + inline uv_loop_t *operator*() { return l; } private: - uv_loop_t l; + uv_loop_t *l; }; class mutex { diff --git a/setup-libraries.sh b/setup-libraries.sh index dc0ced33e9..e955304985 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="e741a075d28812e5d16b581e1540248fe19c52ce" +MP_HASH="d58d6f18b99e5283b43940882da9ea18deea1227" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git @@ -67,7 +67,7 @@ export CXX11=true if [ ${UNAME} = 'Darwin' ]; then if [ ! -z "${TRAVIS:-}" ]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then + if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then rm -rf out/build-cpp11-libcpp-universal tar -xzf out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz fi @@ -76,21 +76,25 @@ fi if test -z "${TRAVIS:-}" || ! test -d out/build-cpp11-libcpp-universal; then source iPhoneOS.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneOSs.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneOS64.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneSimulator.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' @@ -103,6 +107,7 @@ source iPhoneSimulator.sh # echo ' ...done' source MacOSX.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi @@ -115,7 +120,7 @@ source MacOSX.sh if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then tar -zcf out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal - aws s3 cp --acl public-read out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/ + aws s3 cp --acl public-read out/build-cpp11-libcpp-universal_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi fi @@ -130,13 +135,14 @@ cd ../../ elif [ ${UNAME} = 'Linux' ]; then if [ ! -z "${TRAVIS:-}" ]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then + if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then rm -rf out/build-cpp11-libstdcpp-gcc-x86_64-linux - tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz + tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz fi fi source Linux.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi @@ -146,8 +152,8 @@ source Linux.sh if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then - tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux - aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://mapbox-gl-testing/dependencies/ + tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux + aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi fi diff --git a/src/map/map.cpp b/src/map/map.cpp index e6c4e9d03d..6da514d163 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -99,7 +99,7 @@ void Map::stop() { async = false; } -void Map::delete_async(uv_handle_t *handle) { +void Map::delete_async(uv_handle_t *handle, int status) { delete (uv_async_t *)handle; } @@ -146,7 +146,7 @@ void Map::cleanup() { } } -void Map::cleanup(uv_async_t *async) { +void Map::cleanup(uv_async_t *async, int status) { Map *map = static_cast<Map *>(async->data); map->view.make_active(); @@ -158,7 +158,7 @@ void Map::terminate() { painter.terminate(); } -void Map::render(uv_async_t *async) { +void Map::render(uv_async_t *async, int status) { Map *map = static_cast<Map *>(async->data); @@ -178,7 +178,7 @@ void Map::render(uv_async_t *async) { } } -void Map::terminate(uv_async_t *async) { +void Map::terminate(uv_async_t *async, int status) { // Closes all open handles on the loop. This means that the loop will automatically terminate. uv_loop_t *loop = static_cast<uv_loop_t *>(async->data); uv_walk(loop, [](uv_handle_t *handle, void */*arg*/) { diff --git a/src/platform/request.cpp b/src/platform/request.cpp index efd17895db..82e80b9a7c 100644 --- a/src/platform/request.cpp +++ b/src/platform/request.cpp @@ -20,7 +20,7 @@ Request::Request(const std::string &url, // create an actual work request that is attached to the default loop. async = new uv_async_t(); async->data = new std::unique_ptr<Response>(); - uv_async_init(**loop, async, complete); + uv_async_init(**loop, async, &complete); } } @@ -41,7 +41,7 @@ void Request::complete() { } } -void Request::complete(uv_async_t *async) { +void Request::complete(uv_async_t *async, int status) { Response *res = static_cast<std::unique_ptr<Response> *>(async->data)->get(); res->callback(res); diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 65c790b9c0..94f074bfa1 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast<char *>(dir.data()), &max); + uv_cwd(const_cast<char *>(dir.data()), max); } while (max == dir.size()); dir.resize(max - 1); return dir; diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 7e351ecfac..417958a33d 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -3,6 +3,7 @@ #include <mbgl/util/uv_detail.hpp> #include <mbgl/util/url.hpp> #include <mbgl/platform/log.hpp> +#include <iostream> const std::string base_directory = []{ std::string fn = __FILE__; @@ -35,13 +36,27 @@ platform::request_http(const std::string &url, int err; + std::string body; + FILE *file = std::fopen(clean_url.c_str(),"rb"); + + if (file != NULL) + { + std::fseek(file, 0, SEEK_END); + std::size_t file_size = std::ftell(file); + std::fseek(file, 0, SEEK_SET); + body.resize(file_size); + std::fread(&body[0], file_size, 1, file); + std::fclose(file); + } + + /* uv_fs_t open_req; err = uv_fs_open(l, &open_req, clean_url.c_str(), O_RDONLY, S_IRUSR, nullptr); uv_fs_req_cleanup(&open_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } @@ -53,13 +68,13 @@ platform::request_http(const std::string &url, err = uv_fs_fstat(l, &stat_req, fd, nullptr); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } - const uint64_t size = static_cast<const uv_stat_t*>(stat_req.ptr)->st_size; + const uint64_t size = static_cast<const uv_statbuf_t*>(stat_req.ptr)->st_size; std::string body; @@ -71,8 +86,8 @@ platform::request_http(const std::string &url, uv_fs_req_cleanup(&read_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } @@ -83,11 +98,12 @@ platform::request_http(const std::string &url, uv_fs_req_cleanup(&close_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } + */ req->res->body.swap(body); req->res->code = 200; |