Skip to content

Commit d04d062

Browse files
committed
nodelay for less latency
1 parent 4157140 commit d04d062

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/core/connection.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ static void* connection_handle_accept(void *arg)
414414
} while(nfds == 0 && !stop_soon);
415415
assert(nfds >= 0);
416416
int n = 0;
417-
int state = 1;
418417
while (n < nfds) {
419418
int fd = events[n].data.fd;
420419
if (events[n].events & (EPOLLERR | EPOLLHUP))
@@ -426,10 +425,6 @@ static void* connection_handle_accept(void *arg)
426425
DEBUG("[#] Accepting connection from fd %d of type %s\n", fd, listener_type_string(our_type));
427426
int client_sock = accept(fd, NULL, NULL);
428427

429-
if(-1 == setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&enable, sizeof(enable))){
430-
DEBUG("[#] Unable to set tcp nodelay\n");
431-
}
432-
433428
if (client_sock < 0) {
434429
if (errno != EAGAIN && errno != EWOULDBLOCK)
435430
{
@@ -441,12 +436,15 @@ static void* connection_handle_accept(void *arg)
441436
else {
442437
DEBUG("[#] Accepted connection %d on fd %d of type %s\n", client_sock, fd, listener_type_string(our_type));
443438

444-
//Connection will be non-blocking
439+
// Connection will be non-blocking
445440
if (connection_non_blocking(client_sock) < 0)
446441
PFATAL("Setting connection to non blocking failed on fd %d of type %s.", fd, listener_type_string(our_type));
447442

448-
//Enable TCP CORK
449-
setsockopt(client_sock, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
443+
// Set TCP options
444+
if(-1 == setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&enable, sizeof(enable))){
445+
DEBUG("[#] Unable to set tcp nodelay\n");
446+
}
447+
//setsockopt(client_sock, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
450448

451449
connections_queued* q = (connections_queued*)malloc(sizeof(connections_queued));
452450
if(q == NULL){

0 commit comments

Comments
 (0)