Set TCP_NODELAY flag only after login to make SSL handshakes

run with less packets.
This commit is contained in:
Heikki Hannikainen 2013-12-28 12:48:52 +02:00
parent 576182ecdd
commit aa862ab99a
1 changed files with 17 additions and 9 deletions

View File

@ -474,15 +474,6 @@ int set_client_sockopt(struct client_t *c)
return sctp_set_client_sockopt(c);
#endif
/* Use TCP_NODELAY for APRS-IS sockets. High delays can cause packets getting past
* the dupe filters.
*/
#ifdef TCP_NODELAY
int arg = 1;
if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, (void *)&arg, sizeof(arg)))
hlog(LOG_ERR, "%s - setsockopt(TCP_NODELAY, %d) failed: %s", c->addr_rem, arg, strerror(errno));
#endif
/* Set up TCP keepalives, so that we'll notice idle clients.
* I'm not sure if this is absolutely required, since we send
* keepalive datetime messages every 30 seconds from the application,
@ -517,6 +508,21 @@ int set_client_sockopt(struct client_t *c)
return 0;
}
int set_client_sockopt_post_login(struct client_t *c)
{
/* Use TCP_NODELAY for APRS-IS sockets. High delays can cause packets getting past
* the dupe filters.
*/
#ifdef TCP_NODELAY
int arg = 1;
if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, (void *)&arg, sizeof(arg)))
hlog(LOG_ERR, "%s - setsockopt(TCP_NODELAY, %d) failed: %s", c->addr_rem, arg, strerror(errno));
#endif
return 0;
}
/*
* Pass a new client to a worker thread
*/
@ -1411,6 +1417,8 @@ void worker_mark_client_connected(struct worker_t *self, struct client_t *c)
{
c->state = CSTATE_CONNECTED;
set_client_sockopt_post_login(c);
/* classify the client and put it in the right list of clients for
* outgoing data to start flowing.
*/