[squid-users] [PATCH] Squid 3.5.19 SMP under OpenBSD - setsockopt for UDS

Silamael Silamael at coronamundi.de
Mon Jun 27 09:16:35 UTC 2016


Hi,

I'm playing around with the SMP feature on OpenBSD 5.9 and noticed that
Squid does not run due to hard coded limits for the receive and send
buffer sizes of Unix Domain Sockets. In contrary to other OSes these
limits cannot be adjusted by a sysctl.
The attached patch adds some setsockopt() calls to comm.cc which sets
the buffer sizes to 256kb.

PS: Also i noticed that if squid is called with -z for creating the
cache directories, that ${process_number} macro is not expanded but
always set to 0. squid -z only creates one cache dir although in the
configuration
cache_dir ufs /var/squid/cache/cache-foo-${process_number} 700 8 16
is set.

Greetings,
Matthias
-------------- next part --------------
--- src/comm.cc.orig	Thu Jun 23 14:52:52 2016
+++ src/comm.cc	Thu Jun 23 14:54:34 2016
@@ -1937,6 +1937,20 @@ comm_open_uds(int sock_type,
     if (Config.tcpRcvBufsz > 0 && sock_type == SOCK_STREAM)
         commSetTcpRcvbuf(new_socket, Config.tcpRcvBufsz);
 
+#ifdef _SQUID_OPENBSD_
+    /* Set socket buffer size on Unix domain dgram sockets as OpenBSD defaults
+     * to 2k send and 4k recv buffer size
+     */
+    if (sock_type == SOCK_DGRAM) {
+	int size = 262144;
+	int error = 0;
+	if ((error = setsockopt(new_socket, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size))) < 0)
+	    debugs(50, DBG_IMPORTANT, "Error setting rcv buffer size to " << size << ": " << xstrerr(error));
+	if ((error = setsockopt(new_socket, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size))) < 0)
+	    debugs(50, DBG_IMPORTANT, "Error setting send buffer size to " << size << ": " << xstrerr(error));
+    }
+#endif
+
     PROF_stop(comm_open);
 
     return new_socket;


More information about the squid-users mailing list