summaryrefslogtreecommitdiff
path: root/Xtranssock.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@openbsd.org>2014-03-29 23:51:49 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-31 11:45:04 +0200
commit1cd9cbe9b404e6c3e73dc0239d11547a5e2c02c4 (patch)
tree085ff1bc87b451ddf492988c6a4b7d2c1b72d912 /Xtranssock.c
parent68f60238c4224f954ff6556ae778c72e420175f0 (diff)
Increase UNIX socket buffer size
Some systems provide a really small default buffer size for UNIX sockets. Bump it up to 64k if necessary such that large transfers (such as XGetImage() on a 8-megapixel image) don't take tens of seconds. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'Xtranssock.c')
-rw-r--r--Xtranssock.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Xtranssock.c b/Xtranssock.c
index fdf1dd7..6cde146 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -445,6 +445,27 @@ TRANS(SocketOpen) (int i, int type)
}
#endif
+ /*
+ * Some systems provide a really small default buffer size for
+ * UNIX sockets. Bump it up a bit such that large transfers don't
+ * proceed at glacial speed.
+ */
+#ifdef SO_SNDBUF
+ if (Sockettrans2devtab[i].family == AF_UNIX)
+ {
+ SOCKLEN_T len = sizeof (int);
+ int val;
+
+ if (getsockopt (ciptr->fd, SOL_SOCKET, SO_SNDBUF,
+ (char *) &val, &len) == 0 && val < 64 * 1024)
+ {
+ val = 64 * 1024;
+ setsockopt (ciptr->fd, SOL_SOCKET, SO_SNDBUF,
+ (char *) &val, sizeof (int));
+ }
+ }
+#endif
+
return ciptr;
}