summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--common/curl_request.cpp14
-rw-r--r--common/headless_view.cpp11
-rw-r--r--include/mbgl/map/map.hpp8
-rw-r--r--include/mbgl/platform/request.hpp2
-rw-r--r--include/mbgl/util/uv_detail.hpp13
-rwxr-xr-xsetup-libraries.sh24
-rw-r--r--src/map/map.cpp8
-rw-r--r--src/platform/request.cpp4
-rw-r--r--src/util/uv.cpp2
-rw-r--r--test/fixtures/fixture_request.cpp34
11 files changed, 75 insertions, 46 deletions
diff --git a/.travis.yml b/.travis.yml
index 42cca837c6..a2bf164c62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,6 +22,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 ed00f48e82..94a6cd03bc 100644
--- a/common/headless_view.cpp
+++ b/common/headless_view.cpp
@@ -2,6 +2,7 @@
#include <mbgl/util/timer.hpp>
#include <stdexcept>
+#include <iostream>
namespace mbgl {
@@ -117,6 +118,8 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) {
void HeadlessView::clear_buffers() {
#if MBGL_USE_CGL
+ make_active();
+
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
if (fbo) {
@@ -156,6 +159,10 @@ HeadlessView::~HeadlessView() {
#endif
#if MBGL_USE_GLX
+ std::cerr << "~HeadlessView()" << '\n';
+ std::cerr << "x_display: " << x_display << '\n';
+ std::cerr << "glx_pixmap: " << glx_pixmap << '\n';
+ std::cerr << "gl_context: " << gl_context << '\n';
glXMakeCurrent(x_display, None, NULL);
glXDestroyContext(x_display, gl_context);
XFree(x_info);
@@ -176,6 +183,10 @@ void HeadlessView::make_active() {
#endif
#if MBGL_USE_GLX
+ std::cerr << "make_active()" << '\n';
+ std::cerr << "x_display: " << x_display << '\n';
+ std::cerr << "glx_pixmap: " << glx_pixmap << '\n';
+ std::cerr << "gl_context: " << gl_context << '\n';
if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) {
fprintf(stderr, "Switching OpenGL context failed\n");
}
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index fba38879ed..4c5952a2c1 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -129,10 +129,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 42c9ab1088..7947efe494 100755
--- a/setup-libraries.sh
+++ b/setup-libraries.sh
@@ -51,7 +51,7 @@ set -u
NODE=$(which node)
NPM=$(which npm)
-MP_HASH="eb8c6d7e6bd6adb42c232ed806b889f3e6825bb5"
+MP_HASH="c0fc970e52950a6f16e3172f1114e5a4ae1e0aa9"
DIR_HASH=$(echo `pwd` | git hash-object --stdin)
if [ ! -d 'mapnik-packaging/' ]; then
git clone https://github.com/mapnik/mapnik-packaging.git
@@ -67,8 +67,8 @@ export CXX11=true
if [ ${UNAME} = 'Darwin' ]; then
if [ ! -z "${TRAVIS:-}" ]; then
- if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
- if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
+ if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
+ if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
rm -rf out/build-cpp11-libcpp-x86_64-macosx
rm -rf out/build-cpp11-libcpp-universal
tar -xzf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz
@@ -80,21 +80,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'
@@ -105,6 +109,7 @@ source iPhoneSimulator64.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
@@ -118,9 +123,9 @@ source MacOSX.sh
if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then
tar -zcf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal
- aws s3 cp --acl public-read out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/
+ aws s3 cp --acl public-read out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/
tar -zcf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-x86_64-macosx
- aws s3 cp --acl public-read out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/
+ aws s3 cp --acl public-read out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/
fi
fi
@@ -133,13 +138,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
@@ -149,8 +155,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 9984f1b181..1399b97ee2 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;
}
@@ -144,14 +144,14 @@ 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();
map->painter.cleanup();
}
-void Map::render(uv_async_t *async) {
+void Map::render(uv_async_t *async, int status) {
Map *map = static_cast<Map *>(async->data);
@@ -171,7 +171,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;