X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=acceptor.cpp;h=d4d4efb29d668a252b3427ab347e7fa2197f2566;hp=2abfa5220064ec47efb8d40c41d3ad9ceed6a79d;hb=bfc1a54cf84bb1784c14bd4f5acbb500460e35b5;hpb=0cb56be70f7ca4f4564eea892a99d20032359a1d diff --git a/acceptor.cpp b/acceptor.cpp index 2abfa52..d4d4efb 100644 --- a/acceptor.cpp +++ b/acceptor.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -120,10 +121,18 @@ void Acceptor::do_work() // Set the socket as nonblocking. int one = 1; if (ioctl(sock, FIONBIO, &one) == -1) { - log_perror("FIONBIO"); + 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. + if (setsockopt(sock, SOL_TCP, TCP_CORK, &one, sizeof(one)) == -1) { + log_perror("setsockopt(TCP_CORK)"); + // Can still continue. + } + // Pick a server, round-robin, and hand over the socket to it. servers->add_client(sock); }