From: Steinar H. Gunderson Date: Fri, 10 Jul 2015 21:46:37 +0000 (+0200) Subject: Merge branch 'master' of /srv/git.sesse.net/www/cubemap X-Git-Tag: 1.2.0~23 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=0e96bbf9ee0fbebd5fe3fba4d186c0e0d73c9a32;hp=6889a665614e926437484a556124a5ff60363568 Merge branch 'master' of /srv/git.sesse.net/www/cubemap --- diff --git a/acceptor.cpp b/acceptor.cpp index 593e4d4..7c28ca5 100644 --- a/acceptor.cpp +++ b/acceptor.cpp @@ -130,8 +130,8 @@ void Acceptor::do_work() sockaddr_in6 addr; socklen_t addrlen = sizeof(addr); - // Get a new socket. - int sock = accept(server_sock, reinterpret_cast(&addr), &addrlen); + // Get a new socket, and set it as nonblocking. + int sock = accept4(server_sock, reinterpret_cast(&addr), &addrlen, SOCK_NONBLOCK); if (sock == -1 && errno == EINTR) { continue; } @@ -141,16 +141,10 @@ void Acceptor::do_work() continue; } - // Set the socket as nonblocking. - int one = 1; - if (ioctl(sock, FIONBIO, &one) == -1) { - log_perror("ioctl(FIONBIO)"); - exit(1); - } - // Enable TCP_CORK for maximum throughput. In the rare case that the // stream stops entirely, this will cause a small delay (~200 ms) // before the last part is sent out, but that should be fine. + int one = 1; if (setsockopt(sock, SOL_TCP, TCP_CORK, &one, sizeof(one)) == -1) { log_perror("setsockopt(TCP_CORK)"); // Can still continue.