From 7dba426db4f5cc1bf0f2cf1592ec3468c06c0cd0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 5 Jan 2015 16:04:28 +0900 Subject: [PATCH] nghttpx: Use accept if accept4 is not available --- src/shrpx_accept_handler.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/shrpx_accept_handler.cc b/src/shrpx_accept_handler.cc index 43239888..1eab4d70 100644 --- a/src/shrpx_accept_handler.cc +++ b/src/shrpx_accept_handler.cc @@ -57,8 +57,12 @@ void AcceptHandler::accept_connection() { sockaddr_union sockaddr; socklen_t addrlen = sizeof(sockaddr); +#ifdef HAVE_ACCEPT4 auto cfd = accept4(fd_, &sockaddr.sa, &addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC); +#else // !HAVE_ACCEPT4 + auto cfd = accept(fd_, &sockaddr.sa, &addrlen); +#endif // !HAVE_ACCEPT4 if (cfd == -1) { switch (errno) { @@ -79,6 +83,11 @@ void AcceptHandler::accept_connection() { return; } +#ifndef HAVE_ACCEPT4 + util::make_socket_nonblocking(cfd); + util::make_socket_closeonexec(cfd); +#endif // !HAVE_ACCEPT4 + util::make_socket_nodelay(cfd); conn_hnr_->handle_connection(cfd, &sockaddr.sa, addrlen);