summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-10 00:47:33 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-10 00:47:33 +0000
commita86276004a49820977c665852e8a420bf0c3f432 (patch)
tree9e2b238afbaf30221bfc10a1163ecaae714cb72d /src
parentre-reading the config file after sig-hup (diff)
setting TCP_NODELAY option on sockets
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@44 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
Diffstat (limited to 'src')
-rw-r--r--src/clients.c13
1 files changed, 13 insertions, 0 deletions
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 <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#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]);