X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=acceptor.cpp;h=32a89fa7670d7221b54e7c98ffa0f8ce7e255abd;hp=2abfa5220064ec47efb8d40c41d3ad9ceed6a79d;hb=981cdb79fdbf75ff755c80297d6d0e893d076555;hpb=3fd8650ccf3da3960a946d8ac9abc305aec399ce diff --git a/acceptor.cpp b/acceptor.cpp index 2abfa52..32a89fa 100644 --- a/acceptor.cpp +++ b/acceptor.cpp @@ -1,11 +1,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include "acceptor.h" @@ -120,10 +122,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); }