--------------------- PatchSet 11232 Date: 2007/02/03 22:52:11 Author: hno Branch: HEAD Tag: (none) Log: Autoconf test to detect if AF_UNIX socketpair is useable. Members: configure.in:1.417->1.418 src/defines.h:1.123->1.124 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid/squid/configure.in,v retrieving revision 1.417 retrieving revision 1.418 diff -u -r1.417 -r1.418 --- squid/configure.in 21 Jan 2007 04:30:32 -0000 1.417 +++ squid/configure.in 3 Feb 2007 22:52:11 -0000 1.418 @@ -1,7 +1,7 @@ dnl dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.417 2007/01/21 04:30:32 hno Exp $ +dnl $Id: configure.in,v 1.418 2007/02/03 22:52:11 hno Exp $ dnl dnl dnl @@ -10,7 +10,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE -AC_REVISION($Revision: 1.417 $)dnl +AC_REVISION($Revision: 1.418 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -2430,6 +2430,65 @@ AM_CONDITIONAL([USE_SELECT_WIN32], [test $SELECT_TYPE = select_win32]) AM_CONDITIONAL([USE_KQUEUE], [test $SELECT_TYPE = kqueue]) +dnl Hmm.. some OS:es (i.e. FreeBSD) can't handle large AF_UNIX dgram packets. +dnl Verify that at least 16K is supported, if not fall back on using +dnl IP dgram sockets for IPC. +AC_CACHE_CHECK(if AF_UNIX dgram sockets support large packets, ac_cv_af_unix_large_dgram, + AC_TRY_RUN([ +#include +#include +#include +#include +#include + +#define BUFSIZE 16384 + void consumer(int s) + { + char buf[[BUFSIZE]]; + int len; + len = recv(s, buf, sizeof(buf), 0); + } + + void sender(int s) + { + char buf[[BUFSIZE]]; + int len = sizeof(buf); + int rc = send(s, buf, len, 0); + if (rc < 0) { + perror("send"); + exit(1); + } + if (rc != len) { + fprintf(stderr, "Short send %d of %d\n", rc, len); + exit(1); + } + } + + int main(int argc, char **argv) + { + int s[[2]]; + pid_t pid; + socketpair(AF_UNIX, SOCK_DGRAM, 0, s); + pid = fork(); + if (pid < 0) { + perror("fork"); + exit(0); + } + if (pid == 0) { + close(s[[0]]); + consumer(s[[1]]); + } else { + close(s[[1]]); + sender(s[[0]]); + } + return 0; + } + ], ac_cv_af_unix_large_dgram="yes",ac_cv_af_unix_large_dgram="no") +) +if test "$ac_cv_af_unix_large_dgram" = "yes" ; then + AC_DEFINE(SUPPORTS_LARGE_AF_UNIX_DGRAM, 1, [Supports large dgram sockets over AF_UNIX sockets]) +fi + dnl Yay! Another Linux brokenness. Its not good enough dnl to know that setresuid() exists, because RedHat 5.0 declares dnl setresuid() but doesn't implement it. Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid/squid/src/defines.h,v retrieving revision 1.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- squid/src/defines.h 3 Feb 2007 22:22:51 -0000 1.123 +++ squid/src/defines.h 3 Feb 2007 22:52:11 -0000 1.124 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.123 2007/02/03 22:22:51 hno Exp $ + * $Id: defines.h,v 1.124 2007/02/03 22:52:11 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -223,10 +223,9 @@ /* * Do NOT use IPC_UNIX_DGRAM here because you can't * send() more than 4096 bytes on a socketpair() socket - * on FreeBSD - * XXX There should be a configure test for this + * at least on FreeBSD */ -#if HAVE_SOCKETPAIR && defined (AF_UNIX) && !defined(_SQUID_FREEBSD_) +#if HAVE_SOCKETPAIR && defined (AF_UNIX) && SUPPORTS_LARGE_AF_UNIX_DGRAM #define IPC_DGRAM IPC_UNIX_DGRAM #else #define IPC_DGRAM IPC_UDP_SOCKET