commit
49ce44e1f5
27
.travis.yml
27
.travis.yml
|
@ -1,12 +1,20 @@
|
||||||
dist: xenial
|
dist: xenial
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
compiler:
|
||||||
|
- clang
|
||||||
|
- gcc
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- CI_BUILD=cmake
|
- CI_BUILD=cmake
|
||||||
- CI_BUILD=autotools
|
- CI_BUILD=autotools
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: osx
|
||||||
|
compiler: clang
|
||||||
|
osx_image: xcode10.2
|
||||||
|
env: CI_BUILD=autotools
|
||||||
language: cpp
|
language: cpp
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
- gcc
|
|
||||||
sudo: required
|
sudo: required
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
@ -30,6 +38,13 @@ addons:
|
||||||
- libc-ares-dev
|
- libc-ares-dev
|
||||||
- cmake
|
- cmake
|
||||||
- cmake-data
|
- cmake-data
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- libev
|
||||||
|
- libevent
|
||||||
|
- c-ares
|
||||||
|
- cunit
|
||||||
|
- libressl
|
||||||
before_install:
|
before_install:
|
||||||
- $CC --version
|
- $CC --version
|
||||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-8" CC="gcc-8"; fi
|
- if [ "$CXX" = "g++" ]; then export CXX="g++-8" CC="gcc-8"; fi
|
||||||
|
@ -37,13 +52,15 @@ before_install:
|
||||||
- go version
|
- go version
|
||||||
- cmake --version
|
- cmake --version
|
||||||
before_script:
|
before_script:
|
||||||
|
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then CPPFLAGS=-fsanitize=address LDFLAGS="-fsanitize=address -fuse-ld=gold"; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then PKG_CONFIG_PATH=/usr/local/opt/libressl/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig; fi
|
||||||
# Now build nghttp2
|
# Now build nghttp2
|
||||||
- if [ "$CI_BUILD" = "autotools" ]; then autoreconf -i; fi
|
- if [ "$CI_BUILD" = "autotools" ]; then autoreconf -i; fi
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
- if [ "$CI_BUILD" = "autotools" ]; then ./configure --with-mruby; fi
|
- if [ "$CI_BUILD" = "autotools" ]; then ./configure --with-mruby PKG_CONFIG_PATH=$PKG_CONFIG_PATH; fi
|
||||||
- if [ "$CI_BUILD" = "cmake" ]; then cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1; fi
|
- if [ "$CI_BUILD" = "cmake" ]; then cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1; fi
|
||||||
script:
|
script:
|
||||||
- if [ "$CI_BUILD" = "autotools" ]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --enable-werror CPPFLAGS=-fsanitize=address LDFLAGS=\"-fsanitize=address -fuse-ld=gold\""; fi
|
- if [ "$CI_BUILD" = "autotools" ]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --enable-werror CPPFLAGS=$CPPFLAGS LDFLAGS=\"$LDFLAGS\" PKG_CONFIG_PATH=$PKG_CONFIG_PATH"; fi
|
||||||
- if [ "$CI_BUILD" = "cmake" ]; then make check; fi
|
- if [ "$CI_BUILD" = "cmake" ]; then make check; fi
|
||||||
# As of April, 23, 2016, golang http2 build fails, probably because
|
# As of April, 23, 2016, golang http2 build fails, probably because
|
||||||
# the default go version is too old.
|
# the default go version is too old.
|
||||||
|
|
|
@ -899,7 +899,7 @@ AC_MSG_NOTICE([summary of build options:
|
||||||
Failmalloc: ${enable_failmalloc}
|
Failmalloc: ${enable_failmalloc}
|
||||||
Libs:
|
Libs:
|
||||||
OpenSSL: ${have_openssl} (CFLAGS='${OPENSSL_CFLAGS}' LIBS='${OPENSSL_LIBS}')
|
OpenSSL: ${have_openssl} (CFLAGS='${OPENSSL_CFLAGS}' LIBS='${OPENSSL_LIBS}')
|
||||||
Libxml2: ${have_libxml2} (CFLAGS='${LIBXML2_CPPFLAGS}' LIBS='${LIBXML2_LIBS}')
|
Libxml2: ${have_libxml2} (CFLAGS='${LIBXML2_CFLAGS}' LIBS='${LIBXML2_LIBS}')
|
||||||
Libev: ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
|
Libev: ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
|
||||||
Libc-ares ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
|
Libc-ares ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
|
||||||
Libevent(SSL): ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
|
Libevent(SSL): ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
|
||||||
|
|
|
@ -435,7 +435,7 @@ int main(int argc, char **argv) {
|
||||||
#ifdef __sgi
|
#ifdef __sgi
|
||||||
if (daemon(0, 0, 0, 0) == -1) {
|
if (daemon(0, 0, 0, 0) == -1) {
|
||||||
#else
|
#else
|
||||||
if (daemon(0, 0) == -1) {
|
if (util::daemonize(0, 0) == -1) {
|
||||||
#endif
|
#endif
|
||||||
perror("daemon");
|
perror("daemon");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ int call_daemon() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
# endif // HAVE_LIBSYSTEMD
|
# endif // HAVE_LIBSYSTEMD
|
||||||
return daemon(0, 0);
|
return util::daemonize(0, 0);
|
||||||
#endif // !__sgi
|
#endif // !__sgi
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
40
src/util.cc
40
src/util.cc
|
@ -1542,6 +1542,46 @@ std::mt19937 make_mt19937() {
|
||||||
return std::mt19937(rd());
|
return std::mt19937(rd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int daemonize(int nochdir, int noclose) {
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
pid_t pid;
|
||||||
|
pid = fork();
|
||||||
|
if (pid == -1) {
|
||||||
|
return -1;
|
||||||
|
} else if (pid > 0) {
|
||||||
|
_exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
if (setsid() == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pid = fork();
|
||||||
|
if (pid == -1) {
|
||||||
|
return -1;
|
||||||
|
} else if (pid > 0) {
|
||||||
|
_exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
if (nochdir == 0) {
|
||||||
|
if (chdir("/") == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noclose == 0) {
|
||||||
|
if (freopen("/dev/null", "r", stdin) == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (freopen("/dev/null", "w", stdout) == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (freopen("/dev/null", "w", stderr) == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else // !defined(__APPLE__)
|
||||||
|
return daemon(nochdir, noclose);
|
||||||
|
#endif // !defined(__APPLE__)
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
|
@ -772,6 +772,10 @@ StringRef extract_host(const StringRef &hostport);
|
||||||
// Returns new std::mt19937 object.
|
// Returns new std::mt19937 object.
|
||||||
std::mt19937 make_mt19937();
|
std::mt19937 make_mt19937();
|
||||||
|
|
||||||
|
// daemonize calls daemon(3). If __APPLE__ is defined, it implements
|
||||||
|
// daemon() using fork().
|
||||||
|
int daemonize(int nochdir, int noclose);
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
Loading…
Reference in New Issue