? config.log ? NEWS ? Makefile ? config.h.in ? AUTHORS ? autom4te.cache ? config.status ? cfgaux/config.guess ? cfgaux/config.sub ? cfgaux/install-sh ? cfgaux/missing ? cfgaux/mkinstalldirs ? cfgaux/depcomp ? contrib/Makefile ? errors/Makefile ? icons/Makefile ? include/stamp-h1 ? include/autoconf.h ? lib/Makefile ? lib/.deps ? scripts/Makefile ? scripts/RunCache ? scripts/RunAccel ? snmplib/Makefile ? snmplib/.deps ? src/Makefile ? src/.deps ? src/cf_gen_defines.h ? src/cf.data ? src/cf_parser.c ? src/squid.conf ? src/cf_parser.h ? src/squid.conf.default ? src/globals.c ? src/string_arrays.c ? src/repl_modules.c ? src/auth_modules.c ? src/store_modules.c ? src/cf_gen ? src/client ? src/unlinkd ? src/cachemgr ? src/cachemgr.cgi ? src/squid ? src/bak ? src/auth/Makefile ? src/auth/.deps ? src/auth/basic/Makefile ? src/auth/basic/.dirstamp ? src/auth/basic/helpers/Makefile ? src/auth/basic/helpers/LDAP/Makefile ? src/auth/basic/helpers/LDAP/.deps ? src/auth/basic/helpers/MSNT/Makefile ? src/auth/basic/helpers/MSNT/.deps ? src/auth/basic/helpers/NCSA/Makefile ? src/auth/basic/helpers/NCSA/.deps ? src/auth/basic/helpers/PAM/Makefile ? src/auth/basic/helpers/PAM/.deps ? src/auth/basic/helpers/SMB/Makefile ? src/auth/basic/helpers/SMB/.deps ? src/auth/basic/helpers/YP/Makefile ? src/auth/basic/helpers/YP/.deps ? src/auth/basic/helpers/getpwnam/Makefile ? src/auth/basic/helpers/getpwnam/.deps ? src/auth/basic/helpers/multi-domain-NTLM/Makefile ? src/auth/digest/Makefile ? src/auth/digest/helpers/Makefile ? src/auth/digest/helpers/password/Makefile ? src/auth/digest/helpers/password/.deps ? src/auth/ntlm/Makefile ? src/auth/ntlm/helpers/Makefile ? src/auth/ntlm/helpers/NTLMSSP/Makefile ? src/auth/ntlm/helpers/NTLMSSP/.deps ? src/auth/ntlm/helpers/NTLMSSP/smbval/Makefile ? src/auth/ntlm/helpers/NTLMSSP/smbval/.deps ? src/auth/ntlm/helpers/fakeauth/Makefile ? src/auth/ntlm/helpers/fakeauth/.deps ? src/auth/ntlm/helpers/no_check/Makefile ? src/fs/Makefile ? src/fs/.deps ? src/fs/aufs/Makefile ? src/fs/coss/Makefile ? src/fs/diskd/Makefile ? src/fs/diskd/.deps ? src/fs/null/Makefile ? src/fs/ufs/Makefile ? src/fs/ufs/.dirstamp ? src/repl/Makefile ? src/repl/stamp ? src/repl/.deps ? src/repl/heap/Makefile ? src/repl/lru/Makefile ? src/repl/lru/.dirstamp Index: configure.in =================================================================== RCS file: /cvsroot/squid/squid/configure.in,v retrieving revision 1.30 diff -u -r1.30 configure.in --- configure.in 2001/10/03 14:59:31 1.30 +++ configure.in 2001/10/17 06:52:44 @@ -9,6 +9,7 @@ dnl AC_INIT(src/main.c) AC_CONFIG_AUX_DIR(cfgaux) +AC_CONFIG_HEADERS AM_INIT_AUTOMAKE(Squid, 2.5-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) AC_REVISION($Revision: 1.30 $)dnl Index: src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid/squid/src/HttpHeader.c,v retrieving revision 1.6 diff -u -r1.6 HttpHeader.c --- src/HttpHeader.c 2001/04/14 00:31:01 1.6 +++ src/HttpHeader.c 2001/10/17 06:52:46 @@ -123,6 +123,8 @@ {"X-Cache-Lookup", HDR_X_CACHE_LOOKUP, ftStr}, {"X-Forwarded-For", HDR_X_FORWARDED_FOR, ftStr}, {"X-Request-URI", HDR_X_REQUEST_URI, ftStr}, + /* NBK - Aug 9, 2001: record the client's URI in forwarded requests */ + {"X-Forwarded-URI", HDR_X_FORWARDED_URI, ftStr}, {"X-Squid-Error", HDR_X_SQUID_ERROR, ftStr}, {"Negotiate", HDR_NEGOTIATE, ftStr}, #if X_ACCELERATOR_VARY @@ -161,6 +163,7 @@ #if X_ACCELERATOR_VARY HDR_X_ACCELERATOR_VARY, #endif + HDR_X_FORWARDED_URI, HDR_X_FORWARDED_FOR }; Index: src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.38 diff -u -r1.38 client_side.c --- src/client_side.c 2001/10/12 23:35:26 1.38 +++ src/client_side.c 2001/10/17 06:52:48 @@ -287,6 +287,17 @@ result ? result : "NULL"); assert(http->redirect_state == REDIRECT_PENDING); http->redirect_state = REDIRECT_DONE; + + /* NBK - Aug 8, 2001: append X-Forwarded-URI */ + if( http->forwarded_uri ) { + String str; + + str = httpHeaderGetList(&old_request->header, HDR_X_FORWARDED_URI); + strListAdd(&str, http->forwarded_uri, ','); + httpHeaderPutStr(&old_request->header, HDR_X_FORWARDED_URI, strBuf(str)); + stringClean(&str); + } + if (result) { http_status status = (http_status) atoi(result); if (status == HTTP_MOVED_PERMANENTLY || status == HTTP_MOVED_TEMPORARILY) { @@ -302,10 +313,10 @@ new_request = urlParse(old_request->method, result); } if (new_request) { + httpHeaderAppend(&new_request->header, &old_request->header); safe_free(http->uri); http->uri = xstrdup(urlCanonical(new_request)); new_request->http_ver = old_request->http_ver; - httpHeaderAppend(&new_request->header, &old_request->header); new_request->client_addr = old_request->client_addr; new_request->my_addr = old_request->my_addr; new_request->my_port = old_request->my_port; @@ -813,6 +824,7 @@ checkFailureRatio(request->err_type, http->al.hier.code); safe_free(http->uri); safe_free(http->log_uri); + safe_free(http->forwarded_uri); safe_free(http->al.headers.request); safe_free(http->al.headers.reply); safe_free(http->redirect.location); @@ -1367,6 +1379,7 @@ httpHeaderPutStr(hdr, HDR_X_REQUEST_URI, http->entry->mem_obj->url ? http->entry->mem_obj->url : http->uri); #endif + httpHdrMangleList(hdr, request); } @@ -2674,6 +2687,34 @@ http->log_uri = xstrndup(http->uri, MAX_URL); else http->log_uri = xstrndup(rfc1738_escape_unescaped(http->uri), MAX_URL); + + /* X-Forwarded-URI */ + { + const char *proto, *host; + int port; + char *p; + + + proto = "http"; + if( Config.Sockaddr.https->s.sin_port == http->conn->me.sin_port ) { + proto = "https"; + } + port = ntohs(http->conn->me.sin_port); + host = mime_get_header(req_hdr, "Host"); + if( !host ) { + host = getMyHostname(); + } + if( (p = strrchr(host, ';')) ) { + *p=0; + } + + http->forwarded_uri = xcalloc(MAX_URL+32, 1); + if( http->forwarded_uri ) { + snprintf(http->forwarded_uri, MAX_URL+32, + "%s://%s:%d%s", proto, host, port, url); + } + } + debug(33, 5) ("parseHttpRequest: Complete request received\n"); xfree(inbuf); *status = 1; @@ -3280,6 +3321,7 @@ fd_table[fd].ssl = ssl; fd_table[fd].read_method = &ssl_read_method; fd_table[fd].write_method = &ssl_write_method; + fd_table[fd].pending_method = &ssl_pending_method; debug(50, 5) ("httpsAccept: FD %d accepted, starting SSL negotiation.\n", fd); connState = cbdataAlloc(ConnStateData); Index: src/comm_select.c =================================================================== RCS file: /cvsroot/squid/squid/src/comm_select.c,v retrieving revision 1.6 diff -u -r1.6 comm_select.c --- src/comm_select.c 2001/05/04 13:39:12 1.6 +++ src/comm_select.c 2001/10/17 06:52:48 @@ -322,6 +322,8 @@ int calldns = 0; static time_t last_timeout = 0; double timeout = current_dtime + (msec / 1000.0); + int pending = 0; /* the number of fds available for immediate read */ + do { #if !ALARM_UPDATES_TIME double start; @@ -369,6 +371,17 @@ pfds[nfds].fd = i; pfds[nfds].events = events; pfds[nfds].revents = 0; + + // NBK - Oct 16, 2001 - Some streams (like SSL) buffer + // data. They have bytes available for reading, + // without requiring a poll(). If that's true, then I + // pretend the poll succeeded immediately + if( events & POLLRDNORM && + fd_table[i].pending_method && + fd_table[i].pending_method(i) ) { + pending++; + pfds[nfds].revents = POLLRDNORM; + } nfds++; } } @@ -380,7 +393,12 @@ msec = MAX_POLL_TIME; for (;;) { statCounter.syscalls.polls++; - num = poll(pfds, nfds, msec); + if( pending ) { + num = pending; + } + else { + num = poll(pfds, nfds, msec); + } statCounter.select_loops++; if (num >= 0) break; @@ -633,6 +651,8 @@ { fd_set readfds; fd_set writefds; + fd_set pending_fds; + int pending; #if DELAY_POOLS fd_set slowfds; #endif @@ -675,6 +695,9 @@ howmany(maxfd, FD_MASK_BITS) * FD_MASK_BYTES); xmemcpy(&writefds, &global_writefds, howmany(maxfd, FD_MASK_BITS) * FD_MASK_BYTES); + + FD_ZERO(&pending_fds); + /* remove stalled FDs */ maxindex = howmany(maxfd, FD_MASK_BITS); fdsp = (fd_mask *) & readfds; @@ -711,6 +734,11 @@ if (fd_table[i].read_handler && !commDeferRead(i)) { #endif assert(FD_ISSET(i, &readfds)); + if( fd_table[i].pending_method && + fd_table[i].pending_method(i) ) { + pending++; + FD_SET(i, &pending_fds); + } } if (fd_table[i].write_handler) { assert(FD_ISSET(i, &writefds)); @@ -731,7 +759,13 @@ poll_time.tv_sec = msec / 1000; poll_time.tv_usec = (msec % 1000) * 1000; statCounter.syscalls.selects++; - num = select(maxfd, &readfds, &writefds, NULL, &poll_time); + if( pending ) { + readfds = pending_readfds; + num = pending; + } + else { + num = select(maxfd, &readfds, &writefds, NULL, &poll_time); + } statCounter.select_loops++; if (num >= 0) break; Index: src/debug.c =================================================================== RCS file: /cvsroot/squid/squid/src/debug.c,v retrieving revision 1.8 diff -u -r1.8 debug.c --- src/debug.c 2001/06/29 22:34:19 1.8 +++ src/debug.c 2001/10/17 06:52:48 @@ -55,7 +55,10 @@ { const char *format = NULL; #endif - LOCAL_ARRAY(char, f, BUFSIZ); + + /* NBK - Aug 9, 2001: for some reason, LOCAL_ARRAY here crashes on + my RedHat-7.1 box */ + char f[BUFSIZ]; va_list args1; #if STDC_HEADERS va_list args2; @@ -68,7 +71,7 @@ #define args3 args1 format = va_arg(args1, const char *); #endif - snprintf(f, BUFSIZ, "%s| %s", + snprintf(f, sizeof(f), "%s| %s", debugLogTime(squid_curtime), format); _db_print_file(f, args1); Index: src/enums.h =================================================================== RCS file: /cvsroot/squid/squid/src/enums.h,v retrieving revision 1.24 diff -u -r1.24 enums.h --- src/enums.h 2001/10/09 21:18:00 1.24 +++ src/enums.h 2001/10/17 06:52:49 @@ -242,6 +242,8 @@ #if X_ACCELERATOR_VARY HDR_X_ACCELERATOR_VARY, #endif + /* NBK - Aug 9, 2001: record the client's URI in forwarded requests */ + HDR_X_FORWARDED_URI, HDR_OTHER, HDR_ENUM_END } http_hdr_type; Index: src/fd.c =================================================================== RCS file: /cvsroot/squid/squid/src/fd.c,v retrieving revision 1.7 diff -u -r1.7 fd.c --- src/fd.c 2001/08/26 22:26:29 1.7 +++ src/fd.c 2001/10/17 06:52:49 @@ -35,6 +35,7 @@ #include "squid.h" +int default_pending_method(int); int default_read_method(int, char *, int); int default_write_method(int, const char *, int); @@ -94,6 +95,12 @@ } int +default_pending_method(int fd) +{ + return 0; +} + +int default_read_method(int fd, char *buf, int len) { return (read(fd, buf, len)); @@ -121,6 +128,7 @@ F->flags.open = 1; F->read_method = &default_read_method; F->write_method = &default_write_method; + F->pending_method = &default_pending_method; fdUpdateBiggest(fd, 1); if (desc) xstrncpy(F->desc, desc, FD_DESC_SZ); Index: src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.15 diff -u -r1.15 http.c --- src/http.c 2001/09/19 06:43:34 1.15 +++ src/http.c 2001/10/17 06:52:49 @@ -1083,6 +1083,9 @@ httpRequestBodyHandler(char *buf, size_t size, void *data) { HttpStateData *httpState = (HttpStateData *) data; + + debug(11, 2) ("httpRequestBodyHandler: size=%lu\n", size); + if (size > 0) { comm_write(httpState->fd, buf, size, httpSendRequestEntry, data, memFree8K); } else if (size == 0) { Index: src/ssl_support.c =================================================================== RCS file: /cvsroot/squid/squid/src/ssl_support.c,v retrieving revision 1.4 diff -u -r1.4 ssl_support.c --- src/ssl_support.c 2001/08/26 22:24:05 1.4 +++ src/ssl_support.c 2001/10/17 06:52:49 @@ -167,12 +167,38 @@ } int +ssl_pending_method(fd) + int fd; +{ + int i; + + i = !fd_table[fd].read_err && SSL_pending(fd_table[fd].ssl); + debug(81,5) ("ssl_pending_method pending=%d, ssl_err=%d, read_err=%d, ret=%d\n", + SSL_pending(fd_table[fd].ssl), + SSL_get_error(fd_table[fd].ssl, i), + fd_table[fd].read_err, + i); + return i; +} + + +int ssl_read_method(fd, buf, len) int fd; char *buf; int len; { - return (SSL_read(fd_table[fd].ssl, buf, len)); + int i; + + i = SSL_read(fd_table[fd].ssl, buf, len); + fd_table[fd].read_err = i>0 ? 0 : SSL_get_error(fd_table[fd].ssl, i); + + + debug(81, 5) ("SSL_read(fd=%d, len=%d) ret=%d ssl_err=%d, ssl_pending=%d\n", + fd, len, i, + SSL_get_error(fd_table[fd].ssl, i), + SSL_pending(fd_table[fd].ssl)); + return i; } int @@ -181,5 +207,10 @@ const char *buf; int len; { - return (SSL_write(fd_table[fd].ssl, buf, len)); + int i; + + i = SSL_write(fd_table[fd].ssl, buf, len); + debug(81, 5) ("SSL_write(fd=%d, len=%d) ret=%d ssl_err=%d\n", fd, len, i, + SSL_get_error(fd_table[fd].ssl, i)); + return i; } Index: src/ssl_support.h =================================================================== RCS file: /cvsroot/squid/squid/src/ssl_support.h,v retrieving revision 1.4 diff -u -r1.4 ssl_support.h --- src/ssl_support.h 2001/10/09 21:18:00 1.4 +++ src/ssl_support.h 2001/10/17 06:52:49 @@ -46,5 +46,6 @@ SSL_CTX *sslLoadCert(const char *certfile, const char *keyfile); int ssl_read_method(int, char *, int); int ssl_write_method(int, const char *, int); +int ssl_pending_method(int); #endif /* SQUID_SSL_SUPPORT_H */ Index: src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.44 diff -u -r1.44 structs.h --- src/structs.h 2001/10/10 18:07:43 1.44 +++ src/structs.h 2001/10/17 06:52:50 @@ -787,6 +787,19 @@ CommWriteStateData *rwstate; /* State data for comm_write */ READ_HANDLER *read_method; WRITE_HANDLER *write_method; + + /* + NBK - Oct 16, 2001 - Some streams (like SSL) buffer data. They + have bytes available for reading without requiring a poll(). + If that's pending_handler returns true, then I pretend that + poll() succeeded immediately. + + this function returns 1 iff there is data available for + immediate read, without waiting for a poll(). + */ + PENDING_HANDLER *pending_method; + int read_err; + #if USE_SSL SSL *ssl; #endif @@ -1043,6 +1056,8 @@ store_client *old_sc; /* ... for entry to be validated */ char *uri; char *log_uri; + /* NBK - Aug 9, 2001: record the client's URI in forwarded requests */ + char *forwarded_uri; struct { off_t offset; size_t size; Index: src/typedefs.h =================================================================== RCS file: /cvsroot/squid/squid/src/typedefs.h,v retrieving revision 1.25 diff -u -r1.25 typedefs.h --- src/typedefs.h 2001/10/10 18:07:43 1.25 +++ src/typedefs.h 2001/10/17 06:52:50 @@ -234,6 +234,7 @@ typedef int DEFER(int fd, void *data); typedef int READ_HANDLER(int, char *, int); typedef int WRITE_HANDLER(int, const char *, int); +typedef int PENDING_HANDLER(int); typedef void CBCB(char *buf, size_t size, void *data); typedef void STIOCB(void *their_data, int errflag, storeIOState *);