summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2014-07-28 12:18:29 +0530
committerLennart Poettering <lennart@poettering.net>2014-08-14 03:15:59 +0200
commit4427c3f43a87c2e0c784fda6be1b9715be820733 (patch)
tree14a01c5bc763bdd523cb9fdb663fc37df2a8716f /src/core/socket.c
parente9e74f28d783a052dce7edfa94d7918bb591ba7a (diff)
socket: add support for tcp nagle
This patch adds support for TCP TCP_NODELAY socket option. This can be configured via NoDelay conf parameter. TCP Nagle's algorithm works by combining a number of small outgoing messages, and sending them all at once. This controls the TCP_NODELAY socket option.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 646887d803..5af15964ff 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -480,6 +480,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
"%sSocketMode: %04o\n"
"%sDirectoryMode: %04o\n"
"%sKeepAlive: %s\n"
+ "%sNoDelay: %s\n"
"%sFreeBind: %s\n"
"%sTransparent: %s\n"
"%sBroadcast: %s\n"
@@ -494,6 +495,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->socket_mode,
prefix, s->directory_mode,
prefix, yes_no(s->keep_alive),
+ prefix, yes_no(s->no_delay),
prefix, yes_no(s->free_bind),
prefix, yes_no(s->transparent),
prefix, yes_no(s->broadcast),
@@ -790,6 +792,12 @@ static void socket_apply_socket_options(Socket *s, int fd) {
log_warning_unit(UNIT(s)->id, "SO_KEEPALIVE failed: %m");
}
+ if (s->no_delay) {
+ int b = s->no_delay;
+ if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
+ log_warning_unit(UNIT(s)->id, "TCP_NODELAY failed: %m");
+ }
+
if (s->broadcast) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)