From a86276004a49820977c665852e8a420bf0c3f432 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 10 Dec 2010 00:47:33 +0000 Subject: setting TCP_NODELAY option on sockets git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@44 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/clients.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/clients.c b/src/clients.c index e4a7af5..1d529d6 100644 --- a/src/clients.c +++ b/src/clients.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "clients.h" #include "tcp.h" @@ -111,6 +112,18 @@ int clients_add(clients_t* list, int fd, const tcp_endpoint_t remote_end, const return -1; } + int on = 1; + if(setsockopt(element->fd_[0], IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) || + setsockopt(element->fd_[1], IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on))) { + log_printf(ERROR, "Error on setsockopt(): %s", strerror(errno)); + free(element->write_buf_[0].buf_); + free(element->write_buf_[1].buf_); + close(element->fd_[0]); + close(element->fd_[1]); + free(element); + return -1; + } + if(source_end.addr_.ss_family != AF_UNSPEC) { if(bind(element->fd_[1], (struct sockaddr *)&(source_end.addr_), source_end.len_)==-1) { log_printf(INFO, "Error on bind(): %s, not adding client %d", strerror(errno), element->fd_[0]); -- cgit v1.2.3