From: adrian <> Date: Tue, 1 Jan 2002 16:47:46 +0000 (+0000) Subject: Add the kqueue support code - its not very useful as it stands in X-Git-Tag: SQUID_3_0_PRE1~1223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92b9f1fdde807ca4471da49a8c55014345f6377f;p=thirdparty%2Fsquid.git Add the kqueue support code - its not very useful as it stands in production because its missing support for deferred reads and delay pools, but it survives heavy polygraph pounding and interactive testing. Fix up some stupid automake-related brokenness that I introduced earlier while I'm at it. --- diff --git a/configure b/configure index c78e51ae2e..c92f447414 100755 --- a/configure +++ b/configure @@ -6881,8 +6881,14 @@ elif test "$ac_cv_func_select" = "yes" ; then #define USE_SELECT 1 EOF +elif test "$ac_cv_func_kqueue" = "yes" ; then + SELECT_TYPE="kqueue" + cat >> confdefs.h <<\EOF +#define USE_KQUEUE 1 +EOF + else - echo "Eep! Can't find poll or select!" + echo "Eep! Can't find poll, kqueue or select!" echo "I'll try select and hope for the best." SELECT_TYPE="select" cat >> confdefs.h <<\EOF @@ -6891,14 +6897,10 @@ EOF fi echo "Using ${SELECT_TYPE} for select loop." -cat >> confdefs.h <&6 -echo "configure:6902: checking if setresuid is implemented" >&5 +echo "configure:6904: checking if setresuid is implemented" >&5 if eval "test \"`echo '$''{'ac_cv_func_setresuid'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6906,7 +6908,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -6919,7 +6921,7 @@ else } EOF -if { (eval echo configure:6923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setresuid="yes" else @@ -6965,7 +6967,7 @@ fi if test "$IPF_TRANSPARENT" ; then echo $ac_n "checking if IP-Filter header files are installed""... $ac_c" 1>&6 -echo "configure:6969: checking if IP-Filter header files are installed" >&5 +echo "configure:6971: checking if IP-Filter header files are installed" >&5 # hold on to your hats... if test "$ac_cv_header_ip_compat_h" = "yes" || test "$ac_cv_header_ip_fil_compat_h" = "yes" || @@ -7006,7 +7008,7 @@ fi if test "$LINUX_NETFILTER" ; then echo $ac_n "checking if Linux 2.4 kernel header files are installed""... $ac_c" 1>&6 -echo "configure:7010: checking if Linux 2.4 kernel header files are installed" >&5 +echo "configure:7012: checking if Linux 2.4 kernel header files are installed" >&5 # hold on to your hats... if test "$ac_cv_header_linux_netfilter_ipv4_h" = "yes"; then LINUX_NETFILTER="yes" @@ -7040,13 +7042,13 @@ if test -z "$USE_GNUREGEX" ; then esac fi echo $ac_n "checking if GNUregex needs to be compiled""... $ac_c" 1>&6 -echo "configure:7044: checking if GNUregex needs to be compiled" >&5 +echo "configure:7046: checking if GNUregex needs to be compiled" >&5 if test -z "$USE_GNUREGEX"; then if test "$ac_cv_func_regcomp" = "no" || test "$USE_GNUREGEX" = "yes" ; then USE_GNUREGEX="yes" else cat > conftest.$ac_ext < #include @@ -7054,7 +7056,7 @@ int main() { regex_t t; regcomp(&t,"",0); ; return 0; } EOF -if { (eval echo configure:7058: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7060: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* USE_GNUREGEX="no" else @@ -7085,12 +7087,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7089: checking for $ac_func" >&5 +echo "configure:7091: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7141,12 +7143,12 @@ done echo $ac_n "checking Default FD_SETSIZE value""... $ac_c" 1>&6 -echo "configure:7145: checking Default FD_SETSIZE value" >&5 +echo "configure:7147: checking Default FD_SETSIZE value" >&5 if test "$cross_compiling" = yes; then DEFAULT_FD_SETSIZE=256 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then DEFAULT_FD_SETSIZE=`cat conftestval` else @@ -7190,7 +7192,7 @@ EOF echo $ac_n "checking Maximum number of filedescriptors we can open""... $ac_c" 1>&6 -echo "configure:7194: checking Maximum number of filedescriptors we can open" >&5 +echo "configure:7196: checking Maximum number of filedescriptors we can open" >&5 TLDFLAGS="$LDFLAGS" case $host in i386-unknown-freebsd*) @@ -7202,7 +7204,7 @@ if test "$cross_compiling" = yes; then SQUID_MAXFD=256 else cat > conftest.$ac_ext < @@ -7262,7 +7264,7 @@ main() { } EOF -if { (eval echo configure:7266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then SQUID_MAXFD=`cat conftestval` else @@ -7289,12 +7291,12 @@ fi LDFLAGS="$TLDFLAGS" echo $ac_n "checking Default UDP send buffer size""... $ac_c" 1>&6 -echo "configure:7293: checking Default UDP send buffer size" >&5 +echo "configure:7295: checking Default UDP send buffer size" >&5 if test "$cross_compiling" = yes; then SQUID_UDP_SO_SNDBUF=16384 else cat > conftest.$ac_ext < @@ -7315,7 +7317,7 @@ main () } EOF -if { (eval echo configure:7319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then SQUID_UDP_SO_SNDBUF=`cat conftestval` else @@ -7334,12 +7336,12 @@ EOF echo $ac_n "checking Default UDP receive buffer size""... $ac_c" 1>&6 -echo "configure:7338: checking Default UDP receive buffer size" >&5 +echo "configure:7340: checking Default UDP receive buffer size" >&5 if test "$cross_compiling" = yes; then SQUID_UDP_SO_RCVBUF=16384 else cat > conftest.$ac_ext < @@ -7360,7 +7362,7 @@ main () } EOF -if { (eval echo configure:7364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then SQUID_UDP_SO_RCVBUF=`cat conftestval` else @@ -7379,12 +7381,12 @@ EOF echo $ac_n "checking Default TCP send buffer size""... $ac_c" 1>&6 -echo "configure:7383: checking Default TCP send buffer size" >&5 +echo "configure:7385: checking Default TCP send buffer size" >&5 if test "$cross_compiling" = yes; then SQUID_TCP_SO_SNDBUF=16384 else cat > conftest.$ac_ext < @@ -7405,7 +7407,7 @@ main () } EOF -if { (eval echo configure:7409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then SQUID_TCP_SO_SNDBUF=`cat conftestval` else @@ -7424,12 +7426,12 @@ EOF echo $ac_n "checking Default TCP receive buffer size""... $ac_c" 1>&6 -echo "configure:7428: checking Default TCP receive buffer size" >&5 +echo "configure:7430: checking Default TCP receive buffer size" >&5 if test "$cross_compiling" = yes; then SQUID_TCP_SO_RCVBUF=16384 else cat > conftest.$ac_ext < @@ -7450,7 +7452,7 @@ main () } EOF -if { (eval echo configure:7454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then SQUID_TCP_SO_RCVBUF=`cat conftestval` else @@ -7469,19 +7471,19 @@ EOF echo $ac_n "checking if sys_errlist is already defined""... $ac_c" 1>&6 -echo "configure:7473: checking if sys_errlist is already defined" >&5 +echo "configure:7475: checking if sys_errlist is already defined" >&5 if eval "test \"`echo '$''{'ac_cv_needs_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *s = sys_errlist; ; return 0; } EOF -if { (eval echo configure:7485: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7487: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_needs_sys_errlist="no" else @@ -7503,16 +7505,16 @@ EOF fi echo $ac_n "checking for libresolv _dns_ttl_ hack""... $ac_c" 1>&6 -echo "configure:7507: checking for libresolv _dns_ttl_ hack" >&5 +echo "configure:7509: checking for libresolv _dns_ttl_ hack" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -7528,12 +7530,12 @@ fi rm -f conftest* echo $ac_n "checking if inet_ntoa() actually works""... $ac_c" 1>&6 -echo "configure:7532: checking if inet_ntoa() actually works" >&5 +echo "configure:7534: checking if inet_ntoa() actually works" >&5 if test "$cross_compiling" = yes; then INET_NTOA_RESULT="broken" else cat > conftest.$ac_ext < @@ -7552,7 +7554,7 @@ main () } EOF -if { (eval echo configure:7556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then INET_NTOA_RESULT=`cat conftestval` else @@ -7578,9 +7580,9 @@ fi if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then echo $ac_n "checking for working statvfs() interface""... $ac_c" 1>&6 -echo "configure:7582: checking for working statvfs() interface" >&5 +echo "configure:7584: checking for working statvfs() interface" >&5 cat > conftest.$ac_ext < @@ -7597,7 +7599,7 @@ statvfs("/tmp", &sfs); ; return 0; } EOF -if { (eval echo configure:7601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_func_statvfs=yes else @@ -7617,12 +7619,12 @@ fi fi echo $ac_n "checking for _res.nsaddr_list""... $ac_c" 1>&6 -echo "configure:7621: checking for _res.nsaddr_list" >&5 +echo "configure:7623: checking for _res.nsaddr_list" >&5 if eval "test \"`echo '$''{'ac_cv_have_res_nsaddr_list'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_have_res_nsaddr_list="yes" else @@ -7667,12 +7669,12 @@ fi if test $ac_cv_have_res_nsaddr_list = "no" ; then echo $ac_n "checking for _res.ns_list""... $ac_c" 1>&6 -echo "configure:7671: checking for _res.ns_list" >&5 +echo "configure:7673: checking for _res.ns_list" >&5 if eval "test \"`echo '$''{'ac_cv_have_res_ns_list'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7701: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_have_res_ns_list="yes" else diff --git a/configure.in b/configure.in index 9f63242253..89cf34ea22 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.255 2001/12/27 02:18:24 hno Exp $ +dnl $Id: configure.in,v 1.256 2002/01/01 09:47:47 adrian Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.6-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.255 $)dnl +AC_REVISION($Revision: 1.256 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1612,14 +1612,16 @@ if test "$ac_cv_func_poll" = "yes" ; then elif test "$ac_cv_func_select" = "yes" ; then SELECT_TYPE="select" AC_DEFINE(USE_SELECT) +elif test "$ac_cv_func_kqueue" = "yes" ; then + SELECT_TYPE="kqueue" + AC_DEFINE(USE_KQUEUE) else - echo "Eep! Can't find poll or select!" + echo "Eep! Can't find poll, kqueue or select!" echo "I'll try select and hope for the best." SELECT_TYPE="select" AC_DEFINE(USE_SELECT) fi echo "Using ${SELECT_TYPE} for select loop." -AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE") dnl Yay! Another Linux brokenness. Its not good enough diff --git a/include/autoconf.h.in b/include/autoconf.h.in index 1cff7243b6..37622245f2 100644 --- a/include/autoconf.h.in +++ b/include/autoconf.h.in @@ -52,15 +52,6 @@ /* Define to `int' if doesn't define. */ #undef pid_t -/* Define to the type of arg1 for select(). */ -#undef SELECT_TYPE_ARG1 - -/* Define to the type of args 2, 3 and 4 for select(). */ -#undef SELECT_TYPE_ARG234 - -/* Define to the type of arg5 for select(). */ -#undef SELECT_TYPE_ARG5 - /* Define to `unsigned' if doesn't define. */ #undef size_t @@ -396,6 +387,7 @@ /* Support for poll/select/etc stuff */ #undef USE_POLL #undef USE_SELECT +#undef USE_KQUEUE /* The number of bytes in a __int64. */ #undef SIZEOF___INT64 diff --git a/src/Makefile.am b/src/Makefile.am index 341e519718..8f025abf18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.19 2001/12/27 00:23:31 hno Exp $ +# $Id: Makefile.am,v 1.20 2002/01/01 09:47:48 adrian Exp $ # # Uncomment and customize the following to suit your needs: # @@ -114,6 +114,7 @@ squid_SOURCES = \ comm.c \ comm_select.c \ comm_poll.c \ + comm_kqueue.c \ debug.c \ defines.h \ $(DELAY_POOL_SOURCE) \ diff --git a/src/Makefile.in b/src/Makefile.in index 8e530e4410..155945c8a3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -16,7 +16,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.229 2001/12/27 01:03:56 hno Exp $ +# $Id: Makefile.in,v 1.230 2002/01/01 09:47:48 adrian Exp $ # # Uncomment and customize the following to suit your needs: # @@ -215,6 +215,7 @@ squid_SOURCES = \ comm.c \ comm_select.c \ comm_poll.c \ + comm_kqueue.c \ debug.c \ defines.h \ $(DELAY_POOL_SOURCE) \ @@ -459,19 +460,20 @@ am_squid_OBJECTS = access_log.$(OBJEXT) acl.$(OBJEXT) asn.$(OBJEXT) \ authenticate.$(OBJEXT) cache_cf.$(OBJEXT) CacheDigest.$(OBJEXT) \ cache_manager.$(OBJEXT) carp.$(OBJEXT) cbdata.$(OBJEXT) \ client_db.$(OBJEXT) client_side.$(OBJEXT) comm.$(OBJEXT) \ - comm_select.$(OBJEXT) comm_poll.$(OBJEXT) debug.$(OBJEXT) \ - $(am__objects_3) disk.$(OBJEXT) $(am__objects_4) \ - errorpage.$(OBJEXT) ETag.$(OBJEXT) event.$(OBJEXT) fd.$(OBJEXT) \ - filemap.$(OBJEXT) forward.$(OBJEXT) fqdncache.$(OBJEXT) \ - ftp.$(OBJEXT) gopher.$(OBJEXT) helper.$(OBJEXT) \ - $(am__objects_5) http.$(OBJEXT) HttpStatusLine.$(OBJEXT) \ - HttpHdrCc.$(OBJEXT) HttpHdrRange.$(OBJEXT) \ - HttpHdrContRange.$(OBJEXT) HttpHeader.$(OBJEXT) \ - HttpHeaderTools.$(OBJEXT) HttpBody.$(OBJEXT) HttpMsg.$(OBJEXT) \ - HttpReply.$(OBJEXT) HttpRequest.$(OBJEXT) icmp.$(OBJEXT) \ - icp_v2.$(OBJEXT) icp_v3.$(OBJEXT) ident.$(OBJEXT) \ - internal.$(OBJEXT) ipc.$(OBJEXT) ipcache.$(OBJEXT) \ - $(am__objects_6) logfile.$(OBJEXT) main.$(OBJEXT) mem.$(OBJEXT) \ + comm_select.$(OBJEXT) comm_poll.$(OBJEXT) comm_kqueue.$(OBJEXT) \ + debug.$(OBJEXT) $(am__objects_3) disk.$(OBJEXT) \ + $(am__objects_4) errorpage.$(OBJEXT) ETag.$(OBJEXT) \ + event.$(OBJEXT) fd.$(OBJEXT) filemap.$(OBJEXT) \ + forward.$(OBJEXT) fqdncache.$(OBJEXT) ftp.$(OBJEXT) \ + gopher.$(OBJEXT) helper.$(OBJEXT) $(am__objects_5) \ + http.$(OBJEXT) HttpStatusLine.$(OBJEXT) HttpHdrCc.$(OBJEXT) \ + HttpHdrRange.$(OBJEXT) HttpHdrContRange.$(OBJEXT) \ + HttpHeader.$(OBJEXT) HttpHeaderTools.$(OBJEXT) \ + HttpBody.$(OBJEXT) HttpMsg.$(OBJEXT) HttpReply.$(OBJEXT) \ + HttpRequest.$(OBJEXT) icmp.$(OBJEXT) icp_v2.$(OBJEXT) \ + icp_v3.$(OBJEXT) ident.$(OBJEXT) internal.$(OBJEXT) \ + ipc.$(OBJEXT) ipcache.$(OBJEXT) $(am__objects_6) \ + logfile.$(OBJEXT) main.$(OBJEXT) mem.$(OBJEXT) \ MemPool.$(OBJEXT) MemBuf.$(OBJEXT) mime.$(OBJEXT) \ multicast.$(OBJEXT) neighbors.$(OBJEXT) net_db.$(OBJEXT) \ Packer.$(OBJEXT) pconn.$(OBJEXT) peer_digest.$(OBJEXT) \ @@ -523,28 +525,29 @@ depcomp = $(SHELL) $(top_srcdir)/cfgaux/depcomp @AMDEP_TRUE@ $(DEPDIR)/carp.Po $(DEPDIR)/cbdata.Po \ @AMDEP_TRUE@ $(DEPDIR)/cf_gen.Po $(DEPDIR)/client.Po \ @AMDEP_TRUE@ $(DEPDIR)/client_db.Po $(DEPDIR)/client_side.Po \ -@AMDEP_TRUE@ $(DEPDIR)/comm.Po $(DEPDIR)/comm_poll.Po \ -@AMDEP_TRUE@ $(DEPDIR)/comm_select.Po $(DEPDIR)/debug.Po \ -@AMDEP_TRUE@ $(DEPDIR)/delay_pools.Po $(DEPDIR)/disk.Po \ -@AMDEP_TRUE@ $(DEPDIR)/dns.Po $(DEPDIR)/dns_internal.Po \ -@AMDEP_TRUE@ $(DEPDIR)/dnsserver.Po $(DEPDIR)/errorpage.Po \ -@AMDEP_TRUE@ $(DEPDIR)/event.Po $(DEPDIR)/fd.Po \ -@AMDEP_TRUE@ $(DEPDIR)/filemap.Po $(DEPDIR)/forward.Po \ -@AMDEP_TRUE@ $(DEPDIR)/fqdncache.Po $(DEPDIR)/ftp.Po \ -@AMDEP_TRUE@ $(DEPDIR)/globals.Po $(DEPDIR)/gopher.Po \ -@AMDEP_TRUE@ $(DEPDIR)/helper.Po $(DEPDIR)/htcp.Po \ -@AMDEP_TRUE@ $(DEPDIR)/http.Po $(DEPDIR)/icmp.Po \ -@AMDEP_TRUE@ $(DEPDIR)/icp_v2.Po $(DEPDIR)/icp_v3.Po \ -@AMDEP_TRUE@ $(DEPDIR)/ident.Po $(DEPDIR)/internal.Po \ -@AMDEP_TRUE@ $(DEPDIR)/ipc.Po $(DEPDIR)/ipcache.Po \ -@AMDEP_TRUE@ $(DEPDIR)/leakfinder.Po $(DEPDIR)/logfile.Po \ -@AMDEP_TRUE@ $(DEPDIR)/main.Po $(DEPDIR)/mem.Po \ -@AMDEP_TRUE@ $(DEPDIR)/mime.Po $(DEPDIR)/multicast.Po \ -@AMDEP_TRUE@ $(DEPDIR)/neighbors.Po $(DEPDIR)/net_db.Po \ -@AMDEP_TRUE@ $(DEPDIR)/pconn.Po $(DEPDIR)/peer_digest.Po \ -@AMDEP_TRUE@ $(DEPDIR)/peer_select.Po $(DEPDIR)/pinger.Po \ -@AMDEP_TRUE@ $(DEPDIR)/redirect.Po $(DEPDIR)/referer.Po \ -@AMDEP_TRUE@ $(DEPDIR)/refresh.Po $(DEPDIR)/repl_modules.Po \ +@AMDEP_TRUE@ $(DEPDIR)/comm.Po $(DEPDIR)/comm_kqueue.Po \ +@AMDEP_TRUE@ $(DEPDIR)/comm_poll.Po $(DEPDIR)/comm_select.Po \ +@AMDEP_TRUE@ $(DEPDIR)/debug.Po $(DEPDIR)/delay_pools.Po \ +@AMDEP_TRUE@ $(DEPDIR)/disk.Po $(DEPDIR)/dns.Po \ +@AMDEP_TRUE@ $(DEPDIR)/dns_internal.Po $(DEPDIR)/dnsserver.Po \ +@AMDEP_TRUE@ $(DEPDIR)/errorpage.Po $(DEPDIR)/event.Po \ +@AMDEP_TRUE@ $(DEPDIR)/fd.Po $(DEPDIR)/filemap.Po \ +@AMDEP_TRUE@ $(DEPDIR)/forward.Po $(DEPDIR)/fqdncache.Po \ +@AMDEP_TRUE@ $(DEPDIR)/ftp.Po $(DEPDIR)/globals.Po \ +@AMDEP_TRUE@ $(DEPDIR)/gopher.Po $(DEPDIR)/helper.Po \ +@AMDEP_TRUE@ $(DEPDIR)/htcp.Po $(DEPDIR)/http.Po \ +@AMDEP_TRUE@ $(DEPDIR)/icmp.Po $(DEPDIR)/icp_v2.Po \ +@AMDEP_TRUE@ $(DEPDIR)/icp_v3.Po $(DEPDIR)/ident.Po \ +@AMDEP_TRUE@ $(DEPDIR)/internal.Po $(DEPDIR)/ipc.Po \ +@AMDEP_TRUE@ $(DEPDIR)/ipcache.Po $(DEPDIR)/leakfinder.Po \ +@AMDEP_TRUE@ $(DEPDIR)/logfile.Po $(DEPDIR)/main.Po \ +@AMDEP_TRUE@ $(DEPDIR)/mem.Po $(DEPDIR)/mime.Po \ +@AMDEP_TRUE@ $(DEPDIR)/multicast.Po $(DEPDIR)/neighbors.Po \ +@AMDEP_TRUE@ $(DEPDIR)/net_db.Po $(DEPDIR)/pconn.Po \ +@AMDEP_TRUE@ $(DEPDIR)/peer_digest.Po $(DEPDIR)/peer_select.Po \ +@AMDEP_TRUE@ $(DEPDIR)/pinger.Po $(DEPDIR)/redirect.Po \ +@AMDEP_TRUE@ $(DEPDIR)/referer.Po $(DEPDIR)/refresh.Po \ +@AMDEP_TRUE@ $(DEPDIR)/repl_modules.Po \ @AMDEP_TRUE@ $(DEPDIR)/send-announce.Po $(DEPDIR)/snmp_agent.Po \ @AMDEP_TRUE@ $(DEPDIR)/snmp_core.Po $(DEPDIR)/ssl.Po \ @AMDEP_TRUE@ $(DEPDIR)/ssl_support.Po $(DEPDIR)/stat.Po \ @@ -702,6 +705,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/client_db.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/client_side.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/comm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/comm_kqueue.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/comm_poll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/comm_select.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/debug.Po@am__quote@ diff --git a/src/comm_kqueue.cc b/src/comm_kqueue.cc new file mode 100644 index 0000000000..f37fb1348a --- /dev/null +++ b/src/comm_kqueue.cc @@ -0,0 +1,285 @@ + +/* + * $Id: comm_kqueue.cc,v 1.1 2002/01/01 09:47:48 adrian Exp $ + * + * DEBUG: section 5 Socket functions + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +/* + * This code was originally written by Benno Rice and hacked on quite + * a bit by Adrian. Adrian then took it to the hybrid-ircd project to use + * in their new IO subsystem. After a year of modifications and some + * rather interesting changes (event aggregation) its back in squid. + * Thanks to the ircd-hybrid guys. + */ + +/* + * XXX Currently not implemented / supported by this module XXX + * + * - delay pools + * - deferred reads + * + * So, its not entirely useful in a production setup since if a read + * is meant to be deferred it isn't (we're not even throwing the event + * away here). Eventually the rest of the code will be rewritten + * so deferred reads aren't required. + * -- adrian + */ + +#include "squid.h" + +#ifdef USE_KQUEUE + +#include + + +#define KE_LENGTH 128 + +/* jlemon goofed up and didn't add EV_SET until fbsd 4.3 */ + +#ifndef EV_SET +#define EV_SET(kevp, a, b, c, d, e, f) do { \ + (kevp)->ident = (a); \ + (kevp)->filter = (b); \ + (kevp)->flags = (c); \ + (kevp)->fflags = (d); \ + (kevp)->data = (e); \ + (kevp)->udata = (f); \ +} while(0) +#endif + +static void kq_update_events(int, short, PF *); +static int kq; +static struct timespec zero_timespec; + +static struct kevent *kqlst; /* kevent buffer */ +static int kqmax; /* max structs to buffer */ +static int kqoff; /* offset into the buffer */ + + +/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ +/* Private functions */ + +void +kq_update_events(int fd, short filter, PF * handler) +{ + PF *cur_handler; + int kep_flags; + +#if 0 + int retval; +#endif + + switch (filter) { + case EVFILT_READ: + cur_handler = fd_table[fd].read_handler; + break; + case EVFILT_WRITE: + cur_handler = fd_table[fd].write_handler; + break; + default: + /* XXX bad! -- adrian */ + return; + break; + } + + if ((cur_handler == NULL && handler != NULL) + || (cur_handler != NULL && handler == NULL)) { + struct kevent *kep; + + kep = kqlst + kqoff; + + if (handler != NULL) { + kep_flags = (EV_ADD | EV_ONESHOT); + } else { + kep_flags = EV_DELETE; + } + + EV_SET(kep, (uintptr_t) fd, filter, kep_flags, 0, 0, 0); + + if (kqoff == kqmax) { + int ret; + + ret = kevent(kq, kqlst, kqoff, NULL, 0, &zero_timespec); + /* jdc -- someone needs to do error checking... */ + if (ret == -1) { + perror("kq_update_events(): kevent()"); + return; + } + kqoff = 0; + } else { + kqoff++; + } +#if 0 + if (retval < 0) { + /* Error! */ + if (ke.flags & EV_ERROR) { + errno = ke.data; + } + } +#endif + } +} + + + +/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ +/* Public functions */ + + +/* + * comm_select_init + * + * This is a needed exported function which will be called to initialise + * the network loop code. + */ +void +comm_select_init(void) +{ + kq = kqueue(); + if (kq < 0) { + fatal("comm_select_init: Couldn't open kqueue fd!\n"); + } + kqmax = getdtablesize(); + kqlst = xmalloc(sizeof(*kqlst) * kqmax); + zero_timespec.tv_sec = 0; + zero_timespec.tv_nsec = 0; +} + +/* + * comm_setselect + * + * This is a needed exported function which will be called to register + * and deregister interest in a pending IO state for a given FD. + */ +void +commSetSelect(int fd, unsigned int type, PF * handler, + void *client_data, time_t timeout) +{ + fde *F = &fd_table[fd]; + assert(fd >= 0); + assert(F->flags.open); + + if (type & COMM_SELECT_READ) { + kq_update_events(fd, EVFILT_READ, handler); + F->read_handler = handler; + F->read_data = client_data; + } + if (type & COMM_SELECT_WRITE) { + kq_update_events(fd, EVFILT_WRITE, handler); + F->write_handler = handler; + F->write_data = client_data; + } + if (timeout) + F->timeout = squid_curtime + timeout; + +} + +/* + * Check all connections for new connections and input data that is to be + * processed. Also check for connections with data queued and whether we can + * write it out. + */ + +/* + * comm_select + * + * Called to do the new-style IO, courtesy of of squid (like most of this + * new IO code). This routine handles the stuff we've hidden in + * comm_setselect and fd_table[] and calls callbacks for IO ready + * events. + */ + +int +comm_select(int msec) +{ + int num, i; + static struct kevent ke[KE_LENGTH]; + struct timespec poll_time; + + do { + /* + * remember we are doing NANOseconds here, not micro/milli. God knows + * why jlemon used a timespec, but hey, he wrote the interface, not I + * -- Adrian + */ + poll_time.tv_sec = msec / 1000; + poll_time.tv_nsec = (msec % 1000) * 1000000; + for (;;) { + num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time); + statCounter.select_loops++; + kqoff = 0; + if (num >= 0) + break; + if (ignoreErrno(errno)) + break; + getCurrentTime(); + return COMM_ERROR; + /* NOTREACHED */ + } + + getCurrentTime(); + if (num == 0) + continue; + + for (i = 0; i < num; i++) { + int fd = (int) ke[i].ident; + PF *hdl = NULL; + fde *F = &fd_table[fd]; + + if (ke[i].flags & EV_ERROR) { + errno = ke[i].data; + /* XXX error == bad! -- adrian */ + continue; /* XXX! */ + } + switch (ke[i].filter) { + case EVFILT_READ: + if ((hdl = F->read_handler) != NULL) { + F->read_handler = NULL; + hdl(fd, F->read_data); + } + case EVFILT_WRITE: + if ((hdl = F->write_handler) != NULL) { + F->write_handler = NULL; + hdl(fd, F->write_data); + } + default: + /* Bad! -- adrian */ + break; + } + } + return COMM_OK; + } + while (0); /* XXX should rip this out! -- adrian */ + /* XXX Get here, we broke! */ + return 0; +} + +#endif /* USE_KQUEUE */