Call less syscalls after each accept()

This commit is contained in:
Ian Gulliver
2016-02-29 15:22:10 -08:00
parent e44edeba53
commit 3539f9d640
2 changed files with 4 additions and 2 deletions

View File

@@ -79,8 +79,6 @@ static void incoming_handler(struct peer *peer) {
local_hbuf, local_sbuf, local_hbuf, local_sbuf,
peer_hbuf, peer_sbuf); peer_hbuf, peer_sbuf);
socket_connected_init(fd);
if (!incoming_hello(fd, incoming)) { if (!incoming_hello(fd, incoming)) {
fprintf(stderr, "I %s: Error writing greeting\n", incoming->id); fprintf(stderr, "I %s: Error writing greeting\n", incoming->id);
assert(!close(fd)); assert(!close(fd));

View File

@@ -17,6 +17,10 @@ void socket_bound_init(int fd) {
// Called by transport code; safe to assume that fd is a socket // Called by transport code; safe to assume that fd is a socket
int qlen = 5; int qlen = 5;
assert(!setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen))); assert(!setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)));
// These options are inherited through accept()
// Verified by flamingcow on kernel 4.2.0
socket_connected_init(fd);
} }
void socket_connected_init(int fd) { void socket_connected_init(int fd) {