--------------------- PatchSet 1231 Date: 2001/01/09 22:02:13 Author: hno Branch: hno-devel Tag: (none) Log: Cleaning up my old development, to recover what might be interesting. Removed: - Backed out TE (it is in a separate branch) - Committed dnsserver queue overload to HEAD - async-io changes is committed to HEAD long time back - other various minor changes not worth the effort Members: ChangeLog:1.1.1.3.6.5.2.6->1.1.1.3.6.5.2.7 acconfig.h:1.1.1.3.6.5.2.5->1.1.1.3.6.5.2.6 configure.in:1.1.1.3.6.7.2.22->1.1.1.3.6.7.2.23 makefile.in:1.1.1.3.6.1.2.2->1.1.1.3.6.1.2.3 include/version.h:1.1.1.3.10.4.2.1->1.1.1.3.10.4.2.2 src/HttpHeader.c:1.1.1.3.6.2.2.1->1.1.1.3.6.2.2.2 src/HttpHeaderTools.c:1.1.1.3.6.2->1.1.1.3.6.2.2.1 src/authenticate.c:1.1.1.3.10.2->1.1.1.3.10.2.2.1 src/client_side.c:1.1.1.3.10.7.2.18->1.1.1.3.10.7.2.19 src/defines.h:1.1.1.3.10.3.2.1->1.1.1.3.10.3.2.2 src/dns.c:1.1.1.3.10.2.2.3->1.1.1.3.10.2.2.4 src/enums.h:1.1.1.3.10.5.2.6->1.1.1.3.10.5.2.7 src/http.c:1.1.1.3.10.4.2.5->1.1.1.3.10.4.2.6 src/icmp.c:1.1.1.2.12.2.2.2->1.1.1.2.12.2.2.3 src/ipc.c:1.1.1.3.10.4.2.1->1.1.1.3.10.4.2.2 src/protos.h:1.1.1.3.10.8.2.10->1.1.1.3.10.8.2.11 src/redirect.c:1.1.1.3.10.3->1.1.1.3.10.3.2.1 src/store_swapout.c:1.1.1.3.10.5.2.7->1.1.1.3.10.5.2.8 src/structs.h:1.1.1.3.10.8.2.15->1.1.1.3.10.8.2.16 src/unlinkd.c:1.1.1.3.10.3.2.6->1.1.1.3.10.3.2.7 src/fs/aufs/Makefile.in:1.1.6.3.2.2->1.1.6.3.2.3 src/fs/aufs/aiops.c:1.1.6.1.2.5->1.1.6.1.2.6 src/fs/aufs/async_io.c:1.1.6.1.2.6->1.1.6.1.2.7 src/fs/aufs/store_asyncufs.h:1.1.6.3.2.9->1.1.6.3.2.10 src/fs/aufs/store_dir_aufs.c:1.1.6.6.2.6->1.1.6.6.2.7 src/fs/aufs/store_io_aufs.c:1.1.6.6.2.8->1.1.6.6.2.9 Index: squid/ChangeLog =================================================================== RCS file: /cvsroot/squid-sf//squid/ChangeLog,v retrieving revision 1.1.1.3.6.5.2.6 retrieving revision 1.1.1.3.6.5.2.7 diff -u -r1.1.1.3.6.5.2.6 -r1.1.1.3.6.5.2.7 --- squid/ChangeLog 19 Aug 2000 15:47:24 -0000 1.1.1.3.6.5.2.6 +++ squid/ChangeLog 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.5.2.7 @@ -1,14 +1,9 @@ Changes to Squid-HNO.DEVEL: - - Transfer-Encoding support by Patrick R. McManus/AppliedTheory - The pid file is now delated late in the shutdown process, not when the shutdown starts. This is to allow scripts to monitor the pid file for Squid shutdown. - More fine-grained control of the timeout for persistent connections. - - Use UNIX domain sockets (if available) for inter-process - communiation, rather than TCP/IP on the loopback interface. - - Removal policies now implemented in a modular fashion similar - to the store I/O, and fully isolated from the rest of the code. Changes to Squid-2.4.DEVEL4 (): Index: squid/acconfig.h =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/acconfig.h,v retrieving revision 1.1.1.3.6.5.2.5 retrieving revision 1.1.1.3.6.5.2.6 diff -u -r1.1.1.3.6.5.2.5 -r1.1.1.3.6.5.2.6 --- squid/acconfig.h 15 Jul 2000 20:52:05 -0000 1.1.1.3.6.5.2.5 +++ squid/acconfig.h 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.5.2.6 @@ -20,7 +20,7 @@ * */ @ TOP @ -/* $Id: acconfig.h,v 1.1.1.3.6.5.2.5 2000/07/15 20:52:05 hno Exp $ */ +/* $Id: acconfig.h,v 1.1.1.3.6.5.2.6 2001/01/09 22:02:13 hno Exp $ */ /********************************* * START OF CONFIGURABLE OPTIONS * @@ -270,11 +270,6 @@ #undef HEAP_REPLACEMENT /* - * Use the AppliedTheory compression/decompression library - */ -#undef ATHY_COMPRESSION - -/* * message type for message queues */ #undef mtyp_t Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.1.1.3.6.7.2.22 retrieving revision 1.1.1.3.6.7.2.23 diff -u -r1.1.1.3.6.7.2.22 -r1.1.1.3.6.7.2.23 --- squid/configure.in 4 Oct 2000 10:35:36 -0000 1.1.1.3.6.7.2.22 +++ squid/configure.in 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.7.2.23 @@ -3,13 +3,13 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.1.1.3.6.7.2.22 2000/10/04 10:35:36 hno Exp $ +dnl $Id: configure.in,v 1.1.1.3.6.7.2.23 2001/01/09 22:02:13 hno Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.1.1.3.6.7.2.22 $)dnl +AC_REVISION($Revision: 1.1.1.3.6.7.2.23 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(cfgaux) @@ -590,7 +590,8 @@ dnl Enable Leak Finding Functions AC_ARG_ENABLE(leakfinder, -[ --enable-leakfinder Enable Leak Finding code. Enabling this alone +[ --enable-leakfinder + Enable Leak Finding code. Enabling this alone does nothing; you also have to modify the source code to use the leak finding functions. Probably Useful for hackers only.], @@ -605,7 +606,8 @@ dnl Disable HTTP violations AC_ARG_ENABLE(ident-lookups, -[ --disable-ident-lookups This allows you to remove code that performs +[ --disable-ident-lookups + This allows you to remove code that performs Ident (RFC 931) lookups.], [ if test "$enableval" = "no" ; then echo "Disabling Ident Lookups" @@ -690,17 +692,6 @@ fi AC_SUBST(AUTH_MODULES) -dnl With ATHY_COMPRESSION -AC_ARG_WITH(athy-compression, -[ --with-athy-compression This option makes use of a AppliedTheory compression/ - decompression library to handle compressed transfer - encodings.], -[ if test "$enableval" = "yes" ; then - echo "Enabling ATHY_COMPRESSION" - AC_DEFINE(ATHY_COMPRESSION, 1) - fi -]) - dnl Disable "unlinkd" code AC_ARG_ENABLE(unlinkd, [ --disable-unlinkd Do not use unlinkd], @@ -1207,7 +1198,6 @@ setsid \ sigaction \ snprintf \ - socketpair \ srand48 \ srandom \ statfs \ Index: squid/makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/makefile.in,v retrieving revision 1.1.1.3.6.1.2.2 retrieving revision 1.1.1.3.6.1.2.3 diff -u -r1.1.1.3.6.1.2.2 -r1.1.1.3.6.1.2.3 --- squid/makefile.in 2 May 2000 22:50:27 -0000 1.1.1.3.6.1.2.2 +++ squid/makefile.in 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.1.2.3 @@ -1,4 +1,4 @@ -# $Id: makefile.in,v 1.1.1.3.6.1.2.2 2000/05/02 22:50:27 hno Exp $ +# $Id: makefile.in,v 1.1.1.3.6.1.2.3 2001/01/09 22:02:13 hno Exp $ # srcdir = @srcdir@ @@ -49,11 +49,10 @@ targz: distclean tar cvf current.tar . ; gzip current.tar -# this is perhaps more confusing than it is worth -#makefile: configure config.status makefile.in lib/Makefile.in include/config.h.in src/Makefile.in include/version.h -# @echo "Package configuration updated. Cleaning and reconfiguring" ;\ -# ./config.status --recheck;\ -# ./config.status ;\ -# $(MAKE) $(MFLAGS) clean +makefile: configure config.status makefile.in lib/Makefile.in include/config.h.in src/Makefile.in include/version.h + @echo "Package configuration updated. Cleaning and reconfiguring" ;\ + ./config.status --recheck;\ + ./config.status ;\ + $(MAKE) $(MFLAGS) clean depend: Index: squid/include/version.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/version.h,v retrieving revision 1.1.1.3.10.4.2.1 retrieving revision 1.1.1.3.10.4.2.2 diff -u -r1.1.1.3.10.4.2.1 -r1.1.1.3.10.4.2.2 --- squid/include/version.h 31 Jul 2000 21:30:53 -0000 1.1.1.3.10.4.2.1 +++ squid/include/version.h 9 Jan 2001 22:02:13 -0000 1.1.1.3.10.4.2.2 @@ -1,10 +1,10 @@ /* - * $Id: version.h,v 1.1.1.3.10.4.2.1 2000/07/31 21:30:53 hno Exp $ + * $Id: version.h,v 1.1.1.3.10.4.2.2 2001/01/09 22:02:13 hno Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION -#define SQUID_VERSION "2.4.DEVEL4-hno.devel-CVS" +#define SQUID_VERSION "2.4.DEVEL4" #endif #ifndef SQUID_RELEASE_TIME Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.1.1.3.6.2.2.1 retrieving revision 1.1.1.3.6.2.2.2 diff -u -r1.1.1.3.6.2.2.1 -r1.1.1.3.6.2.2.2 --- squid/src/HttpHeader.c 15 Sep 2000 15:35:37 -0000 1.1.1.3.6.2.2.1 +++ squid/src/HttpHeader.c 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.2.2.2 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.1.1.3.6.2.2.1 2000/09/15 15:35:37 hno Exp $ + * $Id: HttpHeader.c,v 1.1.1.3.6.2.2.2 2001/01/09 22:02:13 hno Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -111,9 +111,7 @@ {"Retry-After", HDR_RETRY_AFTER, ftStr}, /* for now (ftDate_1123 or ftInt!) */ {"Server", HDR_SERVER, ftStr}, {"Set-Cookie", HDR_SET_COOKIE, ftStr}, - {"TE",HDR_TE, ftStr}, {"Title", HDR_TITLE, ftStr}, - {"Transfer-Encoding", HDR_TRANSFER_ENCODING,ftStr}, {"Upgrade", HDR_UPGRADE, ftStr}, /* for now */ {"User-Agent", HDR_USER_AGENT, ftStr}, {"Vary", HDR_VARY, ftStr}, /* for now */ @@ -147,9 +145,7 @@ HDR_IF_MATCH, HDR_IF_NONE_MATCH, HDR_LINK, HDR_PRAGMA, HDR_PROXY_CONNECTION, - /* HDR_EXPECT */ - HDR_TE, - HDR_TRANSFER_ENCODING, + /* HDR_TRANSFER_ENCODING, */ HDR_UPGRADE, HDR_VARY, HDR_VIA, @@ -157,7 +153,7 @@ HDR_WWW_AUTHENTICATE, HDR_AUTHENTICATION_INFO, HDR_PROXY_AUTHENTICATION_INFO, - /* HDR_TRAILER */ + /* HDR_EXPECT, HDR_TE, HDR_TRAILER */ HDR_X_FORWARDED_FOR }; @@ -165,7 +161,7 @@ static http_hdr_type GeneralHeadersArr[] = { HDR_CACHE_CONTROL, HDR_CONNECTION, HDR_DATE, HDR_PRAGMA, - HDR_TRANSFER_ENCODING, + /* HDR_TRANSFER_ENCODING, */ HDR_UPGRADE, /* HDR_TRAILER, */ HDR_VIA @@ -201,7 +197,6 @@ HDR_IF_MATCH, HDR_IF_MODIFIED_SINCE, HDR_IF_NONE_MATCH, HDR_IF_RANGE, HDR_MAX_FORWARDS, HDR_PROXY_CONNECTION, HDR_PROXY_AUTHORIZATION, HDR_RANGE, HDR_REFERER, HDR_REQUEST_RANGE, - HDR_TE, HDR_USER_AGENT, HDR_X_FORWARDED_FOR }; Index: squid/src/HttpHeaderTools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeaderTools.c,v retrieving revision 1.1.1.3.6.2 retrieving revision 1.1.1.3.6.2.2.1 diff -u -r1.1.1.3.6.2 -r1.1.1.3.6.2.2.1 --- squid/src/HttpHeaderTools.c 20 Apr 2000 18:14:21 -0000 1.1.1.3.6.2 +++ squid/src/HttpHeaderTools.c 9 Jan 2001 22:02:13 -0000 1.1.1.3.6.2.2.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.c,v 1.1.1.3.6.2 2000/04/20 18:14:21 hno Exp $ + * $Id: HttpHeaderTools.c,v 1.1.1.3.6.2.2.1 2001/01/09 22:02:13 hno Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -188,38 +188,6 @@ return 0; } -int -strListIsMember_q(const String * list, const char *m, char del) -{ - int rv; - const char *pos = NULL; - const char *item, *l; - int matchsize, len_m; - - assert(list && m); - len_m = strlen(m); - rv = 1000; - - while (strListGetItem(list, del, &item, &matchsize, &pos)) { - if (((l = strchr(item, ';'))) && ((l - item) < matchsize)) { - matchsize = l - item; - /* rtrim again */ - for (l--; (l >= item) && xisspace(*l); matchsize--); - l = strchr(item + matchsize, 'q'); - if (l) - l++; - for (; l && *l && xisspace(*l); l++); - if (l && (*l == '=')) - rv = ((double) atof(l + 1)) * 1000; - - } - - if ((len_m == matchsize) && (!strncasecmp(item, m, matchsize))) - return rv; - } - return 0; -} - /* returns true iff "s" is a substring of a member of the list */ int strListIsSubstr(const String * list, const char *s, char del) Index: squid/src/authenticate.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/authenticate.c,v retrieving revision 1.1.1.3.10.2 retrieving revision 1.1.1.3.10.2.2.1 diff -u -r1.1.1.3.10.2 -r1.1.1.3.10.2.2.1 --- squid/src/authenticate.c 20 Apr 2000 18:14:21 -0000 1.1.1.3.10.2 +++ squid/src/authenticate.c 9 Jan 2001 22:02:13 -0000 1.1.1.3.10.2.2.1 @@ -1,6 +1,6 @@ /* - * $Id: authenticate.c,v 1.1.1.3.10.2 2000/04/20 18:14:21 hno Exp $ + * $Id: authenticate.c,v 1.1.1.3.10.2.2.1 2001/01/09 22:02:13 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -114,7 +114,7 @@ authenticators = helperCreate("authenticator"); authenticators->cmdline = Config.Program.authenticate; authenticators->n_to_start = Config.authenticateChildren; - authenticators->ipc_type = IPC_STREAM; + authenticators->ipc_type = IPC_TCP_SOCKET; helperOpenServers(authenticators); if (!init) { cachemgrRegister("authenticator", Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.10.7.2.18 retrieving revision 1.1.1.3.10.7.2.19 diff -u -r1.1.1.3.10.7.2.18 -r1.1.1.3.10.7.2.19 --- squid/src/client_side.c 4 Oct 2000 10:35:37 -0000 1.1.1.3.10.7.2.18 +++ squid/src/client_side.c 9 Jan 2001 22:02:13 -0000 1.1.1.3.10.7.2.19 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.10.7.2.18 2000/10/04 10:35:37 hno Exp $ + * $Id: client_side.c,v 1.1.1.3.10.7.2.19 2001/01/09 22:02:13 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -62,9 +62,7 @@ #endif #endif -#ifdef ATHY_COMPRESSION -#include -#endif + #if LINGERING_CLOSE #define comm_close comm_lingering_close @@ -748,11 +746,6 @@ } if (http->acl_checklist) aclChecklistFree(http->acl_checklist); - while (http->te_translations) { - TE_list *tf = http->te_translations; - http->te_translations = http->te_translations->next; - xfree (tf); - } if (request) checkFailureRatio(request->err_type, http->al.hier.code); safe_free(http->uri); @@ -1172,566 +1165,6 @@ } } -/* Transfer Encoding Filters: They work like this.. - - filter (a,b,c,d,e) - a - is a character pointer to the data to be filtered - b - is length of a - c - is address of a character pointer where the resulting buffer should be stored - d - pointer to integer to store length of c in - e - pointer to a general data pointer that the filter may use to maintain state, - it begins life as NULL. - -the return value is a 4 bit mask - 0x01 - c is a newly allocated buffer and should be freed when the calling - function has completed the filter - 0x02 - reserved internally for chunking - 0x04 - reserved internally for chunking - 0x08 - set this bit if your funciton was called with input, but did not - produce any (for instance if you're buffering it in the context provided by e.) - prevents squid from thinking EOF has been reached. - - call sequence - first call: *e is NULL but a is not and b>0 - body calls : a is not null, b>0 and value of *e determined by previous calls - last call: b==0.. good time to clean up *e if you've stored stuff there.. you - may produce output if necessary, but last call will be repeated. -*/ - -/* this is a TE filter */ -static int unbiff (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - - *obuf = ibuf; - *obufl = ibufl; - - if (!ibufl) return 0; - - for (;ibufl>0;ibufl--) - if (ibuf[ibufl-1] == 'a') - ibuf[ibufl-1] ='b'; - else - if (ibuf[ibufl-1] == 'b') - ibuf[ibufl-1] ='a'; - return 0; -} - -/* this is a TE filter */ -static int unjones (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - - *obufl = ibufl; - *obuf = ibuf; - - if (!ibufl) return 0; - - for (;ibufl>0;ibufl--) - if (ibuf[ibufl-1] == 'c') - ibuf[ibufl-1] ='b'; - else - if (ibuf[ibufl-1] == 'b') - ibuf[ibufl-1] ='c'; - return 0; -} - -#ifdef ATHY_COMPRESSION - -/* this is a TE filter */ -static int dogzip (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - compression_t *m13; - char *tb; - int tbl, of,created; - - m13 = *((compression_t **) d); - - if (!m13) - { - if (!ibufl) /* no input, nothing to finish.. */ - { - *obufl = 0; - return 0; - } - - m13 = compression_init (COMPRESSION_GZIP,COMPRESSION_STD); - *d = (void *) m13; - } - - tbl = ibufl+512; - tb = xmalloc (tbl); - - if (ibufl > 0) - { - created = 0; - do - { - created += compression_shrink (m13,ibuf,ibufl,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - ibufl = 0; - } - } - while (of>0); - - } - else /* end signal */ - { - created = compression_free (m13,tb); - *d = NULL; - } - - - *obuf = tb; - *obufl = created; - - return 1; -} - -/* this is a TE filter */ -static int undogzip (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - compression_t *m13; - char *tb; - int tbl, of,created; - - m13 = *((compression_t **) d); - if (!m13) - { - m13 = compression_init (COMPRESSION_GZIP,COMPRESSION_STD); - *d = (void *) m13; - } - - tbl = ibufl*2+512; - tb = xmalloc (tbl); - - created = 0; - if (ibuf) - { - do - { - created += compression_expand (m13,ibuf,ibufl,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - ibufl = 0; - } - } - while (of>0); - } - - else - { - do - { - created += compression_finish_expand (m13,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - } - } - while (of > 0); - - compression_free (m13,tb); - *d = NULL; - } - - - *obuf = tb; - *obufl = created; - - return 1; -} - - -/* this is a TE filter */ -static int dodeflate (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - compression_t *m13; - char *tb; - int tbl, of,created; - - m13 = *((compression_t **) d); - - if (!m13) - { - if (!ibufl) /* no input, nothing to finish.. */ - { - *obufl = 0; - return 0; - } - - m13 = compression_init (COMPRESSION_ZLIB,COMPRESSION_STD); - *d = (void *) m13; - } - - tbl = ibufl+512; - tb = xmalloc (tbl); - - if (ibufl > 0) - { - created = 0; - do - { - created += compression_shrink (m13,ibuf,ibufl,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - ibufl = 0; - } - } - while (of>0); - - } - else /* end signal */ - { - created = compression_free (m13,tb); - *d = NULL; - } - - - *obuf = tb; - *obufl = created; - - return 1; -} - -/* this is a TE filter */ -static int undodeflate(char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - compression_t *m13; - char *tb; - int tbl, of,created; - - m13 = *((compression_t **) d); - - if (!m13) - { - m13 = compression_init (COMPRESSION_ZLIB,COMPRESSION_STD); /* rfc 1950 */ - *d = (void *) m13; - } - - tbl = ibufl*2+512; - tb = xmalloc (tbl); - - created = 0; - if (ibuf) - { - do - { - created += compression_expand (m13,ibuf,ibufl,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - ibufl = 0; - } - } - while (of>0); - } - - else - { - do - { - created += compression_finish_expand (m13,tb+created,tbl,&of); - if (of>0) - { - tbl = of+16; - tb = xrealloc (tb,created+tbl); - } - } - while (of > 0); - - compression_free (m13,tb); - *d = NULL; - } - - - *obuf = tb; - *obufl = created; - - return 1; -} - -#endif - -static int hexvalue (char i) -{ - if ((i >= '0') && (i<='9')) - i= i - '0'; - else - i = toupper (i) - 'A' + 10; - return i; -} - - -/* this is a TE filter */ -static int dochunk (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - char *tb, *w; - int tbl, created, rv; - - tbl = ibufl+128; - tb = xmalloc (tbl); - rv = 0x00; - - if (ibufl > 0) - { - created = 0; - snprintf (tb,tbl,"%X\r\n", ibufl); - debug(33, 8) ("created chunk of %d\n",ibufl); - - w = tb + strlen (tb); - memcpy (w,ibuf,ibufl); - created = ibufl + (w-tb) + 2; - strcpy (w+ibufl,"\r\n"); - *d = (void *) 0x01; - } - else /* end signal */ - if (*d) - { - strcpy (tb,"0\r\n\r\n"); - created = 5; - debug(33,8) ("created chunk of %d\n",ibufl); - *d = NULL; - rv = 0x08; - } - else - { - *obuf = tb; - *obufl = 0; - return 0x02 | 0x01; /* signal that dochunk() is complete */ - } - - *obuf = tb; - *obufl = created; - - return rv | 0x01; -} - - -static int undochunked - (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - chunked_t *h; - char *tb, *w, *l; - int tbl, created,rv = 1,tr; - - h = *((chunked_t **) d); - - if (!h) - { - h = xmalloc (sizeof (chunked_t)); - h->state = 1; - *d = (void *) h; - } - - tbl = ibufl; - tb = xmalloc (tbl); - - created = 0; - w=ibuf; - l = ibuf+ibufl; - - state_machine_repeat: - - if (ibufl) - switch (h->state) - { - case 1: /* new chunk */ - h->pos = 0; - h->toread = 0; - h->half_crlf = 0; - - for (; (w < l) && !isxdigit (*w); w++); - if (w>=l) - break; - /* no default break! */ - h->state = 2; /* for 1 fallthru */ - - case 2: /* reading hexl */ - for (; (w < l) && isxdigit (*w); w++) - { - h->toread = h->toread << 4; - h->toread += hexvalue(*w); - } - if (w>=l) - break; - h->state = 3; - h->pos = h->toread; - debug(33,8) ("read chunk of %d\n",h->toread); - - - case 3: /* searching for CRLF */ - do - { - if (!h->half_crlf) - { - for (; (w < l) && (*w != '\r') ; w++); - if (w>=l) - break; - h->half_crlf = 1; - w++; - if (w>=l) - break; - } - if (*w != '\n') - h->half_crlf = 0; - else - { - h->state = 4; - } - w++; - if (w>=l) - break; - }while (h->state == 3); - - case 4: - /* gotta read h->toread bytes */ - if (h->toread) - { - tr = min (h->toread, l-w); - memcpy (tb+created, w, tr); - w += tr; - h->toread -= tr; - created += tr; - } - if (h->toread == 0) - { - h->state = 5; - h->half_crlf = 0; - } - if (w>=l) - break; - - case 5: /* seeking CRLF */ - do - { - if (!h->half_crlf) - { - for (; (w < l) && (*w != '\r') ; w++); - if (w>=l) - break; - h->half_crlf = 1; - w++; - if (w>=l) - break; - } - if (*(w++) != '\n') - h->half_crlf = 0; - else - { - debug(33,8) ("completed %d chunk\n",h->pos); - if (h->pos) - { - h->state = 1; - goto state_machine_repeat; - } - else - { - h->state =6; - h->half_crlf = 2; - } - } - - - - if (w>=l) - break; - }while (h->state == 5); - - case 6: - while (h->half_crlf < 4) - { - if (w>=l) - break; - if (!(h->half_crlf % 2)) - if (*w == '\r') - h->half_crlf++; - else - h->half_crlf =0; - else - if (*w == '\n') - h->half_crlf++; - else - h->half_crlf =0; - w++; - } - - /* chunked complete */ - h->state = 7; - rv = 0x04 | 0x01; /* signal that undochunk() is complete */ - - case 7: /* done, ignore */ - break; - } - else - { - xfree (h); - xfree (tb); - *d = NULL; - *obufl = 0; - return 0; - } - - - *obuf = tb; - *obufl = created; - - return rv; -} - - -/* this is a TE filter */ -int biff (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - /* like ROT13.. symmetrical mappings */ - return unbiff (ibuf,ibufl,obuf,obufl,d); -} - -/* this is a TE filter */ -int jones (char *ibuf, int ibufl, char **obuf, int *obufl, void **d) -{ - /* like ROT13.. symmetrical mappings */ - return unjones (ibuf,ibufl,obuf,obufl,d); -} - - -void new_xlat (clientHttpRequest *http, int beg_or_end, - int (*func)(char *, int , char **, int *, void **), - void *data) -{ - TE_list *tp,*tx; - - tp = xmalloc (sizeof (TE_list)); - tp->func = func; - tp->data = data; - - if (beg_or_end == 0) - { /* beginning */ - tp->next = http->te_translations; - http->te_translations = tp; - } - else - { - /* end */ - tp->next = NULL; - for (tx = http->te_translations; tx && tx->next; tx =tx->next); - if (!tx) /* root node */ - http->te_translations = tp; - else - tx->next = tp; - } - - return; -} - - /* * filters out unwanted entries from original reply header * adds extra entries if we have more info than origin server @@ -1743,16 +1176,6 @@ HttpHeader *hdr = &rep->header; int is_hit = isTcpHit(http->log_type); request_t *request = http->request; - String s_transfer_encoding, s_te, s_ce; - const char *pos = NULL; - const char *item; - int y, may_apply_tes; - HttpHeader *ohdr; - const char *s_ct; - char added_te = 0; - - ohdr = &request->header; - #if DONT_FILTER_THESE /* but you might want to if you run Squid as an HTTP accelerator */ /* httpHeaderDelById(hdr, HDR_ACCEPT_RANGES); */ @@ -1764,149 +1187,6 @@ /* remove Set-Cookie if a hit */ if (is_hit) httpHeaderDelById(hdr, HDR_SET_COOKIE); - may_apply_tes = 0; - - if (httpHeaderHas(hdr, HDR_CONTENT_TYPE)) { - s_ct = httpHeaderGetStr(hdr, HDR_CONTENT_TYPE); - y = strlen(s_ct); - if (((y >= 5) && !strncasecmp(s_ct, "text/", 5)) - || strstr(s_ct, "postscript")) { - may_apply_tes = 1; - debug(33, 8) ("Content-Type of Application: %s\n", s_ct); - if (httpHeaderHas(hdr, HDR_CONTENT_ENCODING)) { - /* oh, base entity might be compressed.. don't want - * to double *that* */ - s_ce = httpHeaderGetList(hdr, HDR_CONTENT_ENCODING); - - if ((strListIsMember(&s_ce, "gzip", ',')) || - (strListIsMember(&s_ce, "deflate", ',')) || - (strListIsMember(&s_ce, "x-deflate", ',')) || - (strListIsMember(&s_ce, "x-gzip", ',')) || - (strListIsMember(&s_ce, "x-compress", ',')) || - (strListIsMember(&s_ce, "compress", ','))) - may_apply_tes |= 0x02; /* 02 is the compress exception */ - - stringClean(&s_ce); - } - } - } - - if (httpHeaderHas(hdr, HDR_TRANSFER_ENCODING)) { - s_transfer_encoding = httpHeaderGetList(hdr, HDR_TRANSFER_ENCODING); - - /* REMOVE ALL TRANSFER ENCODINGS */ - /* order is impt here.. want those entries at end of transfer-encoding - * list to be undone first and they are listed in the order they are - * applied .. TE's are HOP BY HOP */ - - pos = NULL; - while (strListGetItem(&s_transfer_encoding, ',', &item, &y, &pos)) - if (!strncasecmp(item, "biff", y)) { - /* need to remove the TE.. and rewrite the header */ - - debug(33, 7) ("removing biff\n"); - new_xlat(http, 0, unbiff, NULL); - - } else if (!strncasecmp(item, "jones", y)) { - /* need to remove the TE.. and rewrite the header */ - - debug(33, 7) ("removing jones\n"); - new_xlat(http, 0, unjones, NULL); - } -#ifdef ATHY_COMPRESSION - else if (!strncasecmp(item, "gzip", y)) { - /* need to remove the TE.. and rewrite the header */ - - debug(33, 7) ("removing gzip\n"); - new_xlat(http, 0, undogzip, NULL); - } else if (!strncasecmp(item, "deflate", y)) { - /* need to remove the TE.. and rewrite the header */ - - debug(33, 7) ("removing deflate\n"); - new_xlat(http, 0, undodeflate, NULL); - } -#endif - else if (!strncasecmp(item, "chunked", y)) { - /* need to remove the TE.. and rewrite the header */ - - debug(33, 7) ("removing chunked\n"); - new_xlat(http, 0, undochunked, NULL); - } - - - httpHeaderDelById(hdr, HDR_TRANSFER_ENCODING); - stringClean(&s_transfer_encoding); - } - - /* ADD NEW TRANSFER ENCODINGS.. check announcements */ - if (may_apply_tes && httpHeaderHas(ohdr, HDR_TE)) { - char vlb[128]; - vlb[0] = '\0'; - s_te = httpHeaderGetList(ohdr, HDR_TE); - if ((strListIsMember_q(&s_te, "chunked", ',')) || - (request->http_ver > 1.099)) { - /* chunked is known.. we can add te's. */ - - if (strListIsMember_q(&s_te, "biff", ',')) { - debug(33, 7) ("will add biff\n"); - new_xlat(http, 1, biff, NULL); - - if (added_te) - strcat(vlb, ", "); - else - added_te = 1; - strcat(vlb, "biff"); - } - - if (strListIsMember_q(&s_te, "jones", ',')) { - debug(33, 7) ("will add jones\n"); - new_xlat(http, 1, jones, NULL); - - if (added_te) - strcat(vlb, ", "); - else - added_te = 1; - strcat(vlb, "jones"); - } - -#ifdef ATHY_COMPRESSION - if ((strListIsMember_q(&s_te, "deflate", ',')) - && (!(may_apply_tes & 0x02))) { /* the ce: compressed */ - debug(33, 7) ("will add deflate\n"); - new_xlat(http, 1, dodeflate, NULL); - - if (added_te) - strcat(vlb, ", "); - else - added_te = 1; - strcat(vlb, "deflate"); - } - else /* ONLY IF NOT DEFLATE */ if ((strListIsMember_q(&s_te, - "gzip", ',')) - && (!(may_apply_tes & 0x02))) { /* the ce: compressed */ - debug(33, 7) ("will add gzip\n"); - new_xlat(http, 1, dogzip, NULL); - - if (added_te) - strcat(vlb, ", "); - else - added_te = 1; - strcat(vlb, "gzip"); - } -#endif - - if (added_te) { - debug(33, 7) ("will add chunked\n"); - new_xlat(http, 1, dochunk, NULL); - strcat(vlb, ", chunked"); - httpHeaderPutStr(hdr, HDR_TRANSFER_ENCODING, vlb); - httpHeaderDelById(hdr, HDR_CONTENT_LENGTH); - } - - } - stringClean(&s_te); - } - /* handle Connection header */ if (httpHeaderHas(hdr, HDR_CONNECTION)) { /* anything that matches Connection list member will be deleted */ @@ -1974,10 +1254,6 @@ httpHeaderPutStr(hdr, http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION, request->flags.proxy_keepalive ? "keep-alive" : "close"); - - if (added_te) - httpHeaderPutStr(hdr, HDR_CONNECTION, "Transfer-Encoding"); - #if ADD_X_REQUEST_URI /* * Knowing the URI of the request is useful when debugging persistent @@ -2367,47 +1643,6 @@ return 0; } -static int perform_te (TE_list *xlat, char *ibuf, int ibufl, - char **obuf, int *obufl) -{ - int rv = 0, made_new, orig_len; - - *obuf = ibuf; - *obufl = ibufl; - orig_len = ibufl; - - made_new = 0; - - while (xlat) - { - /* xlat func is likely to be unbiff or dogzip() or something */ - - rv &= 0xFE; /* turn off low bit, for reuse, while - preserving chunk indicators */ - - rv |= (*(xlat->func)) ((char *)ibuf, ibufl, obuf, obufl,&(xlat->data)); - - /* FREE SOME STUFF HERE if (rv & 0x01) */ - if ((made_new) && (rv & 0x01)) - xfree (ibuf); - - made_new = made_new | (rv & 0x01); - - ibuf = *obuf; - ibufl = *obufl; - xlat = xlat->next; - } - - if ((rv & 0x08) /* a 0 length chunk was created */ - && (orig_len > 0)) /* and there was actually input */ - { - *obufl = 0; /* don't write the chunk, as it means EOT */ - debug(33,8) ("EOT PREVENTION\n"); - } - - return rv | made_new; -} - /* * accepts chunk of a http message in buf, parses prefix, filters headers and * such, writes processed message to the client's socket @@ -2421,9 +1656,7 @@ int fd = conn->fd; HttpReply *rep = NULL; const char *body_buf = buf; - char *te_body_buf; - ssize_t body_size = size, te_body_size; - int free_te; + ssize_t body_size = size; MemBuf mb; ssize_t check_size = 0; debug(33, 5) ("clientSendMoreData: %s, %d bytes\n", http->uri, (int) size); @@ -2546,24 +1779,7 @@ } else if (body_buf && body_size) { http->out.offset += body_size; check_size += body_size; - if (body_size) - { - http->oldte_rv = free_te = - perform_te (http->te_translations,(char *)body_buf, - body_size, &te_body_buf, &te_body_size); - - - if (te_body_size != body_size) - debug(33,1) ("%s:%d:%d\n",http->log_uri, body_size,te_body_size); - if (te_body_size) - memBufAppend(&mb, te_body_buf, te_body_size); - } - - if (free_te & 0x01) - xfree (te_body_buf); - - if (free_te & 0x04) - http->flags.done_copying = 1; + memBufAppend(&mb, body_buf, body_size); } if (!http->request->range && http->request->method == METHOD_GET) assert(check_size == size); @@ -2638,11 +1854,7 @@ { clientHttpRequest *http = data; StoreEntry *entry = http->entry; - int done, stuckdatasize,free_te; - char *stuck_data; - MemBuf mb; - - stuckdatasize = 0; + int done; http->out.size += size; debug(33, 5) ("clientWriteComplete: FD %d, sz %d, err %d, off %d, len %d\n", fd, size, errflag, (int) http->out.offset, entry ? objectLen(entry) : 0); @@ -2660,36 +1872,9 @@ comm_close(fd); /* yuk */ } else if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(fd); - } else if ((done = clientCheckTransferDone(http)) != 0 || - (size == 0 && !(http->oldte_rv & 0x08))) { + } else if ((done = clientCheckTransferDone(http)) != 0 || size == 0) { debug(33, 5) ("clientWriteComplete: FD %d transfer is DONE\n", fd); /* We're finished case */ - http->oldte_rv = free_te = perform_te (http->te_translations,NULL,0, - &stuck_data, &stuckdatasize); - if (stuckdatasize > 0) - { - debug(33,1) ("%s:0:%d\n",http->log_uri,stuckdatasize); - - memBufDefInit(&mb); - memBufAppend(&mb, stuck_data, stuckdatasize); - - comm_write_mbuf(fd, mb, clientWriteComplete, http); - - /* don't need this, as write may happen async, it's dangerous - too.. plus, it is done after the write but the hook function - within it */ - /* memBufClean(&mb); */ - - - if (free_te & 0x01) - xfree (stuck_data); - return; - } - if (free_te & 0x02) /* signal from dochunk() that - data has been chunked */ - { - http->flags.done_copying = 1; - } if (httpReplyBodySize(http->request->method, entry->mem_obj->reply) < 0) { debug(33, 5) ("clientWriteComplete: closing, content_length < 0\n"); comm_close(fd); @@ -2710,7 +1895,6 @@ } else { /* More data will be coming from primary server; register with * storage manager. */ - http->oldte_rv = 0x00; if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) debug(33, 0) ("clientWriteComplete 2: ENTRY_ABORTED\n"); storeClientCopy(http->sc, entry, @@ -2721,7 +1905,6 @@ clientSendMoreData, http); } - } /* @@ -3299,9 +2482,10 @@ } /* * Don't reset the timeout value here. The timeout value will be - * set to by httpAccept() and clientWriteComplete(), and should - * apply to the request headers as a whole, not individual read() - * calls. Plus, it breaks our lame half-close detection + * set to Config.Timeout.request by httpAccept() and + * clientWriteComplete(), and should apply to the request as a + * whole, not individual read() calls. Plus, it breaks our + * lame half-close detection */ commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, conn, 0); if (size == 0) { @@ -3650,7 +2834,6 @@ #define SENDING_BODY 0 #define SENDING_HDRSONLY 1 -/* checks status of sending to original client */ static int clientCheckTransferDone(clientHttpRequest * http) { Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.1.1.3.10.3.2.1 retrieving revision 1.1.1.3.10.3.2.2 diff -u -r1.1.1.3.10.3.2.1 -r1.1.1.3.10.3.2.2 --- squid/src/defines.h 31 Jul 2000 21:30:53 -0000 1.1.1.3.10.3.2.1 +++ squid/src/defines.h 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.3.2.2 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.1.1.3.10.3.2.1 2000/07/31 21:30:53 hno Exp $ + * $Id: defines.h,v 1.1.1.3.10.3.2.2 2001/01/09 22:02:14 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -192,16 +192,6 @@ #define IPC_TCP_SOCKET 1 #define IPC_UDP_SOCKET 2 #define IPC_FIFO 3 -#define IPC_UNIX_STREAM 4 -#define IPC_UNIX_DGRAM 5 - -#if HAVE_SOCKETPAIR && defined (AF_UNIX) -#define IPC_STREAM IPC_UNIX_STREAM -#define IPC_DGRAM IPC_UNIX_DGRAM -#else -#define IPC_STREAM IPC_TCP_SOCKET -#define IPC_DGRAM IPC_UDP_SOCKET -#endif #define STORE_META_KEY STORE_META_KEY_MD5 Index: squid/src/dns.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/dns.c,v retrieving revision 1.1.1.3.10.2.2.3 retrieving revision 1.1.1.3.10.2.2.4 diff -u -r1.1.1.3.10.2.2.3 -r1.1.1.3.10.2.2.4 --- squid/src/dns.c 12 Jun 2000 10:26:06 -0000 1.1.1.3.10.2.2.3 +++ squid/src/dns.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.2.2.4 @@ -1,6 +1,6 @@ /* - * $Id: dns.c,v 1.1.1.3.10.2.2.3 2000/06/12 10:26:06 hno Exp $ + * $Id: dns.c,v 1.1.1.3.10.2.2.4 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -54,7 +54,7 @@ if (dnsservers == NULL) dnsservers = helperCreate("dnsserver"); dnsservers->n_to_start = Config.dnsChildren; - dnsservers->ipc_type = IPC_STREAM; + dnsservers->ipc_type = IPC_TCP_SOCKET; assert(dnsservers->cmdline == NULL); wordlistAdd(&dnsservers->cmdline, Config.Program.dnsserver); if (Config.onoff.res_defnames) @@ -90,10 +90,6 @@ { char buf[256]; snprintf(buf, 256, "%s\n", lookup); - if (dnsservers->stats.queue_size > dnsservers->n_running * 2) { - callback(data, "$fail temporary network problem, pleas retry later"); - debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup); - } else helperSubmit(dnsservers, buf, callback, data); } Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.1.1.3.10.5.2.6 retrieving revision 1.1.1.3.10.5.2.7 diff -u -r1.1.1.3.10.5.2.6 -r1.1.1.3.10.5.2.7 --- squid/src/enums.h 4 Oct 2000 10:35:37 -0000 1.1.1.3.10.5.2.6 +++ squid/src/enums.h 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.5.2.7 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.1.1.3.10.5.2.6 2000/10/04 10:35:37 hno Exp $ + * $Id: enums.h,v 1.1.1.3.10.5.2.7 2001/01/09 22:02:14 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -214,9 +214,7 @@ HDR_RETRY_AFTER, HDR_SERVER, HDR_SET_COOKIE, - HDR_TE, HDR_TITLE, - HDR_TRANSFER_ENCODING, HDR_UPGRADE, HDR_USER_AGENT, HDR_VARY, Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.1.1.3.10.4.2.5 retrieving revision 1.1.1.3.10.4.2.6 diff -u -r1.1.1.3.10.4.2.5 -r1.1.1.3.10.4.2.6 --- squid/src/http.c 16 Jul 2000 12:54:02 -0000 1.1.1.3.10.4.2.5 +++ squid/src/http.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.4.2.6 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.1.1.3.10.4.2.5 2000/07/16 12:54:02 hno Exp $ + * $Id: http.c,v 1.1.1.3.10.4.2.6 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -485,7 +485,6 @@ statCounter.syscalls.sock.reads++; len = read(fd, buf, read_sz); debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, len); - if (len > 0) { fd_bytes(fd, len, FD_READ); #if DELAY_POOLS @@ -744,24 +743,6 @@ if (Config.fake_ua && !httpHeaderHas(hdr_out, HDR_USER_AGENT)) httpHeaderPutStr(hdr_out, HDR_USER_AGENT, Config.fake_ua); - /* append TE */ - { - char strTE[128]; - - httpHeaderDelById(hdr_out, HDR_TE); /* hop by hop.. that's what last - hop could do*/ -#ifdef ATHY_COMPRESSION - strcpy (strTE,"biff;q=0.0, gzip;q=1.0, deflate;q=1.0, jones;q=0.0, chunked;q=1.0"); -#else - strcpy (strTE,"biff;q=1.0, gzip;q=0.0, deflate;q=0.0, jones;q=1.0, chunked;q=1.0"); -#endif - - httpHeaderPutStr (hdr_out,HDR_TE,strTE); - httpHeaderPutStr(hdr_out,HDR_CONNECTION, "TE"); /* its hop by hop */ - - } - - /* append Via */ if (httpRequestHdrAllowedByName(HDR_VIA)) { String strVia = httpHeaderGetList(hdr_in, HDR_VIA); Index: squid/src/icmp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/icmp.c,v retrieving revision 1.1.1.2.12.2.2.2 retrieving revision 1.1.1.2.12.2.2.3 diff -u -r1.1.1.2.12.2.2.2 -r1.1.1.2.12.2.2.3 --- squid/src/icmp.c 1 Jul 2000 12:20:15 -0000 1.1.1.2.12.2.2.2 +++ squid/src/icmp.c 9 Jan 2001 22:02:14 -0000 1.1.1.2.12.2.2.3 @@ -1,6 +1,6 @@ /* - * $Id: icmp.c,v 1.1.1.2.12.2.2.2 2000/07/01 12:20:15 hno Exp $ + * $Id: icmp.c,v 1.1.1.2.12.2.2.3 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -196,7 +196,7 @@ int wfd; args[0] = "(pinger)"; args[1] = NULL; - x = ipcCreate(IPC_DGRAM, + x = ipcCreate(IPC_UDP_SOCKET, Config.Program.pinger, args, "Pinger Socket", @@ -206,7 +206,6 @@ return; assert(rfd == wfd); icmp_sock = rfd; - fd_note (icmp_sock, "pinger"); commSetSelect(icmp_sock, COMM_SELECT_READ, icmpRecv, NULL, 0); commSetTimeout(icmp_sock, -1, NULL, NULL); debug(29, 1) ("Pinger socket opened on FD %d\n", icmp_sock); Index: squid/src/ipc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipc.c,v retrieving revision 1.1.1.3.10.4.2.1 retrieving revision 1.1.1.3.10.4.2.2 diff -u -r1.1.1.3.10.4.2.1 -r1.1.1.3.10.4.2.2 --- squid/src/ipc.c 14 May 2000 23:22:19 -0000 1.1.1.3.10.4.2.1 +++ squid/src/ipc.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.4.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ipc.c,v 1.1.1.3.10.4.2.1 2000/05/14 23:22:19 hno Exp $ + * $Id: ipc.c,v 1.1.1.3.10.4.2.2 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -123,29 +123,6 @@ fd_open(cwfd = p2c[1], FD_PIPE, "IPC FIFO Child Write"); fd_open(crfd = c2p[0], FD_PIPE, "IPC FIFO Child Read"); fd_open(pwfd = c2p[1], FD_PIPE, "IPC FIFO Parent Write"); -#if HAVE_SOCKETPAIR && defined(AF_UNIX) - } else if (type == IPC_UNIX_STREAM) { - int fds[2]; - int buflen = 32768; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { - debug(50, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); - return -1; - } - setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, (void *)&buflen, sizeof(buflen)); - setsockopt(fds[0], SOL_SOCKET, SO_RCVBUF, (void *)&buflen, sizeof(buflen)); - setsockopt(fds[1], SOL_SOCKET, SO_SNDBUF, (void *)&buflen, sizeof(buflen)); - setsockopt(fds[1], SOL_SOCKET, SO_RCVBUF, (void *)&buflen, sizeof(buflen)); - fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX STREAM Parent"); - fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX STREAM Parent"); - } else if (type == IPC_UNIX_DGRAM) { - int fds[2]; - if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) < 0) { - debug(50, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); - return -1; - } - fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX DGRAM Parent"); - fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX DGRAM Parent"); -#endif } else { assert(IPC_NONE); } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.1.1.3.10.8.2.10 retrieving revision 1.1.1.3.10.8.2.11 diff -u -r1.1.1.3.10.8.2.10 -r1.1.1.3.10.8.2.11 --- squid/src/protos.h 4 Oct 2000 10:35:37 -0000 1.1.1.3.10.8.2.10 +++ squid/src/protos.h 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.8.2.11 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.10.8.2.10 2000/10/04 10:35:37 hno Exp $ + * $Id: protos.h,v 1.1.1.3.10.8.2.11 2001/01/09 22:02:14 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -372,7 +372,6 @@ extern void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, ssize_t); extern void strListAdd(String * str, const char *item, char del); extern int strListIsMember(const String * str, const char *item, char del); -extern int strListIsMember_q (const String * list, const char *m, char del); extern int strListIsSubstr(const String * list, const char *s, char del); extern int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos); extern const char *getStringPrefix(const char *str, const char *end); Index: squid/src/redirect.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/redirect.c,v retrieving revision 1.1.1.3.10.3 retrieving revision 1.1.1.3.10.3.2.1 diff -u -r1.1.1.3.10.3 -r1.1.1.3.10.3.2.1 --- squid/src/redirect.c 20 Apr 2000 18:14:23 -0000 1.1.1.3.10.3 +++ squid/src/redirect.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.3.2.1 @@ -1,6 +1,6 @@ /* - * $Id: redirect.c,v 1.1.1.3.10.3 2000/04/20 18:14:23 hno Exp $ + * $Id: redirect.c,v 1.1.1.3.10.3.2.1 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -158,7 +158,7 @@ redirectors = helperCreate("redirector"); redirectors->cmdline = Config.Program.redirect; redirectors->n_to_start = Config.redirectChildren; - redirectors->ipc_type = IPC_STREAM; + redirectors->ipc_type = IPC_TCP_SOCKET; helperOpenServers(redirectors); if (!init) { cachemgrRegister("redirector", Index: squid/src/store_swapout.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapout.c,v retrieving revision 1.1.1.3.10.5.2.7 retrieving revision 1.1.1.3.10.5.2.8 diff -u -r1.1.1.3.10.5.2.7 -r1.1.1.3.10.5.2.8 --- squid/src/store_swapout.c 19 Aug 2000 15:47:25 -0000 1.1.1.3.10.5.2.7 +++ squid/src/store_swapout.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.5.2.8 @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.c,v 1.1.1.3.10.5.2.7 2000/08/19 15:47:25 hno Exp $ + * $Id: store_swapout.c,v 1.1.1.3.10.5.2.8 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -280,7 +280,7 @@ assert(e->swap_status == SWAPOUT_WRITING); cbdataFree(c); if (errflag) { - debug(20, 3) ("storeSwapOutFileClosed: dirno %d, swapfile %08X, errflag=%d\n\t%s\n", + debug(20, 1) ("storeSwapOutFileClosed: dirno %d, swapfile %08X, errflag=%d\n\t%s\n", e->swap_dirn, e->swap_filen, errflag, xstrerror()); if (errflag == DISK_NO_SPACE_LEFT) { storeDirDiskFull(e->swap_dirn); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.10.8.2.15 retrieving revision 1.1.1.3.10.8.2.16 diff -u -r1.1.1.3.10.8.2.15 -r1.1.1.3.10.8.2.16 --- squid/src/structs.h 4 Oct 2000 10:35:37 -0000 1.1.1.3.10.8.2.15 +++ squid/src/structs.h 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.8.2.16 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.10.8.2.15 2000/10/04 10:35:37 hno Exp $ + * $Id: structs.h,v 1.1.1.3.10.8.2.16 2001/01/09 22:02:14 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -858,16 +858,6 @@ HierarchyLogEntry hier; }; - -typedef struct _TE_list -{ - int (*func)(char *ibuf, int ibufl, char **obuf, int *obufl, void **data); - void *data; - struct _TE_list *next; -} -TE_list; - - struct _clientHttpRequest { ConnStateData *conn; request_t *request; /* Parsed URL ... */ @@ -903,8 +893,6 @@ char *location; } redirect; dlink_node active; - TE_list *te_translations; - int oldte_rv; }; struct _ConnStateData { @@ -1870,16 +1858,6 @@ STFSSHUTDOWN *donefunc; }; -typedef struct chunked_tag -{ - int state; /* 1 - in between */ - int pos; /* 2 - reading hexl */ - int toread; /* 3 - seeking CRLF from hexl */ - int half_crlf; /* 4 - reading data */ - /* 5 - seeking CRLF from data */ - /* 6 - looking for double CRLF */ -} chunked_t; - /* * This defines an repl type */ Index: squid/src/unlinkd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/unlinkd.c,v retrieving revision 1.1.1.3.10.3.2.6 retrieving revision 1.1.1.3.10.3.2.7 diff -u -r1.1.1.3.10.3.2.6 -r1.1.1.3.10.3.2.7 --- squid/src/unlinkd.c 1 Jul 2000 12:20:15 -0000 1.1.1.3.10.3.2.6 +++ squid/src/unlinkd.c 9 Jan 2001 22:02:14 -0000 1.1.1.3.10.3.2.7 @@ -1,6 +1,6 @@ /* - * $Id: unlinkd.c,v 1.1.1.3.10.3.2.6 2000/07/01 12:20:15 hno Exp $ + * $Id: unlinkd.c,v 1.1.1.3.10.3.2.7 2001/01/09 22:02:14 hno Exp $ * * DEBUG: section 12 Unlink Daemon * AUTHOR: Duane Wessels @@ -164,7 +164,12 @@ struct timeval slp; args[0] = "(unlinkd)"; args[1] = NULL; - x = ipcCreate(IPC_STREAM, +#if HAVE_POLL && defined(_SQUID_OSF_) + /* pipes and poll() don't get along on DUNIX -DW */ + x = ipcCreate(IPC_TCP_SOCKET, +#else + x = ipcCreate(IPC_FIFO, +#endif Config.Program.unlinkd, args, "unlinkd", Index: squid/src/fs/aufs/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/Attic/Makefile.in,v retrieving revision 1.1.6.3.2.2 retrieving revision 1.1.6.3.2.3 diff -u -r1.1.6.3.2.2 -r1.1.6.3.2.3 --- squid/src/fs/aufs/Makefile.in 16 Sep 2000 20:47:58 -0000 1.1.6.3.2.2 +++ squid/src/fs/aufs/Makefile.in 9 Jan 2001 22:02:14 -0000 1.1.6.3.2.3 @@ -36,7 +36,6 @@ $(RANLIB) $(OUT) $(OBJS): $(top_srcdir)/include/version.h ../../../include/autoconf.h -$(OBJS): store_asyncufs.h .c.o: @rm -f ../stamp Index: squid/src/fs/aufs/aiops.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/aiops.c,v retrieving revision 1.1.6.1.2.5 retrieving revision 1.1.6.1.2.6 diff -u -r1.1.6.1.2.5 -r1.1.6.1.2.6 --- squid/src/fs/aufs/aiops.c 16 Sep 2000 22:09:38 -0000 1.1.6.1.2.5 +++ squid/src/fs/aufs/aiops.c 9 Jan 2001 22:02:14 -0000 1.1.6.1.2.6 @@ -49,6 +49,13 @@ #define RIDICULOUS_LENGTH 4096 +#if defined(_SQUID_LINUX_) +/* Linux requires proper use of mutexes or it will segfault deep in the + * thread libraries. Observed on Alpha SMP Linux 2.2.10-ac12. + */ +#define AIO_PROPER_MUTEX 1 +#endif + enum _aio_thread_status { _THREAD_STARTING = 0, _THREAD_WAITING, @@ -70,7 +77,6 @@ }; typedef struct aio_request_t { - struct aio_request_t *next; enum _aio_request_type request_type; int cancelled; char *path; @@ -87,25 +93,20 @@ struct stat *tmpstatp; struct stat *statp; aio_result_t *resultp; + struct aio_request_t *next; } aio_request_t; -typedef struct aio_request_queue_t { - pthread_mutex_t mutex; - pthread_cond_t cond; - aio_request_t *head; - aio_request_t **tailp; - unsigned long requests; - unsigned long blocked; /* main failed to lock the queue */ -} aio_request_queue_t; - -typedef struct aio_thread_t aio_thread_t; -struct aio_thread_t { - aio_thread_t *next; + +typedef struct aio_thread_t { pthread_t thread; enum _aio_thread_status status; - struct aio_request_t *current_req; - unsigned long requests; -}; + pthread_mutex_t mutex; /* Mutex for testing condition variable */ + pthread_cond_t cond; /* Condition variable */ + struct aio_request_t *volatile req; /* set by main, cleared by thread */ + struct aio_request_t *processed_req; /* reminder to main */ + struct aio_thread_t *next; +} aio_thread_t; + int aio_cancel(aio_result_t *); int aio_open(const char *, int, mode_t, aio_result_t *); @@ -120,6 +121,7 @@ static void aio_init(void); static void aio_queue_request(aio_request_t *); +static void aio_process_request_queue(void); static void aio_cleanup_request(aio_request_t *); static void *aio_thread_loop(void *); static void aio_do_open(aio_request_t *); @@ -133,21 +135,23 @@ static void *aio_do_opendir(aio_request_t *); #endif static void aio_debug(aio_request_t *); -static void aio_poll_queues(void); +static void aio_poll_threads(void); +static aio_thread_t *threads; static int aio_initialised = 0; static int request_queue_len = 0; static MemPool *aio_request_pool = NULL; -static MemPool *aio_thread_pool = NULL; -static aio_request_queue_t request_queue; -static struct { aio_request_t *head, **tailp; } request_queue2 = { NULL, &request_queue2.head }; -static aio_request_queue_t done_queue; -static struct { aio_request_t *head, **tailp; } done_requests = { NULL, &done_requests.head }; +static aio_request_t *request_queue_head = NULL; +static aio_request_t *request_queue_tail = NULL; +static aio_request_t *request_done_head = NULL; +static aio_request_t *request_done_tail = NULL; +static aio_thread_t *wait_threads = NULL; +static aio_thread_t *busy_threads_head = NULL; +static aio_thread_t *busy_threads_tail = NULL; static pthread_attr_t globattr; static struct sched_param globsched; static pthread_t main_thread; -static aio_thread_t *threads = NULL; static void aio_init(void) @@ -171,47 +175,33 @@ #if HAVE_PTHREAD_ATTR_SETSCHEDPARAM pthread_attr_setschedparam(&globattr, &globsched); #endif - - /* Initialize request queue */ - if (pthread_mutex_init(&(request_queue.mutex), NULL)) - fatal("Failed to create mutex"); - if (pthread_cond_init(&(request_queue.cond), NULL)) - fatal("Failed to create condition variable"); - request_queue.head = NULL; - request_queue.tailp = &request_queue.head; - request_queue.requests = 0; - request_queue.blocked = 0; - - /* Initialize request2 queue for temporary storage - * when request_queue is blocked - */ - request_queue2.head = NULL; - request_queue2.tailp = &request_queue.head; - - /* Initialize done queue */ - if (pthread_mutex_init(&(done_queue.mutex), NULL)) - fatal("Failed to create mutex"); - if (pthread_cond_init(&(done_queue.cond), NULL)) - fatal("Failed to create condition variable"); - done_queue.head = NULL; - done_queue.tailp = &done_queue.head; - done_queue.requests = 0; - done_queue.blocked = 0; /* Create threads and get them to sit in their wait loop */ - aio_thread_pool = memPoolCreate("aio_thread", sizeof(aio_thread_t)); + threads = xcalloc(NUMTHREADS, sizeof(aio_thread_t)); + for (i = 0; i < NUMTHREADS; i++) { - threadp = memPoolAlloc(aio_thread_pool); + threadp = &threads[i]; threadp->status = _THREAD_STARTING; - threadp->current_req = NULL; - threadp->requests = 0; - threadp->next = threads; - threads = threadp; + if (pthread_mutex_init(&(threadp->mutex), NULL)) { + threadp->status = _THREAD_FAILED; + continue; + } + if (pthread_cond_init(&(threadp->cond), NULL)) { + threadp->status = _THREAD_FAILED; + continue; + } + threadp->req = NULL; + threadp->processed_req = NULL; if (pthread_create(&threadp->thread, &globattr, aio_thread_loop, threadp)) { fprintf(stderr, "Thread creation failed\n"); threadp->status = _THREAD_FAILED; continue; } + threadp->next = wait_threads; + wait_threads = threadp; +#if AIO_PROPER_MUTEX + pthread_mutex_lock(&threadp->mutex); +#endif } /* Create request pool */ @@ -227,6 +217,9 @@ aio_thread_t *threadp = ptr; aio_request_t *request; sigset_t new; +#if !AIO_PROPER_MUTEX + struct timespec wait_time; +#endif /* * Make sure to ignore signals which may possibly get sent to @@ -250,25 +243,29 @@ sigaddset(&new, SIGALRM); pthread_sigmask(SIG_BLOCK, &new, NULL); + pthread_mutex_lock(&threadp->mutex); while (1) { - threadp->current_req = request = NULL; - request = NULL; - /* Get a request to process */ - threadp->status = _THREAD_WAITING; - pthread_mutex_lock(&request_queue.mutex); - while(!request_queue.head) { - pthread_cond_wait(&request_queue.cond, &request_queue.mutex); - } - request = request_queue.head; - if (request) - request_queue.head = request->next; - if (!request_queue.head) - request_queue.tailp = &request_queue.head; - pthread_mutex_unlock(&request_queue.mutex); - /* process the request */ - threadp->status = _THREAD_BUSY; - request->next = NULL; - threadp->current_req = request; +#if AIO_PROPER_MUTEX + while (threadp->req == NULL) { + threadp->status = _THREAD_WAITING; + pthread_cond_wait(&threadp->cond, &threadp->mutex); + } +#else + /* The timeout is used to unlock the race condition where + * ->req is set between the check and pthread_cond_wait. + * The thread steps it's own clock on each timeout, to avoid a CPU + * spin situation if the main thread is suspended (paging), and + * squid_curtime is not being updated timely. + */ + wait_time.tv_sec = squid_curtime + 1; /* little quicker first time */ + wait_time.tv_nsec = 0; + while (threadp->req == NULL) { + threadp->status = _THREAD_WAITING; + pthread_cond_timedwait(&threadp->cond, &threadp->mutex, &wait_time); + wait_time.tv_sec += 3; /* then wait 3 seconds between each check */ + } +#endif + request = threadp->req; errno = 0; if (!request->cancelled) { switch (request->request_type) { @@ -307,67 +304,51 @@ request->ret = -1; request->err = EINTR; } - threadp->status = _THREAD_DONE; - /* put the request in the done queue */ - pthread_mutex_lock(&done_queue.mutex); - *done_queue.tailp = request; - done_queue.tailp = &request->next; - pthread_mutex_unlock(&done_queue.mutex); - threadp->requests++; - } /* while forever */ + threadp->req = NULL; /* tells main thread that we are done */ + } /* while */ return NULL; } /* aio_thread_loop */ static void -aio_queue_request(aio_request_t * request) +aio_do_request(aio_request_t * requestp) { + if (wait_threads == NULL && busy_threads_head == NULL) { + fprintf(stderr, "PANIC: No threads to service requests with!\n"); + exit(-1); + } + aio_queue_request(requestp); +} /* aio_do_request */ + + +static void +aio_queue_request(aio_request_t * requestp) +{ + aio_request_t *rp; static int last_warn = 0; static int high_start = 0; static int queue_high, queue_low; + int i; - debug(41, 9) ("aio_queue_request: %p type=%d result=%p\n", - request, request->request_type, request->resultp); /* Mark it as not executed (failing result, no error) */ - request->ret = -1; - request->err = 0; - /* Internal housekeeping */ - request_queue_len += 1; - request->resultp->_data = request; - /* Play some tricks with the request_queue2 queue */ - request->next = NULL; - if (!request_queue2.head) { - if (pthread_mutex_trylock(&request_queue.mutex) == 0) { - /* Normal path */ - *request_queue.tailp = request; - request_queue.tailp = &request->next; - pthread_cond_signal(&request_queue.cond); - pthread_mutex_unlock(&request_queue.mutex); - } else { - /* Oops, the request queue is blocked, use request_queue2 */ - *request_queue2.tailp = request; - request_queue2.tailp = &request->next; - } + requestp->ret = -1; + requestp->err = 0; + /* Queue it on the request queue */ + if (request_queue_head == NULL) { + request_queue_head = requestp; + request_queue_tail = requestp; } else { - /* Secondary path. We have blocked requests to deal with */ - /* add the request to the chain */ - *request_queue2.tailp = request; - if (pthread_mutex_trylock(&request_queue.mutex) == 0) { - /* Ok, the queue is no longer blocked */ - *request_queue.tailp = request_queue2.head; - request_queue.tailp = &request->next; - pthread_cond_signal(&request_queue.cond); - pthread_mutex_unlock(&request_queue.mutex); - request_queue2.head = NULL; - request_queue2.tailp = &request_queue2.head; - } else { - /* still blocked, bump the blocked request chain */ - request_queue2.tailp = &request->next; - } + request_queue_tail->next = requestp; + request_queue_tail = requestp; } - if (request_queue2.head) - debug(43, 1) ("aio_queue_request: WARNING - Queue congestion\n"); + requestp->next = NULL; + request_queue_len += 1; + /* Poll done threads if needed */ + if (wait_threads == NULL) + aio_poll_threads(); + /* Kick it rolling */ + aio_process_request_queue(); /* Warn if out of threads */ - if (request_queue_len > MAGIC1) { + if (request_queue_len > (NUMTHREADS >> 1)) { if (high_start == 0) { high_start = squid_curtime; queue_high = request_queue_len; @@ -378,14 +359,43 @@ if (request_queue_len < queue_low) queue_low = request_queue_len; if (squid_curtime >= (last_warn + 15) && - squid_curtime >= (high_start + 5)) { - debug(43, 1) ("aio_queue_request: WARNING - Disk I/O overloading\n"); - if (squid_curtime >= (high_start + 15)) { - debug(43, 1) ("aio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%d\n", + squid_curtime >= (high_start + 3)) { + debug(43, 1) ("aio_queue_request: WARNING - Running out of I/O threads\n"); + debug(43, 2) ("aio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%d\n", request_queue_len, queue_high, queue_low, squid_curtime - high_start); - debug(43, 1) ("aio_queue_request: Perhaps you should increase NUMTHREADS,\n"); - debug(43, 1) ("aio_queue_request: install more disks to share the loadr\n"); - debug(43, 1) ("aio_queue_request: or add a second CPU for the I/O\n"); + debug(43, 1) ("aio_queue_request: Perhaps you should increase NUMTHREADS\n"); + debug(43, 1) ("aio_queue_request: Or install more disks to share the load\n"); + debug(43, 3) ("aio_queue_request: First %d items on request queue\n", NUMTHREADS); + rp = request_queue_head; + for (i = 1; i <= NUMTHREADS; i++) { + switch (rp->request_type) { + case _AIO_OP_OPEN: + debug(43, 3) ("aio_queue_request: %d : open -> %s\n", i, rp->path); + break; + case _AIO_OP_READ: + debug(43, 3) ("aio_queue_request: %d : read -> FD = %d\n", i, rp->fd); + break; + case _AIO_OP_WRITE: + debug(43, 3) ("aio_queue_request: %d : write -> FD = %d\n", i, rp->fd); + break; + case _AIO_OP_CLOSE: + debug(43, 3) ("aio_queue_request: %d : close -> FD = %d\n", i, rp->fd); + break; + case _AIO_OP_UNLINK: + debug(43, 3) ("aio_queue_request: %d : unlink -> %s\n", i, rp->path); + break; + case _AIO_OP_TRUNCATE: + debug(43, 3) ("aio_queue_request: %d : truncate -> %s\n", i, rp->path); + break; + case _AIO_OP_STAT: + debug(43, 3) ("aio_queue_request: %d : stat -> %s\n", i, rp->path); + break; + default: + debug(43, 1) ("aio_queue_request: %d : Unimplemented request type: %d\n", i, rp->request_type); + break; + } + if ((rp = rp->next) == NULL) + break; } last_warn = squid_curtime; } @@ -400,66 +410,117 @@ } } /* aio_queue_request */ + +static void +aio_process_request_queue(void) +{ + aio_thread_t *threadp; + aio_request_t *requestp; + + for (;;) { + if (wait_threads == NULL || request_queue_head == NULL) + return; + + requestp = request_queue_head; + if ((request_queue_head = requestp->next) == NULL) + request_queue_tail = NULL; + requestp->next = NULL; + request_queue_len--; + + if (requestp->cancelled) { + aio_cleanup_request(requestp); + continue; + } + threadp = wait_threads; + wait_threads = threadp->next; + threadp->next = NULL; + + if (busy_threads_head != NULL) + busy_threads_tail->next = threadp; + else + busy_threads_head = threadp; + busy_threads_tail = threadp; + + threadp->status = _THREAD_BUSY; + threadp->req = threadp->processed_req = requestp; + pthread_cond_signal(&(threadp->cond)); +#if AIO_PROPER_MUTEX + pthread_mutex_unlock(&threadp->mutex); +#endif + } +} /* aio_process_request_queue */ + + static void -aio_cleanup_request(aio_request_t * request) +aio_cleanup_request(aio_request_t * requestp) { - aio_result_t *resultp = request->resultp; - int cancelled = request->cancelled; + aio_result_t *resultp = requestp->resultp; + int cancelled = requestp->cancelled; /* Free allocated structures and copy data back to user space if the */ /* request hasn't been cancelled */ - switch (request->request_type) { + switch (requestp->request_type) { case _AIO_OP_STAT: - if (!cancelled && request->ret == 0) - xmemcpy(request->statp, request->tmpstatp, sizeof(struct stat)); - xfree(request->tmpstatp); + if (!cancelled && requestp->ret == 0) + xmemcpy(requestp->statp, requestp->tmpstatp, sizeof(struct stat)); + xfree(requestp->tmpstatp); case _AIO_OP_OPEN: - if (cancelled && request->ret >= 0) + if (cancelled && requestp->ret >= 0) /* The open() was cancelled but completed */ - close(request->ret); - xfree(request->path); + close(requestp->ret); + xfree(requestp->path); break; case _AIO_OP_CLOSE: - if (cancelled && request->ret < 0) + if (cancelled && requestp->ret < 0) /* The close() was cancelled and never got executed */ - close(request->fd); + close(requestp->fd); break; case _AIO_OP_UNLINK: case _AIO_OP_TRUNCATE: case _AIO_OP_OPENDIR: - xfree(request->path); + xfree(requestp->path); break; case _AIO_OP_READ: - if (!cancelled && request->ret > 0) - xmemcpy(request->bufferp, request->tmpbufp, request->ret); - xfree(request->tmpbufp); - break; + if (!cancelled && requestp->ret > 0) + xmemcpy(requestp->bufferp, requestp->tmpbufp, requestp->ret); case _AIO_OP_WRITE: + xfree(requestp->tmpbufp); break; default: break; } if (resultp != NULL && !cancelled) { - resultp->aio_return = request->ret; - resultp->aio_errno = request->err; + resultp->aio_return = requestp->ret; + resultp->aio_errno = requestp->err; } - memPoolFree(aio_request_pool, request); + memPoolFree(aio_request_pool, requestp); } /* aio_cleanup_request */ int aio_cancel(aio_result_t * resultp) { - aio_request_t *request = resultp->_data; + aio_thread_t *threadp; + aio_request_t *requestp; - if (request && request->resultp == resultp) { - debug(41, 9) ("aio_cancel: %p type=%d result=%p\n", - request, request->request_type, request->resultp); - request->cancelled = 1; - request->resultp = NULL; - resultp->_data = NULL; - return 0; - } + for (threadp = busy_threads_head; threadp != NULL; threadp = threadp->next) + if (threadp->processed_req->resultp == resultp) { + threadp->processed_req->cancelled = 1; + threadp->processed_req->resultp = NULL; + return 0; + } + for (requestp = request_queue_head; requestp != NULL; requestp = requestp->next) + if (requestp->resultp == resultp) { + requestp->cancelled = 1; + requestp->resultp = NULL; + return 0; + } + for (requestp = request_done_head; requestp != NULL; requestp = requestp->next) + if (requestp->resultp == resultp) { + requestp->cancelled = 1; + requestp->resultp = NULL; + return 0; + } return 1; } /* aio_cancel */ @@ -467,219 +528,223 @@ int aio_open(const char *path, int oflag, mode_t mode, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; int len; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } len = strlen(path) + 1; - if ((request->path = (char *) xmalloc(len)) == NULL) { - memPoolFree(aio_request_pool, request); + if ((requestp->path = (char *) xmalloc(len)) == NULL) { + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - strncpy(request->path, path, len); - request->oflag = oflag; - request->mode = mode; - request->resultp = resultp; - request->request_type = _AIO_OP_OPEN; - request->cancelled = 0; + strncpy(requestp->path, path, len); + requestp->oflag = oflag; + requestp->mode = mode; + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_OPEN; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_open(aio_request_t * request) +aio_do_open(aio_request_t * requestp) { - request->ret = open(request->path, request->oflag, request->mode); - request->err = errno; + requestp->ret = open(requestp->path, requestp->oflag, requestp->mode); + requestp->err = errno; } int aio_read(int fd, char *bufp, int bufs, off_t offset, int whence, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } - request->fd = fd; - request->bufferp = bufp; - if ((request->tmpbufp = (char *) xmalloc(bufs)) == NULL) { - memPoolFree(aio_request_pool, request); + requestp->fd = fd; + requestp->bufferp = bufp; + if ((requestp->tmpbufp = (char *) xmalloc(bufs)) == NULL) { + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - request->buflen = bufs; - request->offset = offset; - request->whence = whence; - request->resultp = resultp; - request->request_type = _AIO_OP_READ; - request->cancelled = 0; + requestp->buflen = bufs; + requestp->offset = offset; + requestp->whence = whence; + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_READ; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_read(aio_request_t * request) +aio_do_read(aio_request_t * requestp) { - lseek(request->fd, request->offset, request->whence); - request->ret = read(request->fd, request->tmpbufp, request->buflen); - request->err = errno; + lseek(requestp->fd, requestp->offset, requestp->whence); + requestp->ret = read(requestp->fd, requestp->tmpbufp, requestp->buflen); + requestp->err = errno; } int aio_write(int fd, char *bufp, int bufs, off_t offset, int whence, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { + errno = ENOMEM; + return -1; + } + requestp->fd = fd; + if ((requestp->tmpbufp = (char *) xmalloc(bufs)) == NULL) { + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - request->fd = fd; - request->tmpbufp = NULL; - request->bufferp = bufp; - request->buflen = bufs; - request->offset = offset; - request->whence = whence; - request->resultp = resultp; - request->request_type = _AIO_OP_WRITE; - request->cancelled = 0; + xmemcpy(requestp->tmpbufp, bufp, bufs); + requestp->buflen = bufs; + requestp->offset = offset; + requestp->whence = whence; + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_WRITE; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_write(aio_request_t * request) +aio_do_write(aio_request_t * requestp) { - request->ret = write(request->fd, request->bufferp, request->buflen); - request->err = errno; + requestp->ret = write(requestp->fd, requestp->tmpbufp, requestp->buflen); + requestp->err = errno; } int aio_close(int fd, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } - request->fd = fd; - request->resultp = resultp; - request->request_type = _AIO_OP_CLOSE; - request->cancelled = 0; + requestp->fd = fd; + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_CLOSE; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_close(aio_request_t * request) +aio_do_close(aio_request_t * requestp) { - request->ret = close(request->fd); - request->err = errno; + requestp->ret = close(requestp->fd); + requestp->err = errno; } int aio_stat(const char *path, struct stat *sb, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; int len; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } len = strlen(path) + 1; - if ((request->path = (char *) xmalloc(len)) == NULL) { - memPoolFree(aio_request_pool, request); + if ((requestp->path = (char *) xmalloc(len)) == NULL) { + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - strncpy(request->path, path, len); - request->statp = sb; - if ((request->tmpstatp = (struct stat *) xmalloc(sizeof(struct stat))) == NULL) { - xfree(request->path); - memPoolFree(aio_request_pool, request); + strncpy(requestp->path, path, len); + requestp->statp = sb; + if ((requestp->tmpstatp = (struct stat *) xmalloc(sizeof(struct stat))) == NULL) { + xfree(requestp->path); + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - request->resultp = resultp; - request->request_type = _AIO_OP_STAT; - request->cancelled = 0; + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_STAT; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_stat(aio_request_t * request) +aio_do_stat(aio_request_t * requestp) { - request->ret = stat(request->path, request->tmpstatp); - request->err = errno; + requestp->ret = stat(requestp->path, requestp->tmpstatp); + requestp->err = errno; } int aio_unlink(const char *path, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; int len; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } len = strlen(path) + 1; - if ((request->path = (char *) xmalloc(len)) == NULL) { - memPoolFree(aio_request_pool, request); + if ((requestp->path = (char *) xmalloc(len)) == NULL) { + memPoolFree(aio_request_pool, requestp); errno = ENOMEM; return -1; } - strncpy(request->path, path, len); - request->resultp = resultp; - request->request_type = _AIO_OP_UNLINK; - request->cancelled = 0; + strncpy(requestp->path, path, len); + requestp->resultp = resultp; + requestp->request_type = _AIO_OP_UNLINK; + requestp->cancelled = 0; - aio_queue_request(request); + aio_do_request(requestp); return 0; } static void -aio_do_unlink(aio_request_t * request) +aio_do_unlink(aio_request_t * requestp) { - request->ret = unlink(request->path); - request->err = errno; + requestp->ret = unlink(requestp->path); + requestp->err = errno; } int @@ -706,7 +771,7 @@ requestp->request_type = _AIO_OP_TRUNCATE; requestp->cancelled = 0; - aio_queue_request(requestp); + aio_do_request(requestp); return 0; } @@ -720,17 +785,17 @@ #if AIO_OPENDIR -/* XXX aio_opendir NOT implemented yet.. */ +/* XXX aio_opendir NOT implemented? */ int aio_opendir(const char *path, aio_result_t * resultp) { - aio_request_t *request; + aio_request_t *requestp; int len; if (!aio_initialised) aio_init(); - if ((request = memPoolAlloc(aio_request_pool)) == NULL) { + if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) { errno = ENOMEM; return -1; } @@ -738,70 +803,89 @@ } static void -aio_do_opendir(aio_request_t * request) +aio_do_opendir(aio_request_t * requestp) { /* NOT IMPLEMENTED */ } #endif -static void -aio_poll_queues(void) + +void +aio_poll_threads(void) { - /* kick "overflow" request queue */ - if (request_queue2.head && - pthread_mutex_trylock(&request_queue.mutex) == 0) { - *request_queue.tailp = request_queue2.head; - request_queue.tailp = request_queue2.tailp; - pthread_cond_signal(&request_queue.cond); - pthread_mutex_unlock(&request_queue.mutex); - request_queue2.head = NULL; - request_queue2.tailp = &request_queue2.head; - } - /* poll done queue */ - if (done_queue.head && pthread_mutex_trylock(&done_queue.mutex) == 0) { - struct aio_request_t *requests = done_queue.head; - done_queue.head = NULL; - done_queue.tailp = &done_queue.head; - pthread_mutex_unlock(&done_queue.mutex); - *done_requests.tailp = requests; - request_queue_len -= 1; - while(requests->next) { - requests = requests->next; - request_queue_len -= 1; + aio_thread_t *prev; + aio_thread_t *threadp; + aio_request_t *requestp; + + do { /* while found completed thread */ + prev = NULL; + threadp = busy_threads_head; + while (threadp) { + debug(43, 9) ("aio_poll_threads: %p: request type %d -> status %d\n", + threadp, + threadp->processed_req->request_type, + threadp->status); +#if AIO_PROPER_MUTEX + if (threadp->req == NULL) + if (pthread_mutex_trylock(&threadp->mutex) == 0) + break; +#else + if (threadp->req == NULL) + break; +#endif + prev = threadp; + threadp = threadp->next; } - done_requests.tailp = &requests->next; - } -} + if (threadp == NULL) + break; + + if (prev == NULL) + busy_threads_head = busy_threads_head->next; + else + prev->next = threadp->next; + + if (busy_threads_tail == threadp) + busy_threads_tail = prev; + + requestp = threadp->processed_req; + threadp->processed_req = NULL; + + threadp->next = wait_threads; + wait_threads = threadp; + + if (request_done_tail != NULL) + request_done_tail->next = requestp; + else + request_done_head = requestp; + request_done_tail = requestp; + } while (threadp); + + aio_process_request_queue(); +} /* aio_poll_threads */ aio_result_t * aio_poll_done(void) { - aio_request_t *request; + aio_request_t *requestp; aio_result_t *resultp; int cancelled; - int polled = 0; AIO_REPOLL: - request = done_requests.head; - if (request == NULL && !polled) { - aio_poll_queues(); - polled = 1; - request = done_requests.head; - } - if (!request) { + aio_poll_threads(); + if (request_done_head == NULL) { return NULL; } - debug(41, 9) ("aio_poll_done: %p type=%d result=%p\n", - request, request->request_type, request->resultp); - done_requests.head = request->next; - if (!done_requests.head) - done_requests.tailp = &done_requests.head; - resultp = request->resultp; - cancelled = request->cancelled; - aio_debug(request); - debug(43, 5) ("DONE: %d -> %d\n", request->ret, request->err); - aio_cleanup_request(request); + requestp = request_done_head; + request_done_head = requestp->next; + if (!request_done_head) + request_done_tail = NULL; + + resultp = requestp->resultp; + cancelled = requestp->cancelled; + aio_debug(requestp); + debug(43, 5) ("DONE: %d -> %d\n", requestp->ret, requestp->err); + aio_cleanup_request(requestp); if (cancelled) goto AIO_REPOLL; return resultp; @@ -810,7 +894,7 @@ int aio_operations_pending(void) { - return request_queue_len > 0 || done_requests.head; + return request_queue_len + (request_done_head != NULL) + (busy_threads_head != NULL); } int @@ -830,9 +914,10 @@ int aio_sync(void) { - /* XXX This might take a while if the queue is large.. */ + int loop_count = 0; do { - aio_poll_queues(); + aio_poll_threads(); + assert(++loop_count < 10); } while (request_queue_len > 0); return aio_operations_pending(); } @@ -844,26 +929,26 @@ } static void -aio_debug(aio_request_t * request) +aio_debug(aio_request_t * requestp) { - switch (request->request_type) { + switch (requestp->request_type) { case _AIO_OP_OPEN: - debug(43, 5) ("OPEN of %s to FD %d\n", request->path, request->ret); + debug(43, 5) ("OPEN of %s to FD %d\n", requestp->path, requestp->ret); break; case _AIO_OP_READ: - debug(43, 5) ("READ on fd: %d\n", request->fd); + debug(43, 5) ("READ on fd: %d\n", requestp->fd); break; case _AIO_OP_WRITE: - debug(43, 5) ("WRITE on fd: %d\n", request->fd); + debug(43, 5) ("WRITE on fd: %d\n", requestp->fd); break; case _AIO_OP_CLOSE: - debug(43, 5) ("CLOSE of fd: %d\n", request->fd); + debug(43, 5) ("CLOSE of fd: %d\n", requestp->fd); break; case _AIO_OP_UNLINK: - debug(43, 5) ("UNLINK of %s\n", request->path); + debug(43, 5) ("UNLINK of %s\n", requestp->path); break; case _AIO_OP_TRUNCATE: - debug(43, 5) ("UNLINK of %s\n", request->path); + debug(43, 5) ("UNLINK of %s\n", requestp->path); break; default: break; Index: squid/src/fs/aufs/async_io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/async_io.c,v retrieving revision 1.1.6.1.2.6 retrieving revision 1.1.6.1.2.7 diff -u -r1.1.6.1.2.6 -r1.1.6.1.2.7 --- squid/src/fs/aufs/async_io.c 1 Jul 2000 12:20:15 -0000 1.1.6.1.2.6 +++ squid/src/fs/aufs/async_io.c 9 Jan 2001 22:02:14 -0000 1.1.6.1.2.7 @@ -53,8 +53,6 @@ AIOCB *done_handler; void *done_handler_data; aio_result_t result; - char *bufp; - FREE *free_func; } aio_ctrl_t; struct { @@ -226,8 +224,6 @@ ctrlp->done_handler = callback; ctrlp->done_handler_data = callback_data; ctrlp->operation = _AIO_WRITE; - ctrlp->bufp = bufp; - ctrlp->free_func = free_func; if (offset >= 0) seekmode = SEEK_SET; else { @@ -246,6 +242,11 @@ ctrlp->next = used_list; used_list = ctrlp; } + /* + * aio_write copies the buffer so we can free it here + */ + if (free_func) + free_func(bufp); } /* aioWrite */ @@ -411,9 +412,6 @@ ctrlp->result.aio_return, ctrlp->result.aio_errno); cbdataUnlock(their_data); } - /* free data if requested to aioWrite() */ - if (ctrlp->free_func) - ctrlp->free_func(ctrlp->bufp); if (ctrlp->operation == _AIO_CLOSE) aioFDWasClosed(ctrlp->fd); memPoolFree(aio_ctrl_pool, ctrlp); Index: squid/src/fs/aufs/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_asyncufs.h,v retrieving revision 1.1.6.3.2.9 retrieving revision 1.1.6.3.2.10 diff -u -r1.1.6.3.2.9 -r1.1.6.3.2.10 --- squid/src/fs/aufs/store_asyncufs.h 16 Sep 2000 23:25:21 -0000 1.1.6.3.2.9 +++ squid/src/fs/aufs/store_asyncufs.h 9 Jan 2001 22:02:14 -0000 1.1.6.3.2.10 @@ -10,25 +10,14 @@ #ifdef ASYNC_IO_THREADS #define NUMTHREADS ASYNC_IO_THREADS #else -#define NUMTHREADS (Config.cacheSwap.n_configured*12) +#define NUMTHREADS 16 #endif -/* Queue limit where swapouts are deferred (load calculation) */ -#define MAGIC1 (NUMTHREADS*Config.cacheSwap.n_configured*5) -/* Queue limit where swapins are deferred (open/create fails) */ -#define MAGIC2 (NUMTHREADS*Config.cacheSwap.n_configured*20) - -/* Which operations to run async */ -#define ASYNC_OPEN 1 -#define ASYNC_CLOSE 0 -#define ASYNC_CREATE 1 -#define ASYNC_WRITE 0 -#define ASYNC_READ 1 +#define MAGIC1 (NUMTHREADS/Config.cacheSwap.n_configured/2) struct _aio_result_t { int aio_return; int aio_errno; - void *_data; /* Internal housekeeping */ }; typedef struct _aio_result_t aio_result_t; @@ -79,8 +68,6 @@ unsigned int reading:1; unsigned int writing:1; unsigned int opening:1; - unsigned int write_kicking:1; - unsigned int read_kicking:1; } flags; const char *read_buf; link_list *pending_writes; Index: squid/src/fs/aufs/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_dir_aufs.c,v retrieving revision 1.1.6.6.2.6 retrieving revision 1.1.6.6.2.7 diff -u -r1.1.6.6.2.6 -r1.1.6.6.2.7 --- squid/src/fs/aufs/store_dir_aufs.c 16 Sep 2000 20:48:01 -0000 1.1.6.6.2.6 +++ squid/src/fs/aufs/store_dir_aufs.c 9 Jan 2001 22:02:14 -0000 1.1.6.6.2.7 @@ -1344,8 +1344,10 @@ ql = aioQueueSize(); if (ql == 0) loadav = 0; - loadav = ql * 1000 / MAGIC1; - debug(41, 9) ("storeAufsDirCheckObj: load=%d\n", loadav); + else if (ql >= MAGIC1) /* Queue is too long, don't even consider it */ + loadav = -1; + else + loadav = MAGIC1 * 1000 / ql; return loadav; } Index: squid/src/fs/aufs/store_io_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_io_aufs.c,v retrieving revision 1.1.6.6.2.8 retrieving revision 1.1.6.6.2.9 diff -u -r1.1.6.6.2.8 -r1.1.6.6.2.9 --- squid/src/fs/aufs/store_io_aufs.c 16 Sep 2000 23:25:21 -0000 1.1.6.6.2.8 +++ squid/src/fs/aufs/store_io_aufs.c 9 Jan 2001 22:02:14 -0000 1.1.6.6.2.9 @@ -6,16 +6,8 @@ #include "squid.h" #include "store_asyncufs.h" -#if ASYNC_READ static AIOCB storeAufsReadDone; -#else -static DRCB storeAufsReadDone; -#endif -#if ASYNC_WRITE static AIOCB storeAufsWriteDone; -#else -static DWCB storeAufsWriteDone; -#endif static void storeAufsIOCallback(storeIOState * sio, int errflag); static AIOCB storeAufsOpenDone; static int storeAufsSomethingPending(storeIOState *); @@ -47,25 +39,13 @@ sfileno f = e->swap_filen; char *path = storeAufsDirFullPath(SD, f, NULL); storeIOState *sio; -#if !ASYNC_OPEN - int fd; -#endif debug(78, 3) ("storeAufsOpen: fileno %08X\n", f); /* * we should detect some 'too many files open' condition and return * NULL here. */ -#ifdef MAGIC2 - if (aioQueueSize() > MAGIC2) + while (aioQueueSize() > MAGIC1) return NULL; -#endif -#if !ASYNC_OPEN - fd = file_open(path, O_RDONLY); - if (fd < 0) { - debug(78, 3) ("storeAufsOpen: got failude (%d)\n", errno); - return NULL; - } -#endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); sio->fsstate = memPoolAlloc(aio_state_pool); @@ -78,12 +58,8 @@ sio->callback_data = callback_data; sio->e = e; cbdataLock(callback_data); - Opening_FD++; -#if ASYNC_OPEN aioOpen(path, O_RDONLY, 0644, storeAufsOpenDone, sio); -#else - storeAufsOpenDone(fd, sio, fd, 0); -#endif + Opening_FD++; store_open_disk_fd++; return sio; } @@ -96,9 +72,6 @@ storeIOState *sio; sfileno filn; sdirno dirn; -#if !ASYNC_CREATE - int fd; -#endif /* Allocate a number */ dirn = SD->index; @@ -110,17 +83,8 @@ * we should detect some 'too many files open' condition and return * NULL here. */ -#ifdef MAGIC2 - if (aioQueueSize() > MAGIC2) - return NULL; -#endif -#if !ASYNC_CREATE - fd = file_open(path, O_WRONLY | O_CREAT | O_TRUNC); - if (fd < 0) { - debug(78, 3) ("storeAufsCreate: got failude (%d)\n", errno); + while (aioQueueSize() > MAGIC1) return NULL; - } -#endif sio = memAllocate(MEM_STORE_IO); cbdataAdd(sio, storeAufsIOFreeEntry, MEM_STORE_IO); sio->fsstate = memPoolAlloc(aio_state_pool); @@ -133,12 +97,8 @@ sio->callback_data = callback_data; sio->e = (StoreEntry *) e; cbdataLock(callback_data); - Opening_FD++; -#if ASYNC_CREATE aioOpen(path, O_WRONLY | O_CREAT | O_TRUNC, 0644, storeAufsOpenDone, sio); -#else - storeAufsOpenDone(fd, sio, fd, 0); -#endif + Opening_FD++; store_open_disk_fd++; /* now insert into the replacement policy */ @@ -194,11 +154,7 @@ sio->swap_dirn, sio->swap_filen, aiostate->fd); sio->offset = offset; aiostate->flags.reading = 1; -#if ASYNC_READ aioRead(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); -#else - file_read(aiostate->fd, offset, buf, size, storeAufsReadDone, sio); -#endif } @@ -221,7 +177,6 @@ linklistPush(&(aiostate->pending_writes), q); return; } -#if ASYNC_WRITE if (aiostate->flags.writing) { struct _queued_write *q; debug(78, 3) ("storeAufsWrite: queuing write\n"); @@ -238,15 +193,9 @@ * XXX it might be nice if aioWrite() gave is immediate * feedback here about EWOULDBLOCK instead of in the * callback function - * XXX Should never give EWOULDBLOCK under normal operations - * if it does then the MAGIC1/2 tuning is wrong. */ aioWrite(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, free_func); -#else - file_write(aiostate->fd, offset, buf, size, storeAufsWriteDone, sio, - free_func); -#endif } /* Unlink */ @@ -314,20 +263,8 @@ debug(78, 3) ("storeAufsOpenDone: exiting\n"); } -/* - * XXX TODO - * if errflag == EWOULDBLOCK, then we'll need to re-queue the - * chunk at the beginning of the write_pending list and try - * again later. - * XXX Should not normally happen. - */ -#if ASYNC_READ static void storeAufsReadDone(int fd, void *my_data, int len, int errflag) -#else -static void -storeAufsReadDone(int fd, int errflag, size_t len, void *my_data) -#endif { storeIOState *sio = my_data; aiostate_t *aiostate = (aiostate_t *) sio->fsstate; @@ -365,15 +302,9 @@ * if errflag == EWOULDBLOCK, then we'll need to re-queue the * chunk at the beginning of the write_pending list and try * again later. - * XXX Should not normally happen. */ -#if ASYNC_WRITE static void storeAufsWriteDone(int fd, void *my_data, int len, int errflag) -#else -static void -storeAufsWriteDone(int fd, int errflag, size_t len, void *my_data) -#endif { static int loop_detect = 0; storeIOState *sio = my_data; @@ -389,21 +320,10 @@ return; } sio->offset += len; -#if ASYNC_WRITE - if (!storeAufsKickWriteQueue(sio)) - 0; + if (storeAufsKickWriteQueue(sio)) + (void) 0; else if (aiostate->flags.close_request) storeAufsIOCallback(sio, errflag); -#else - if (!aiostate->flags.write_kicking) { - aiostate->flags.write_kicking = 1; - while (storeAufsKickWriteQueue(sio)) - (void) 0; - aiostate->flags.write_kicking = 0; - if (aiostate->flags.close_request) - storeAufsIOCallback(sio, errflag); - } -#endif loop_detect--; }