projects
/
cubemap
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
845934c
)
Enable TCP_CORK if available.
author
Steinar H. Gunderson
<sgunderson@bigfoot.com>
Mon, 22 Apr 2013 21:24:59 +0000
(23:24 +0200)
committer
Steinar H. Gunderson
<sgunderson@bigfoot.com>
Mon, 22 Apr 2013 21:24:59 +0000
(23:24 +0200)
acceptor.cpp
patch
|
blob
|
history
diff --git
a/acceptor.cpp
b/acceptor.cpp
index
2abfa52
..
32a89fa
100644
(file)
--- a/
acceptor.cpp
+++ b/
acceptor.cpp
@@
-1,11
+1,13
@@
#include <assert.h>
#include <errno.h>
#include <netinet/in.h>
#include <assert.h>
#include <errno.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <unistd.h>
#include "acceptor.h"
#include <unistd.h>
#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) {
// Set the socket as nonblocking.
int one = 1;
if (ioctl(sock, FIONBIO, &one) == -1) {
- log_perror("
FIONBIO
");
+ log_perror("
ioctl(FIONBIO)
");
exit(1);
}
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);
}
// Pick a server, round-robin, and hand over the socket to it.
servers->add_client(sock);
}