summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2013-12-23 23:28:44 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2016-09-24 02:23:49 -0400
commit93afda9c8e6016dc132e6cac35a322be62b3cb03 (patch)
tree28395999b3add84dd280ef6cd920fd0e231086f8 /src/network.c
parent8047c2f448c6aa48bf9d6b578e8b1806fc37ccaf (diff)
downloadlighttpd1.4-93afda9c8e6016dc132e6cac35a322be62b3cb03.tar.gz
lighttpd1.4-93afda9c8e6016dc132e6cac35a322be62b3cb03.zip
performance: use Linux extended syscalls and flags
reduce syscalls on Linux using extended syscalls and flags, e.g. accept4(), pipe2(), O_CLOEXEC, SOCK_CLOEXEC, SOCK_NONBLOCK github: closes #2
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/network.c b/src/network.c
index 574a0072..3bfaebd2 100644
--- a/src/network.c
+++ b/src/network.c
@@ -382,7 +382,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
if (AF_UNIX == srv_socket->addr.plain.sa_family) {
/* check if the socket exists and try to connect to it. */
force_assert(host); /*(static analysis hint)*/
- if (-1 == (srv_socket->fd = socket(srv_socket->addr.plain.sa_family, SOCK_STREAM, 0))) {
+ if (-1 == (srv_socket->fd = fdevent_socket_cloexec(srv_socket->addr.plain.sa_family, SOCK_STREAM, 0))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed:", strerror(errno));
goto error_free_socket;
}
@@ -409,10 +409,12 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
goto error_free_socket;
}
+
+ fdevent_fcntl_set_nb(srv->ev, srv_socket->fd);
} else
#endif
{
- if (-1 == (srv_socket->fd = socket(srv_socket->addr.plain.sa_family, SOCK_STREAM, IPPROTO_TCP))) {
+ if (-1 == (srv_socket->fd = fdevent_socket_nb_cloexec(srv_socket->addr.plain.sa_family, SOCK_STREAM, IPPROTO_TCP))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "socket failed:", strerror(errno));
goto error_free_socket;
}
@@ -433,9 +435,6 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
#endif
}
- /* set FD_CLOEXEC now, fdevent_fcntl_set is called later; needed for pipe-logger forks */
- fd_close_on_exec(srv_socket->fd);
-
/* */
srv->cur_fds = srv_socket->fd;