Skip to content

Commit

Permalink
nghttpx: Use accept if accept4 is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Jan 5, 2015
1 parent fcf0cee commit 7dba426
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/shrpx_accept_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 7dba426

Please sign in to comment.