[Xcb-commit] libxcb: src

Christian Linhart clinhart at kemper.freedesktop.org
Tue Feb 2 23:32:16 PST 2016


 src/xcb_util.c |    7 +++++++
 1 file changed, 7 insertions(+)

New commits:
commit 095353ff1a4f611922dfc4c98b0c4bd55d9f6d4f
Author: Mark Kettenis <kettenis at openbsd.org>
Date:   Sat Jan 23 17:29:32 2016 +0100

    Increase unix socket send buffer to at least 64KB
    
    Some systems (e.g. OpenBSD) have a rather small default socket send buffer
    size of 4KB.  The result is that sending requests with a largish payload
    requires serveral writev(2) system calls.  Make sure the socket send buffer
    is at least 64KB such that we're likely to succeed with a single system
    call for most requests.  A similar change was made to the xtrans code
    some time ago.
    
    Signed-off-by: Mark Kettenis <kettenis at openbsd.org>
    Reviewed-by: Matthieu Herrb <matthieu at herrb.eu>

diff --git a/src/xcb_util.c b/src/xcb_util.c
index ba0f108..a3357ef 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -428,6 +428,8 @@ static int _xcb_open_unix(char *protocol, const char *file)
 {
     int fd;
     struct sockaddr_un addr;
+    socklen_t len = sizeof(int);
+    int val;
 
     if (protocol && strcmp("unix",protocol))
         return -1;
@@ -440,6 +442,11 @@ static int _xcb_open_unix(char *protocol, const char *file)
     fd = _xcb_socket(AF_UNIX, SOCK_STREAM, 0);
     if(fd == -1)
         return -1;
+    if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) == 0 && val < 64 * 1024)
+    {
+        val = 64 * 1024;
+        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(int));
+    }
     if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
         close(fd);
         return -1;


More information about the xcb-commit mailing list