Skip to content

Commit

Permalink
Save syscalls when constructing listener sockets for evhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Feb 10, 2012
1 parent a35f396 commit af6c9d8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -3984,17 +3984,13 @@ bind_socket_ai(struct evutil_addrinfo *ai, int reuse)
int serrno;

/* Create listen socket */
fd = socket(ai ? ai->ai_family : AF_INET, SOCK_STREAM, 0);
fd = evutil_socket(ai ? ai->ai_family : AF_INET,
SOCK_STREAM|EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC, 0);
if (fd == -1) {
event_sock_warn(-1, "socket");
return (-1);
}

if (evutil_make_socket_nonblocking(fd) < 0)
goto out;
if (evutil_make_socket_closeonexec(fd) < 0)
goto out;

setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
if (reuse)
evutil_make_listen_socket_reuseable(fd);
Expand Down

0 comments on commit af6c9d8

Please sign in to comment.