Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <libubox/blobmsg.h>
#include <errno.h>
#include <limits.h>
#include <netinet/tcp.h>

#include "uhttpd.h"
#include "tls.h"
Expand Down Expand Up @@ -823,6 +824,7 @@ bool uh_accept_client(int fd, bool tls)
static struct client *next_client;
struct client *cl;
unsigned int sl;
int yes = 1;
int sfd;
static int client_id = 0;
struct sockaddr_in6 addr;
Expand All @@ -837,6 +839,13 @@ bool uh_accept_client(int fd, bool tls)
if (sfd < 0)
return false;

/* A response is emitted as one write() per header line plus one for the
* body, so with Nagle enabled the small final segment of a response on a
* REUSED keep-alive connection is held back until the peer acknowledges
* the previous one - which its delayed ACK timer puts ~40 ms away. Every
* request after the first on a connection pays that. */
setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));

set_addr(&cl->peer_addr, &addr);
sl = sizeof(addr);
getsockname(sfd, (struct sockaddr *) &addr, &sl);
Expand Down