--------------------- PatchSet 11241 Date: 2007/02/05 22:10:33 Author: hno Branch: HEAD Tag: (none) Log: 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.418->1.419 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid/squid/configure.in,v retrieving revision 1.418 retrieving revision 1.419 diff -u -r1.418 -r1.419 --- squid/configure.in 3 Feb 2007 22:52:11 -0000 1.418 +++ squid/configure.in 5 Feb 2007 22:10:33 -0000 1.419 @@ -1,7 +1,7 @@ dnl dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.418 2007/02/03 22:52:11 hno Exp $ +dnl $Id: configure.in,v 1.419 2007/02/05 22:10:33 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.418 $)dnl +AC_REVISION($Revision: 1.419 $)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; }