summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2015-10-08 10:51:02 +0200
committerMichael Adam <obnox@samba.org>2015-10-14 10:27:42 +0200
commite9e0dac6d719304af8174f4b9119709afe71f508 (patch)
treebd90a2d0a3ae1f2ae4d880994601619a9abf2ad0
parent40b1926e42896bb977705ed155c385b413ddd517 (diff)
downloadsocket_wrapper-e9e0dac6d719304af8174f4b9119709afe71f508.tar.gz
socket_wrapper-e9e0dac6d719304af8174f4b9119709afe71f508.tar.xz
socket_wrapper-e9e0dac6d719304af8174f4b9119709afe71f508.zip
swrap: Add support for TCP_NODELAY in setsockopt()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--src/socket_wrapper.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 45282ed..527ba21 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -248,6 +248,7 @@ struct socket_info
int connected;
int defer_connect;
int pktinfo;
+ int tcp_nodelay;
/* The unix path so we can unlink it on close() */
struct sockaddr_un un_addr;
@@ -3388,6 +3389,35 @@ static int swrap_setsockopt(int s, int level, int optname,
optname,
optval,
optlen);
+ } else if (level == IPPROTO_TCP) {
+ switch (optname) {
+#ifdef TCP_NODELAY
+ case TCP_NODELAY: {
+ int i;
+
+ /*
+ * This enables sending packets directly out over TCP.
+ * A unix socket is doing that any way.
+ */
+ if (optval == NULL || optlen == 0 ||
+ optlen < (socklen_t)sizeof(int)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ i = *discard_const_p(int, optval);
+ if (i != 0 && i != 1) {
+ errno = EINVAL;
+ return -1;
+ }
+ si->tcp_nodelay = i;
+
+ return 0;
+ }
+#endif /* TCP_NODELAY */
+ default:
+ break;
+ }
}
switch (si->family) {