diff --git a/android-config b/android-config index 15b95040..26d79caf 100755 --- a/android-config +++ b/android-config @@ -41,5 +41,6 @@ PATH=$TOOLCHAIN/bin:$PATH --disable-examples \ --disable-threads \ CPPFLAGS="-I$PREFIX/include" \ + CXXFLAGS="-fno-strict-aliasing" \ PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \ LDFLAGS="-L$PREFIX/lib" diff --git a/configure.ac b/configure.ac index 13c57fc4..ebc94129 100644 --- a/configure.ac +++ b/configure.ac @@ -278,7 +278,8 @@ AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ]) # libev (for src) # libev does not have pkg-config file. Check it in an old way. LIBS_OLD=$LIBS -AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no]) +# android requires -lm for floor +AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no], [-lm]) if test "x${have_libev}" = "xyes"; then AC_CHECK_HEADER([ev.h], [have_libev=yes], [have_libev=no]) if test "x${have_libev}" = "xyes"; then diff --git a/src/shrpx.cc b/src/shrpx.cc index 25c164f5..81b74fcc 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -188,11 +188,19 @@ std::unique_ptr create_acceptor(ConnectionHandler *handler, return nullptr; } for (rp = res; rp; rp = rp->ai_next) { +#ifdef SOCK_NONBLOCK fd = socket(rp->ai_family, rp->ai_socktype | SOCK_NONBLOCK, rp->ai_protocol); if (fd == -1) { continue; } +#else // !SOCK_NONBLOCK + fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + if (fd == -1) { + continue; + } + util::make_socket_nonblocking(fd); +#endif // !SOCK_NONBLOCK int val = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, static_cast(sizeof(val))) == -1) { diff --git a/src/shrpx.h b/src/shrpx.h index eea1337b..85c4d343 100644 --- a/src/shrpx.h +++ b/src/shrpx.h @@ -36,14 +36,6 @@ #include "shrpx_log.h" -#ifndef SOCK_NONBLOCK -#define SOCK_NONBLOCK 0 -#endif // !SOCK_NONBLOCK - -#ifndef SOCK_CLOEXEC -#define SOCK_CLOEXEC 0 -#endif // !SOCK_CLOEXEC - #ifndef HAVE__EXIT #define _Exit(status) _exit(status) #endif // !HAVE__EXIT diff --git a/src/shrpx_accept_handler.cc b/src/shrpx_accept_handler.cc index 43208736..364cc9f8 100644 --- a/src/shrpx_accept_handler.cc +++ b/src/shrpx_accept_handler.cc @@ -26,6 +26,8 @@ #include +#include + #include "shrpx_connection_handler.h" #include "shrpx_config.h" #include "util.h" diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index f047dfa6..b9c8a9a2 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -61,11 +61,13 @@ Worker::Worker(SSL_CTX *sv_ssl_ctx, SSL_CTX *cl_ssl_ctx, http1_connect_blocker_ = util::make_unique(loop_); } +#ifndef NOTHREADS fut_ = std::async(std::launch::async, [this, &ticket_keys] { worker_config->ticket_keys = ticket_keys; (void)reopen_log_files(); ev_run(loop_); }); +#endif // !NOTHREADS } Worker::~Worker() { ev_async_stop(loop_, &w_); } diff --git a/src/util.cc b/src/util.cc index 4016d955..555bed62 100644 --- a/src/util.cc +++ b/src/util.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -860,11 +861,22 @@ int make_socket_nodelay(int fd) { } int create_nonblock_socket(int family) { +#ifdef SOCK_NONBLOCK auto fd = socket(family, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); if (fd == -1) { return -1; } +#else // !SOCK_NONBLOCK + auto fd = socket(family, SOCK_STREAM, 0); + + if (fd == -1) { + return -1; + } + + make_socket_nonblocking(fd); + make_socket_closeonexec(fd); +#endif // !SOCK_NONBLOCK make_socket_nodelay(fd);