From af6c9d8ee6e27daf558211aba83e20e33f15bd58 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 10 Feb 2012 16:32:32 -0500 Subject: [PATCH] Save syscalls when constructing listener sockets for evhttp --- http.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index 9f1bc89930..0ed315ba0a 100644 --- a/http.c +++ b/http.c @@ -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);