--------------------- PatchSet 11242 Date: 2007/02/05 22:11:40 Author: hno Branch: SQUID_2_6 Tag: (none) Log: MFC: Fix a timing issue in the AF_UNIX dgram socket test due to some timing issues on systems where the test as such is unsuccessful it could leave ./conftest processes behind. Members: configure.in:1.416.2.3->1.416.2.4 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid/squid/configure.in,v retrieving revision 1.416.2.3 retrieving revision 1.416.2.4 diff -u -r1.416.2.3 -r1.416.2.4 --- squid/configure.in 3 Feb 2007 22:58:20 -0000 1.416.2.3 +++ squid/configure.in 5 Feb 2007 22:11:40 -0000 1.416.2.4 @@ -1,7 +1,7 @@ dnl dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.416.2.3 2007/02/03 22:58:20 hno Exp $ +dnl $Id: configure.in,v 1.416.2.4 2007/02/05 22:11:40 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.416.2.3 $)dnl +AC_REVISION($Revision: 1.416.2.4 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -2437,19 +2437,34 @@ AC_TRY_RUN([ #include #include +#if HAVE_SYS_SELECT_H +#include +#else +#include +#endif #include #include #include #define BUFSIZE 16384 - void consumer(int s) + void consumer(int s, int p) { + fd_set fds; char buf[[BUFSIZE]]; int len; - len = recv(s, buf, sizeof(buf), 0); + int nfds = p > s ? p + 1 : s + 1; + int rc; + FD_ZERO(&fds); + FD_SET(s, &fds); + FD_SET(p, &fds); + rc = select(nfds, &fds, NULL, NULL, NULL); + if (rc < 0) + exit(1); + if (FD_ISSET(s, &fds)) + len = recv(s, buf, sizeof(buf), 0); } - void sender(int s) + void sender(int s, int p) { char buf[[BUFSIZE]]; int len = sizeof(buf); @@ -2467,8 +2482,10 @@ int main(int argc, char **argv) { int s[[2]]; + int p[[2]]; pid_t pid; socketpair(AF_UNIX, SOCK_DGRAM, 0, s); + pipe(p); pid = fork(); if (pid < 0) { perror("fork"); @@ -2476,10 +2493,12 @@ } if (pid == 0) { close(s[[0]]); - consumer(s[[1]]); + close(p[[0]]); + consumer(s[[1]],p[[1]]); } else { close(s[[1]]); - sender(s[[0]]); + close(p[[1]]); + sender(s[[0]],p[[0]]); } return 0; }