--------------------- PatchSet 1692 Date: 2001/03/07 07:22:23 Author: hno Branch: eventio Tag: (none) Log: Slowly moving forward. Large parts of client_side.c converted (probably about 50% done), and ncomm support for transparent proxies. Members: include/squid_types.h:1.1.2.1->1.1.2.2 src/acl.c:1.21.8.2->1.21.8.3 src/cache_cf.c:1.18.8.4->1.18.8.5 src/cf.data.pre:1.21.8.2->1.21.8.3 src/client_side.c:1.19.2.4->1.19.2.5 src/comm.c:1.7.12.5->1.7.12.6 src/comm_select.c:1.4.12.1->1.4.12.2 src/defines.h:1.8.12.1->1.8.12.2 src/disk.c:1.5.12.3->1.5.12.4 src/forward.c:1.9.12.1->1.9.12.2 src/http.c:1.11.12.2->1.11.12.3 src/ident.c:1.6.12.1->1.6.12.2 src/main.c:1.19.8.3->1.19.8.4 src/mime.c:1.8->1.8.12.1 src/ncomm.c:1.1.2.14->1.1.2.15 src/ncomm_internals.h:1.1.2.4->1.1.2.5 src/ncomm_test.c:1.1.2.8->1.1.2.9 src/peer_digest.c:1.6.8.1->1.6.8.2 src/protos.h:1.18.8.11->1.18.8.12 src/ssl.c:1.6.12.1->1.6.12.2 src/stat.c:1.8.8.1->1.8.8.2 src/structs.h:1.24.8.10->1.24.8.11 src/urn.c:1.8.8.2->1.8.8.3 Index: squid/include/squid_types.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/squid_types.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/include/squid_types.h 25 Feb 2001 22:04:58 -0000 1.1.2.1 +++ squid/include/squid_types.h 7 Mar 2001 07:22:23 -0000 1.1.2.2 @@ -53,8 +53,6 @@ #ifndef _SQUID_TYPES_H_ #define _SQUID_TYPES_H_ -#include "autoconf.h" - #ifdef HAVE_SYS_TYPES_H #include #endif Index: squid/src/acl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/acl.c,v retrieving revision 1.21.8.2 retrieving revision 1.21.8.3 diff -u -r1.21.8.2 -r1.21.8.3 --- squid/src/acl.c 24 Feb 2001 12:52:42 -0000 1.21.8.2 +++ squid/src/acl.c 7 Mar 2001 07:22:24 -0000 1.21.8.3 @@ -1,6 +1,6 @@ /* - * $Id: acl.c,v 1.21.8.2 2001/02/24 12:52:42 hno Exp $ + * $Id: acl.c,v 1.21.8.3 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -1226,7 +1226,7 @@ * not had bungled connection oriented authentication happen on it. */ debug(28, 9) ("aclMatchProxyAuth: header %s.\n", proxy_auth); if (auth_user_request == NULL) { - debug(28, 9) ("aclMatchProxyAuth: This is a new request on FD:%d\n", checklist->conn->fd); + debug(28, 9) ("aclMatchProxyAuth: This is a new request on FH:%p\n", checklist->conn->fh); if ((!checklist->request->auth_user_request) && (checklist->conn->auth_type == AUTH_UNKNOWN)) { /* beginning of a new request check */ debug(28, 4) ("aclMatchProxyAuth: no connection authentication type\n"); Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18.8.4 retrieving revision 1.18.8.5 diff -u -r1.18.8.4 -r1.18.8.5 --- squid/src/cache_cf.c 28 Feb 2001 14:26:15 -0000 1.18.8.4 +++ squid/src/cache_cf.c 7 Mar 2001 07:22:24 -0000 1.18.8.5 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18.8.4 2001/02/28 14:26:15 hno Exp $ + * $Id: cache_cf.c,v 1.18.8.5 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -56,9 +56,7 @@ static const char *const list_sep = ", \t\n\r"; -#if NOT_YET_PORTED static void update_maxobjsize(void); -#endif /* NOT_YET_PORTED */ static void configDoConfigure(void); static void parse_refreshpattern(refresh_t **); static int parseTimeUnits(const char *unit); @@ -135,7 +133,6 @@ return i; } -#if NOT_YET_PORTED static void update_maxobjsize(void) { @@ -148,7 +145,6 @@ } store_maxobjsize = ms; } -#endif /* NOT_YET_PORTED */ int parseConfigFile(const char *file_name) @@ -829,7 +825,6 @@ } } -#if NOT_YET_PORTED static void dump_cachedir(StoreEntry * entry, const char *name, cacheSwap swap) { @@ -846,7 +841,6 @@ { return swap.swapDirs == NULL; } -#endif /* NOT_YET_PORTED */ static int check_null_string(char *s) @@ -951,7 +945,6 @@ } } -#if NOT_YET_PORTED static int find_fstype(char *type) { @@ -1126,7 +1119,6 @@ swap->n_allocated = 0; swap->n_configured = 0; } -#endif /* NOT_YET_PORTED */ static const char * peer_type_str(const peer_t type) Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf.data.pre,v retrieving revision 1.21.8.2 retrieving revision 1.21.8.3 diff -u -r1.21.8.2 -r1.21.8.3 --- squid/src/cf.data.pre 28 Feb 2001 14:26:16 -0000 1.21.8.2 +++ squid/src/cf.data.pre 7 Mar 2001 07:22:24 -0000 1.21.8.3 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.21.8.2 2001/02/28 14:26:16 hno Exp $ +# $Id: cf.data.pre,v 1.21.8.3 2001/03/07 07:22:24 hno Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -677,7 +677,6 @@ NAME: cache_dir TYPE: cachedir -IFDEF: NOT_YET_PORTED DEFAULT: none DEFAULT_IF_NONE: ufs @DEFAULT_SWAP_DIR@ 100 16 256 LOC: Config.cacheSwap Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.19.2.4 retrieving revision 1.19.2.5 diff -u -r1.19.2.4 -r1.19.2.5 --- squid/src/client_side.c 28 Feb 2001 14:26:16 -0000 1.19.2.4 +++ squid/src/client_side.c 7 Mar 2001 07:22:24 -0000 1.19.2.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.19.2.4 2001/02/28 14:26:16 hno Exp $ + * $Id: client_side.c,v 1.19.2.5 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -35,41 +35,6 @@ #include "squid.h" -#if IPF_TRANSPARENT -#if HAVE_SYS_IOCTL_H -#include -#endif -#include -#include -#if HAVE_IP_FIL_COMPAT_H -#include -#elif HAVE_NETINET_IP_FIL_COMPAT_H -#include -#elif HAVE_IP_COMPAT_H -#include -#elif HAVE_NETINET_IP_COMPAT_H -#include -#endif -#if HAVE_IP_FIL_H -#include -#elif HAVE_NETINET_IP_FIL_H -#include -#endif -#if HAVE_IP_NAT_H -#include -#elif HAVE_NETINET_IP_NAT_H -#include -#endif -#endif - - -#if LINUX_NETFILTER -#include -#endif - - -#if NOT_YET_PORTED - #if LINGERING_CLOSE #define comm_close comm_lingering_close #endif @@ -80,19 +45,22 @@ /* Local functions */ -static CWCB clientWriteComplete; -static CWCB clientWriteBodyComplete; -static PF clientReadRequest; +static COMMIOCB clientWriteComplete; +static COMMIOCB clientWriteBodyComplete; +static COMMIOCB clientReadRequest; +static void clientReadRequest2(ConnStateData * conn); +#if NOT_YET_PORTED static PF connStateFree; static PF requestTimeout; static PF clientLifetimeTimeout; +#endif static int clientCheckTransferDone(clientHttpRequest *); static int clientGotNotEnough(clientHttpRequest *); static void checkFailureRatio(err_type, hier_code); static void clientProcessMiss(clientHttpRequest *); static void clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep); static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, char **, size_t *); +static clientHttpRequest *parseHttpRequest(ConnStateData *, char **, size_t *, method_t *, int *, char **, size_t *); static RH clientRedirectDone; static void clientCheckNoCache(clientHttpRequest *); static void clientCheckNoCacheDone(int answer, void *data); @@ -115,7 +83,9 @@ static int clientCachable(clientHttpRequest * http); static int clientHierarchical(clientHttpRequest * http); static int clientCheckContentLength(request_t * r); +#if NOT_YET_PORTED static DEFER httpAcceptDefer; +#endif static log_type clientProcessRequest2(clientHttpRequest * http); static int clientReplyBodyTooLarge(int clen); static int clientRequestBodyTooLarge(int clen); @@ -808,13 +778,14 @@ cbdataFree(http); } +#if NOT_YET_PORTED /* This is a handler normally called by comm_close() */ static void connStateFree(filehandle *fh, void *data) { ConnStateData *connState = data; clientHttpRequest *http; - debug(33, 3) ("connStateFree: FH %p\n", fd); + debug(33, 3) ("connStateFree: FH %p\n", fh); assert(connState != NULL); authenticateOnCloseConnection(connState); clientdbEstablished(connState->peer.sin_addr, -1); /* decrement */ @@ -823,21 +794,11 @@ assert(connState->chr != connState->chr->next); httpRequestFree(http); } - if (connState->in.size == CLIENT_REQ_BUF_SZ) - memFree(connState->in.buf, MEM_CLIENT_REQ_BUF); - else - safe_free(connState->in.buf); - /* XXX account connState->in.buf */ + cbdataUnreference(connState->in); pconnHistCount(0, connState->nrequests); cbdataFree(connState); -#ifdef _SQUID_LINUX_ - /* prevent those nasty RST packets */ - { - char buf[SQUID_TCP_SO_RCVBUF]; - while (read(fd, buf, SQUID_TCP_SO_RCVBUF) > 0); - } -#endif } +#endif static void clientInterpretRequestHeaders(clientHttpRequest * http) @@ -1755,17 +1716,17 @@ return; } else if (entry && EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* call clientWriteComplete so the client socket gets closed */ - clientWriteComplete(fd, NULL, 0, COMM_OK, http); + clientWriteComplete(conn->fh, NULL, 0, 0, 0, http); memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size < 0) { /* call clientWriteComplete so the client socket gets closed */ - clientWriteComplete(fd, NULL, 0, COMM_OK, http); + clientWriteComplete(conn->fh, NULL, 0, 0, 0, http); memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size == 0) { /* call clientWriteComplete so the client socket gets closed */ - clientWriteComplete(fd, NULL, 0, COMM_OK, http); + clientWriteComplete(conn->fh, NULL, 0, 0, 0, http); memFree(buf, MEM_CLIENT_SOCK_BUF); return; } @@ -1838,11 +1799,11 @@ /* reset range iterator */ http->range_iter.pos = HttpHdrRangeInitPos; } else if (!http->request->range) { - /* Avoid copying to MemBuf for non-range requests */ /* Note, if we're here, then 'rep' is known to be NULL */ + IOBuf *iob = IOBufCreate(buf, size); /* should get an IOBuf from start... */ http->out.offset += body_size; - comm_write(fd, buf, size, clientWriteBodyComplete, http, NULL); - /* NULL because clientWriteBodyComplete frees it */ + ncomm_write(conn->fh, iob, clientWriteBodyComplete, http); + cbdataUnreference(iob); return; } if (http->request->method == METHOD_HEAD) { @@ -1893,7 +1854,7 @@ if (!http->request->range && http->request->method == METHOD_GET) assert(check_size == size); /* write */ - comm_write_mbuf(fd, mb, clientWriteComplete, http); + ncomm_write_mbuf(conn->fh, mb, clientWriteComplete, http); /* if we don't do it, who will? */ memFree(buf, MEM_CLIENT_SOCK_BUF); } @@ -1905,14 +1866,13 @@ * the headers probably go through here. */ static void -clientWriteBodyComplete(int fd, char *buf, size_t size, int errflag, void *data) +clientWriteBodyComplete(filehandle *fh, IOBuf *buf, int offset, int size, int error, void *cbdata) { /* * NOTE: clientWriteComplete doesn't currently use its "buf" * (second) argument, so we pass in NULL. */ - clientWriteComplete(fd, NULL, size, errflag, data); - memFree(buf, MEM_CLIENT_SOCK_BUF); + clientWriteComplete(fh, NULL, offset, size, error, cbdata); } static void @@ -1920,17 +1880,19 @@ { ConnStateData *conn = http->conn; StoreEntry *entry; - debug(33, 3) ("clientKeepaliveNextRequest: FH %p\n", conn->fh->fd); + debug(33, 3) ("clientKeepaliveNextRequest: FH %p\n", conn->fh); httpRequestFree(http); if ((http = conn->chr) == NULL) { debug(33, 5) ("clientKeepaliveNextRequest: FH %p reading next req\n", - conn->fh->fd); + conn->fh); ncomm_note(conn->fh, "Waiting for next request"); /* * Set the timeout BEFORE calling clientReadRequest(). */ +#if NOT_YET_PORTED commSetTimeout(conn->fh, Config.Timeout.pconn, requestTimeout, conn); - clientReadRequest(conn->fh, conn); /* Read next request */ +#endif + clientReadRequest2(conn); /* Read next request */ /* * Note, the FD may be closed at this point. */ @@ -1958,14 +1920,14 @@ } static void -clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) +clientWriteComplete(filehandle *fh, IOBuf *buf, int offset, int size, int errflag, void *data) { clientHttpRequest *http = data; StoreEntry *entry = http->entry; int done; http->out.size += size; debug(33, 5) ("clientWriteComplete: FH %p, sz %d, err %d, off %d, len %d\n", - fd, size, errflag, (int) http->out.offset, entry ? objectLen(entry) : 0); + fh, size, errflag, (int) http->out.offset, entry ? objectLen(entry) : 0); if (size > 0) { kb_incr(&statCounter.client_http.kbytes_out, size); if (isTcpHit(http->log_type)) @@ -1975,31 +1937,31 @@ /* * just close the socket, httpRequestFree will abort if needed */ - comm_close(fd); + ncomm_close(fh); } else if (NULL == entry) { - comm_close(fd); /* yuk */ + ncomm_close(fh); /* yuk */ } else if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - comm_close(fd); + ncomm_close(fh); } else if ((done = clientCheckTransferDone(http)) != 0 || size == 0) { - debug(33, 5) ("clientWriteComplete: FH %p transfer is DONE\n", fd); + debug(33, 5) ("clientWriteComplete: FH %p transfer is DONE\n", fh); /* We're finished case */ if (httpReplyBodySize(http->request->method, entry->mem_obj->reply) < 0) { debug(33, 5) ("clientWriteComplete: closing, content_length < 0\n"); - comm_close(fd); + ncomm_close(fh); } else if (!done) { debug(33, 5) ("clientWriteComplete: closing, !done\n"); - comm_close(fd); + ncomm_close(fh); } else if (clientGotNotEnough(http)) { debug(33, 5) ("clientWriteComplete: client didn't get all it expected\n"); - comm_close(fd); + ncomm_close(fh); } else if (http->request->flags.proxy_keepalive) { - debug(33, 5) ("clientWriteComplete: FH %p Keeping Alive\n", fd); + debug(33, 5) ("clientWriteComplete: FH %p Keeping Alive\n", fh); clientKeepaliveNextRequest(http); } else { - comm_close(fd); + ncomm_close(fh); } } else if (clientReplyBodyTooLarge((int) http->out.offset)) { - comm_close(fd); + ncomm_close(fh); } else { /* More data will be coming from primary server; register with * storage manager. */ @@ -2167,7 +2129,7 @@ { char *url = http->uri; request_t *r = http->request; - int fd = http->conn->fh; + filehandle *fh = http->conn->fh; HttpReply *rep; http_version_t version; debug(33, 4) ("clientProcessRequest: %s '%s'\n", @@ -2175,7 +2137,7 @@ url); if (r->method == METHOD_CONNECT) { http->log_type = LOG_TCP_MISS; - sslStart(fd, url, r, &http->out.size, &http->al.http.code); + sslStart(fh, url, r, &http->out.size, &http->al.http.code); return; } else if (r->method == METHOD_PURGE) { clientPurgeRequest(http); @@ -2293,7 +2255,6 @@ http = cbdataAlloc(clientHttpRequest); http->conn = conn; http->start = current_time; - http->req_sz = conn->in.offset; http->uri = xstrdup(uri); http->log_uri = xstrndup(uri, MAX_URL); http->range_iter.boundary = StringNull; @@ -2309,10 +2270,10 @@ * a clientHttpRequest structure on success */ static clientHttpRequest * -parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status, - char **prefix_p, size_t * req_line_sz_p) +parseHttpRequest(ConnStateData * conn, char ** buf_p, size_t *size_p, method_t * method_p, int *status, char **prefix_p, size_t * req_line_sz_p) { - char *inbuf = NULL; + char *inbuf; + char *buf = *buf_p; char *mstr = NULL; char *url = NULL; char *req_hdr = NULL; @@ -2326,29 +2287,25 @@ size_t req_sz; method_t method; clientHttpRequest *http = NULL; -#if IPF_TRANSPARENT - struct natlookup natLookup; - static int natfd = -1; - static int siocgnatl_cmd = SIOCGNATL & 0xff; - int x; -#endif -#if LINUX_NETFILTER - size_t sock_sz = sizeof(conn->me); -#endif - if ((req_sz = headersEnd(conn->in.buf, conn->in.offset)) == 0) { + if ((req_sz = headersEnd(*buf_p, *size_p)) == 0) { debug(33, 5) ("Incomplete request, waiting for end of headers\n"); *status = 0; *prefix_p = NULL; *method_p = METHOD_NONE; return NULL; } - assert(req_sz <= conn->in.offset); - /* Use memcpy, not strdup! */ + assert(req_sz <= *size_p); + + /* Make a temporary (terminated) copy of the request line and headers */ inbuf = xmalloc(req_sz + 1); - xmemcpy(inbuf, conn->in.buf, req_sz); + xmemcpy(inbuf, *buf_p, req_sz); *(inbuf + req_sz) = '\0'; + /* Eat up the request line and headers from the input */ + *buf_p += req_sz; + *size_p -= req_sz; + /* pre-set these values to make aborting simpler */ *prefix_p = inbuf; *method_p = METHOD_NONE; @@ -2426,7 +2383,7 @@ *req_line_sz_p = req_hdr - inbuf; debug(33, 3) ("parseHttpRequest: prefix_sz = %d, req_line_sz = %d\n", (int) prefix_sz, (int) *req_line_sz_p); - assert(prefix_sz <= conn->in.offset); + assert(prefix_sz == req_sz); /* Ok, all headers are received */ http = cbdataAlloc(clientHttpRequest); @@ -2436,7 +2393,7 @@ http->req_sz = prefix_sz; http->range_iter.boundary = StringNull; *prefix_p = xmalloc(prefix_sz + 1); - xmemcpy(*prefix_p, conn->in.buf, prefix_sz); + xmemcpy(*prefix_p, buf, prefix_sz); *(*prefix_p + prefix_sz) = '\0'; dlinkAdd(http, &http->active, &ClientActiveRequests); @@ -2490,59 +2447,6 @@ vport = (int) ntohs(http->conn->me.sin_port); else vport = (int) Config.Accel.port; -#if IPF_TRANSPARENT - natLookup.nl_inport = http->conn->me.sin_port; - natLookup.nl_outport = http->conn->peer.sin_port; - natLookup.nl_inip = http->conn->me.sin_addr; - natLookup.nl_outip = http->conn->peer.sin_addr; - natLookup.nl_flags = IPN_TCP; - if (natfd < 0) - natfd = open(IPL_NAT, O_RDONLY, 0); - if (natfd < 0) { - debug(50, 1) ("parseHttpRequest: NAT open failed: %s\n", - xstrerror()); - return parseHttpRequestAbort(conn, "error:nat-open-failed"); - } - /* - * IP-Filter changed the type for SIOCGNATL between - * 3.3 and 3.4. It also changed the cmd value for - * SIOCGNATL, so at least we can detect it. We could - * put something in configure and use ifdefs here, but - * this seems simpler. - */ - if (63 == siocgnatl_cmd) { - struct natlookup *nlp = &natLookup; - x = ioctl(natfd, SIOCGNATL, &nlp); - } else { - x = ioctl(natfd, SIOCGNATL, &natLookup); - } - if (x < 0) { - if (errno != ESRCH) { - debug(50, 1) ("parseHttpRequest: NAT lookup failed: ioctl(SIOCGNATL)\n"); - close(natfd); - natfd = -1; - return parseHttpRequestAbort(conn, "error:nat-lookup-failed"); - } else - snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(http->conn->me.sin_addr), - vport, url); - } else if (vport_mode) - vport = natLookup.nl_realport; - snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(natLookup.nl_realip), - vport, url); -#else -#if LINUX_NETFILTER - /* If the call fails the address structure will be unchanged */ - getsockopt(conn->fh, SOL_IP, SO_ORIGINAL_DST, &conn->me, &sock_sz); - debug(33, 5) ("parseHttpRequest: addr = %s", inet_ntoa(conn->me.sin_addr)); - if (vport_mode) - vport = (int) ntohs(http->conn->me.sin_port); -#endif - snprintf(http->uri, url_sz, "http://%s:%d%s", - inet_ntoa(http->conn->me.sin_addr), - vport, url); -#endif debug(33, 5) ("VHOST REWRITE: '%s'\n", http->uri); } else { url_sz = strlen(Config2.Accel.prefix) + strlen(url) + @@ -2568,6 +2472,7 @@ return http; } +#if OLD_COMM_CODE static int clientReadDefer(int fdnotused, void *data) { @@ -2577,8 +2482,220 @@ else return conn->defer.until > squid_curtime; } +#endif static void +clientReadRequest2(ConnStateData * conn) +{ + filehandle *fh = conn->fh; + request_t *request; + + /* Process request body if any */ + if (conn->body.callback != NULL) + clientProcessBody(conn); + + while (conn->in && conn->body.size_left == 0) { + clientHttpRequest **H, *http; + int nrequests; + method_t method; + char *prefix; + int parser_return_code; + char *buf = IOBufP(conn->in); + size_t size = IOBufSize(conn->in); + size_t req_line_sz; + /* Skip leading (and trailing) whitespace */ + while (size > 0 && xisspace(*buf)) { + buf++; + size--; + } + if (size == 0) + break; + /* Limit the number of concurrent requests to 2 */ + for (H = &conn->chr, nrequests = 0; *H; H = &(*H)->next, nrequests++); + if (nrequests >= (Config.onoff.pipeline_prefetch ? 2 : 1)) { + debug(33, 3) ("clientReadRequest: FH %p max concurrent requests reached\n", fh); + debug(33, 5) ("clientReadRequest: FH %p defering new request until one is done\n", fh); + return; + } + if (nrequests == 0) + ncomm_note(conn->fh, "Reading next request"); + /* Process request */ + http = parseHttpRequest(conn, + &buf, + &size, + &method, + &parser_return_code, + &prefix, + &req_line_sz); + if (!http) + safe_free(prefix); + if (http) { + IOBuf *newbuf = NULL; + assert(http->req_sz > 0); + assert(size >= 0); + /* + * If we read past the end of this request, move the remaining + * data to the beginning + */ + if (size > 0) + newbuf = IOBufCreate(buf, size); + cbdataUnreference(conn->in); + conn->in = cbdataReference(newbuf); + cbdataUnreference(newbuf); + + /* add to the client request queue */ + for (H = &conn->chr; *H; H = &(*H)->next); + *H = http; + conn->nrequests++; + /* + * I wanted to lock 'http' here since its callback data for + * clientLifetimeTimeout(), but there's no logical place to + * cbdataUnlock if the timeout never happens. Maybe its safe + * enough to assume that if the FD is open, and the timeout + * triggers, that 'http' is valid. + */ +#if NOT_YET_PORTED + commSetTimeout(fh, Config.Timeout.lifetime, clientLifetimeTimeout, http); +#endif + if (parser_return_code < 0) { + ErrorState *err; + debug(33, 1) ("clientReadRequest: FH %p Invalid Request\n", fh); + err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST); + err->request_hdrs = xstrdup(buf); /* XXX NULL termination! */ + http->entry = clientCreateStoreEntry(http, method, null_request_flags); + errorAppendEntry(http->entry, err); + safe_free(prefix); + break; + } + if ((request = urlParse(method, http->uri)) == NULL) { + ErrorState *err; + debug(33, 5) ("Invalid URL: %s\n", http->uri); + err = errorCon(ERR_INVALID_URL, HTTP_BAD_REQUEST); + err->src_addr = conn->peer.sin_addr; + err->url = xstrdup(http->uri); + http->al.http.code = err->http_status; + http->entry = clientCreateStoreEntry(http, method, null_request_flags); + errorAppendEntry(http->entry, err); + safe_free(prefix); + break; + } else { + /* compile headers */ + /* we should skip request line! */ + if (!httpRequestParseHeader(request, prefix + req_line_sz)) + debug(33, 1) ("Failed to parse request headers: %s\n%s\n", + http->uri, prefix); + /* continue anyway? */ + } + request->flags.accelerated = http->flags.accel; + if (!http->flags.internal) { + if (internalCheck(strBuf(request->urlpath))) { + if (internalHostnameIs(request->host) && + request->port == ntohs(Config.Sockaddr.http->s.sin_port)) { + http->flags.internal = 1; + } else if (internalStaticCheck(strBuf(request->urlpath))) { + xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN); + request->port = ntohs(Config.Sockaddr.http->s.sin_port); + http->flags.internal = 1; + } + } + } + /* + * cache the Content-length value in request_t. + */ + request->content_length = httpHeaderGetInt(&request->header, + HDR_CONTENT_LENGTH); + request->flags.internal = http->flags.internal; + safe_free(prefix); + safe_free(http->log_uri); + http->log_uri = xstrdup(urlCanonicalClean(request)); + request->client_addr = conn->peer.sin_addr; + request->my_addr = conn->me.sin_addr; + request->my_port = ntohs(conn->me.sin_port); + request->http_ver = http->http_ver; + if (!urlCheckRequest(request)) { + ErrorState *err = errorCon(ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED); + err->src_addr = conn->peer.sin_addr; + err->request = requestLink(request); + request->flags.proxy_keepalive = 0; + http->al.http.code = err->http_status; + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); + errorAppendEntry(http->entry, err); + break; + } + if (!clientCheckContentLength(request)) { + ErrorState *err = errorCon(ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED); + err->src_addr = conn->peer.sin_addr; + err->request = requestLink(request); + http->al.http.code = err->http_status; + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); + errorAppendEntry(http->entry, err); + break; + } + http->request = requestLink(request); + clientSetKeepaliveFlag(http); + /* Do we expect a request-body? */ + if (request->content_length > 0) { + conn->body.size_left = request->content_length; + request->body_connection = conn; + /* Is it too large? */ + if (clientRequestBodyTooLarge(request->content_length)) { + ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); + err->request = requestLink(request); + http->entry = clientCreateStoreEntry(http, + METHOD_NONE, null_request_flags); + errorAppendEntry(http->entry, err); + break; + } + } + clientAccessCheck(http); + continue; /* while offset > 0 && body.size_left == 0 */ + } else if (parser_return_code == 0) { + /* + * Partial request received; reschedule until parseHttpRequest() + * is happy with the input + */ + if (size >= Config.maxRequestHeaderSize) { + ErrorState *err; + /* The request is too large to handle */ + debug(33, 1) ("Request header is too large (%d bytes)\n", + (int) size); + debug(33, 1) ("Config 'request_header_max_size'= %d bytes.\n", + Config.maxRequestHeaderSize); + err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE); + http = parseHttpRequestAbort(conn, "error:request-too-large"); + /* add to the client request queue */ + for (H = &conn->chr; *H; H = &(*H)->next); + *H = http; + http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); + errorAppendEntry(http->entry, err); + return; + } + break; + } + } /* while offset > 0 && conn->body.size_left == 0 */ + ncomm_read(fh, clientReadRequest, conn); +} + +static void +clientReadRequest(filehandle *fh, IOBuf *in, int offset, int size, int error, void *cbdata) +{ + ConnStateData *conn = cbdata; + + kb_incr(&statCounter.client_http.kbytes_in, size); + + /* TODO: error, EOF (size == 0) */ + + if (conn->in) + IOBufAppend(conn->in, IOBufP(in), size); + else + conn->in = cbdataReference(in); + + clientReadRequest2(conn); +} + + +#if OLD_VERSION +static void clientReadRequest(int fd, void *data) { ConnStateData *conn = data; @@ -2842,6 +2959,7 @@ } } } +#endif /* OLD_VERSION */ /* file_read like function, for reading body content */ void @@ -2853,13 +2971,13 @@ callback(buf, 0, cbdata); /* Signal end of body */ return; } - debug(33, 2) ("clientReadBody: start fh=%p body_size=%d in.offset=%d cb=%p req=%p\n", conn->fh, conn->body.size_left, conn->in.offset, callback, request); + debug(33, 2) ("clientReadBody: start fh=%p body_size=%d size=%d cb=%p req=%p\n", conn->fh, conn->body.size_left, IOBufSize(conn->in), callback, request); conn->body.callback = callback; conn->body.cbdata = cbdata; conn->body.buf = buf; conn->body.bufsize = size; conn->body.request = requestLink(request); - if (conn->in.offset) { + if (conn->in) { /* Data available */ clientProcessBody(conn); } else { @@ -2871,30 +2989,34 @@ static void clientProcessBody(ConnStateData * conn) { - int size; + int size, remaining; char *buf = conn->body.buf; void *cbdata = conn->body.cbdata; CBCB *callback = conn->body.callback; request_t *request = conn->body.request; /* Note: request is null while eating "aborted" transfers */ - debug(33, 2) ("clientProcessBody: start fh=%p body_size=%d in.offset=%d cb=%p req=%p\n", conn->fh, conn->body.size_left, conn->in.offset, callback, request); + debug(33, 2) ("clientProcessBody: start fh=%p body_size=%d size=%d cb=%p req=%p\n", conn->fh, conn->body.size_left, IOBufSize(conn->in), callback, request); /* Some sanity checks... */ assert(conn->body.size_left > 0); - assert(conn->in.offset > 0); + assert(conn->in); assert(callback != NULL); assert(buf != NULL); /* How much do we have to process? */ - size = conn->in.offset; + size = IOBufSize(conn->in); if (size > conn->body.size_left) /* only process the body part */ size = conn->body.size_left; if (size > conn->body.bufsize) /* don't copy more than requested */ size = conn->body.bufsize; - xmemcpy(buf, conn->in.buf, size); + xmemcpy(buf, IOBufP(conn->in), size); conn->body.size_left -= size; /* Move any remaining data */ - conn->in.offset -= size; - if (conn->in.offset > 0) - xmemmove(conn->in.buf, conn->in.buf + size, conn->in.offset); + remaining = IOBufSize(conn->in) - size; + if (remaining) { + IOBuf *newbuf = IOBufCreate(IOBufP(conn->in)+size, remaining); + cbdataUnreference(conn->in); + conn->in = cbdataReference(newbuf); + cbdataUnreference(newbuf); + } /* Remove request link if this is the last part of the body, as * clientReadRequest automatically continues to process next request */ if (conn->body.size_left <= 0 && request != NULL) @@ -2911,7 +3033,7 @@ callback(buf, size, cbdata); if (request != NULL) requestUnlink(request); /* Linked in clientReadBody */ - debug(33, 2) ("clientProcessBody: end fh=%p size=%d body_size=%d in.offset=%d cb=%p req=%p\n", conn->fh, size, conn->body.size_left, conn->in.offset, callback, request); + debug(33, 2) ("clientProcessBody: end fh=%p size=%d body_size=%d remaining=%d cb=%p req=%p\n", conn->fh, size, conn->body.size_left, IOBufSize(conn->in), callback, request); return; } @@ -2921,7 +3043,7 @@ clientReadBodyAbortHandler(char *buf, size_t size, void *data) { ConnStateData *conn = (ConnStateData *) data; - debug(33, 2) ("clientReadBodyAbortHandler: fh=%p body_size=%d in.offset=%d\n", conn->fh, conn->body.size_left, conn->in.offset); + debug(33, 2) ("clientReadBodyAbortHandler: fh=%p body_size=%d size=%d\n", conn->fh, conn->body.size_left, IOBufSize(conn->in)); if (size != 0 && conn->body.size_left != 0) { debug(33, 3) ("clientReadBodyAbortHandler: fh=%p shedule next read\n", conn->fh); conn->body.callback = clientReadBodyAbortHandler; @@ -2959,6 +3081,7 @@ return 1; /* Aborted */ } +#if NOT_YET_PORTED /* general lifetime handler for HTTP requests */ static void requestTimeout(int fd, void *data) @@ -3037,49 +3160,42 @@ } return 1; } - #endif /* NOT_YET_PORTED */ + /* Handle a new connection on HTTP socket. */ static void clientNewHttpConnection(filehandle *fh, int error, struct sockaddr *local, struct sockaddr *peer, int addrlen, void *cbdata) { int fd = -1; - ConnStateData *connState = NULL; -#if NOT_YET_PORTED + ConnStateData *conn = NULL; #if USE_IDENT static aclCheck_t identChecklist; #endif -#endif debug(33, 4) ("httpAccept: FH %p: accepted\n", fd); - connState = cbdataAlloc(ConnStateData); - connState->fh = cbdataReference(fh); - memcpy(&connState->peer, peer, sizeof(connState->peer)); /* addrsize? */ - connState->log_addr = ((struct sockaddr_in *)peer)->sin_addr; - connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr; - memcpy(&connState->me, local, sizeof(connState->me)); /* addrsize? */ - connState->in.size = CLIENT_REQ_BUF_SZ; - connState->in.buf = memAllocate(MEM_CLIENT_REQ_BUF); + conn = cbdataAlloc(ConnStateData); + conn->fh = cbdataReference(fh); + memcpy(&conn->peer, peer, sizeof(conn->peer)); /* addrsize? */ + conn->log_addr = ((struct sockaddr_in *)peer)->sin_addr; + conn->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr; + memcpy(&conn->me, local, sizeof(conn->me)); /* addrsize? */ #if NOT_YET_PORTED - comm_add_close_handler(fd, connStateFree, connState); + comm_add_close_handler(fd, connFree, conn); if (Config.onoff.log_fqdn) fqdncache_gethostbyaddr(peer.sin_addr, FQDN_LOOKUP_IF_MISS); - commSetTimeout(fd, Config.Timeout.request, requestTimeout, connState); + commSetTimeout(fd, Config.Timeout.request, requestTimeout, conn); +#endif #if USE_IDENT - identChecklist.src_addr = peer.sin_addr; - identChecklist.my_addr = me.sin_addr; - identChecklist.my_port = ntohs(me.sin_port); - if (aclCheckFast(Config.accessList.identLookup, &identChecklist)) - identStart(&me, &peer, clientIdentDone, connState); -#endif - commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, connState, 0); - commSetDefer(fd, clientReadDefer, connState); - clientdbEstablished(peer.sin_addr, 1); - } + identChecklist.src_addr = ((struct sockaddr_in *)peer)->sin_addr; + identChecklist.my_addr = ((struct sockaddr_in *)local)->sin_addr; + identChecklist.my_port = ntohs(((struct sockaddr_in *)local)->sin_port); + if (aclCheckFast(Config.accessList.identLookup, &identChecklist)) + identStart(local, peer, clientIdentDone, conn); #endif + clientdbEstablished(((struct sockaddr_in *)peer)->sin_addr, 1); + ncomm_read(fh, clientReadRequest, conn); } -#if NOT_YET_PORTED #define SENDING_BODY 0 #define SENDING_HDRSONLY 1 @@ -3204,7 +3320,6 @@ hit_only_mode_until = squid_curtime + FAILURE_MODE_TIME; request_failure_ratio = 0.8; /* reset to something less than 1.0 */ } -#endif /* NOT_YET_PORTED */ void clientHttpConnectionsOpen(void) @@ -3213,14 +3328,13 @@ filehandle *fh; for (s = Config.Sockaddr.http; s; s = s->next) { enter_suid(); - fh = ncomm_listen(SOCK_STREAM, 0, (struct sockaddr *)&s->s, sizeof(s->s), 8192, clientNewHttpConnection, NULL); + fh = ncomm_listen_transparent(SOCK_STREAM, 0, (struct sockaddr *)&s->s, sizeof(s->s), 8192, clientNewHttpConnection, NULL); leave_suid(); if (fh == NULL) fatal("Cannot open HTTP Port"); } } -#if NOT_YET_PORTED void clientHttpConnectionsClose(void) { @@ -3234,4 +3348,3 @@ } NHttpSockets = 0; } -#endif /* NOT_YET_PORTED */ Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.7.12.5 retrieving revision 1.7.12.6 diff -u -r1.7.12.5 -r1.7.12.6 --- squid/src/comm.c 25 Feb 2001 00:06:40 -0000 1.7.12.5 +++ squid/src/comm.c 7 Mar 2001 07:22:24 -0000 1.7.12.6 @@ -1,6 +1,5 @@ - /* - * $Id: comm.c,v 1.7.12.5 2001/02/25 00:06:40 hno Exp $ + * $Id: comm.c,v 1.7.12.6 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -582,7 +581,6 @@ assert(F->type != FD_FILE); F->flags.closing = 1; CommWriteStateCallbackAndFree(fd, COMM_ERR_CLOSING); - ncomm_close(fd); commCallCloseHandlers(fd); if (F->uses) /* assume persistent connect count */ pconnHistCount(1, F->uses); Index: squid/src/comm_select.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm_select.c,v retrieving revision 1.4.12.1 retrieving revision 1.4.12.2 diff -u -r1.4.12.1 -r1.4.12.2 --- squid/src/comm_select.c 24 Feb 2001 07:55:38 -0000 1.4.12.1 +++ squid/src/comm_select.c 7 Mar 2001 07:22:24 -0000 1.4.12.2 @@ -1,6 +1,5 @@ - /* - * $Id: comm_select.c,v 1.4.12.1 2001/02/24 07:55:38 hno Exp $ + * $Id: comm_select.c,v 1.4.12.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 5 Socket Functions * Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.8.12.1 retrieving revision 1.8.12.2 diff -u -r1.8.12.1 -r1.8.12.2 --- squid/src/defines.h 24 Feb 2001 12:52:42 -0000 1.8.12.1 +++ squid/src/defines.h 7 Mar 2001 07:22:24 -0000 1.8.12.2 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.8.12.1 2001/02/24 12:52:42 hno Exp $ + * $Id: defines.h,v 1.8.12.2 2001/03/07 07:22:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -294,3 +294,9 @@ #ifndef O_BINARY #define O_BINARY 0 #endif + +/* IOBuf macros */ +#define IOBufP(iobuf) (*(iobuf)->bufp) +#define IOBufSize(iobuf) ((iobuf) ? (iobuf)->size : 0) +#define IOBufAppend(iobuf, buf, size) memBufAppend(iobuf, buf, size) + Index: squid/src/disk.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/disk.c,v retrieving revision 1.5.12.3 retrieving revision 1.5.12.4 diff -u -r1.5.12.3 -r1.5.12.4 --- squid/src/disk.c 25 Feb 2001 00:06:40 -0000 1.5.12.3 +++ squid/src/disk.c 7 Mar 2001 07:22:24 -0000 1.5.12.4 @@ -1,6 +1,5 @@ - /* - * $Id: disk.c,v 1.5.12.3 2001/02/25 00:06:40 hno Exp $ + * $Id: disk.c,v 1.5.12.4 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.9.12.1 retrieving revision 1.9.12.2 diff -u -r1.9.12.1 -r1.9.12.2 --- squid/src/forward.c 24 Feb 2001 12:52:42 -0000 1.9.12.1 +++ squid/src/forward.c 7 Mar 2001 07:22:24 -0000 1.9.12.2 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.9.12.1 2001/02/24 12:52:42 hno Exp $ + * $Id: forward.c,v 1.9.12.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -371,8 +371,8 @@ request_t *request = fwdState->request; StoreEntry *entry = fwdState->entry; ErrorState *err; - debug(17, 3) ("fwdDispatch: FD %d: Fetching '%s %s'\n", - fwdState->client_fd, + debug(17, 3) ("fwdDispatch: FH %p: Fetching '%s %s'\n", + fwdState->client_fh, RequestMethodStr[request->method], storeUrl(entry)); /*assert(!EBIT_TEST(entry->flags, ENTRY_DISPATCHED)); */ @@ -486,7 +486,7 @@ } void -fwdStart(int fd, StoreEntry * e, request_t * r) +fwdStart(filehandle *fh, StoreEntry * e, request_t * r) { FwdState *fwdState; aclCheck_t ch; @@ -517,7 +517,6 @@ } debug(17, 3) ("fwdStart: '%s'\n", storeUrl(e)); e->mem_obj->request = requestLink(r); - e->mem_obj->fd = fd; #if URL_CHECKSUM_DEBUG assert(e->mem_obj->chksum == url_checksum(e->mem_obj->url)); #endif @@ -536,7 +535,7 @@ internalStart(r, e); return; case PROTO_CACHEOBJ: - cachemgrStart(fd, r, e); + cachemgrStart(r, e); return; case PROTO_URN: urnStart(r, e); @@ -546,7 +545,7 @@ } fwdState = cbdataAlloc(FwdState); fwdState->entry = e; - fwdState->client_fd = fd; + fwdState->client_fh = fh; fwdState->server_fd = -1; fwdState->request = requestLink(r); fwdState->start = squid_curtime; Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.11.12.2 retrieving revision 1.11.12.3 diff -u -r1.11.12.2 -r1.11.12.3 --- squid/src/http.c 24 Feb 2001 12:52:42 -0000 1.11.12.2 +++ squid/src/http.c 7 Mar 2001 07:22:24 -0000 1.11.12.3 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.11.12.2 2001/02/24 12:52:42 hno Exp $ + * $Id: http.c,v 1.11.12.3 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -42,8 +42,8 @@ static const char *const crlf = "\r\n"; -static COMMCB httpSendComplete; -static COMMCB httpSendRequestEntry; +static CWCB httpSendComplete; +static CWCB httpSendRequestEntry; static PF httpReadReply; static void httpSendRequest(HttpStateData *); @@ -589,8 +589,7 @@ /* This will be called when request write is complete. Schedule read of * reply. */ static void -httpSendComplete(int fd, void *bufnotused, ssize_t size, int errflag, - int reterrno, void *data) +httpSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) { HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; @@ -601,6 +600,7 @@ assert(entry->mem_obj->chksum == url_checksum(entry->mem_obj->url)); #endif if (size > 0) { + fd_bytes(fd, size, FD_WRITE); kb_incr(&statCounter.server.all.kbytes_out, size); kb_incr(&statCounter.server.http.kbytes_out, size); } @@ -872,7 +872,7 @@ StoreEntry *entry = httpState->entry; int cfd; peer *p = httpState->peer; - COMMCB *sendHeaderDone; + CWCB *sendHeaderDone; debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", httpState->fd, httpState); @@ -881,12 +881,16 @@ else sendHeaderDone = httpSendComplete; +#if NOT_YET_PORTED if (!opt_forwarded_for) cfd = -1; else if (entry->mem_obj == NULL) cfd = -1; else cfd = entry->mem_obj->fd; +#else + cfd = -1; +#endif assert(-1 == cfd || FD_SOCKET == fd_table[cfd].type); if (p != NULL) httpState->flags.proxying = 1; @@ -915,7 +919,7 @@ cfd, httpState->flags); debug(11, 6) ("httpSendRequest: FD %d:\n%s\n", httpState->fd, *mb.bufp); - ncomm_write_mbuf(httpState->fd, mb, sendHeaderDone, httpState); + comm_write_mbuf(httpState->fd, mb, sendHeaderDone, httpState); } void @@ -986,13 +990,13 @@ ch.request = httpState->request; if (!Config.accessList.brokenPosts) { debug(11, 5) ("httpSendRequestEntryDone: No brokenPosts list\n"); - httpSendComplete(fd, NULL, 0, COMM_OK, 0, data); + httpSendComplete(fd, NULL, 0, 0, data); } else if (!aclCheckFast(Config.accessList.brokenPosts, &ch)) { debug(11, 5) ("httpSendRequestEntryDone: didn't match brokenPosts\n"); - httpSendComplete(fd, NULL, 0, COMM_OK, 0, data); + httpSendComplete(fd, NULL, 0, 0, data); } else { debug(11, 2) ("httpSendRequestEntryDone: matched brokenPosts\n"); - ncomm_write(fd, "\r\n", 2, httpSendComplete, data, NULL); + comm_write(fd, "\r\n", 2, httpSendComplete, data, NULL); } } @@ -1001,7 +1005,7 @@ { HttpStateData *httpState = (HttpStateData *) data; if (size > 0) { - ncomm_write(httpState->fd, buf, size, httpSendRequestEntry, data, memFree8K); + comm_write(httpState->fd, buf, size, httpSendRequestEntry, data, memFree8K); } else if (size == 0) { /* End of body */ memFree8K(buf); @@ -1009,13 +1013,12 @@ } else { /* Failed to get whole body, probably aborted */ memFree8K(buf); - httpSendComplete(httpState->fd, NULL, 0, COMM_ERR_CLOSING, 0, data); + httpSendComplete(httpState->fd, NULL, 0, COMM_ERR_CLOSING, data); } } static void -httpSendRequestEntry(int fd, void *bufnotused, ssize_t size, int errflag, int reterrno, - void *data) +httpSendRequestEntry(int fd, char *bufnotused, size_t size, int errflag, void *data) { HttpStateData *httpState = data; StoreEntry *entry = httpState->entry; @@ -1023,6 +1026,7 @@ debug(11, 5) ("httpSendRequestEntry: FD %d: size %d: errflag %d.\n", fd, size, errflag); if (size > 0) { + fd_bytes(fd, size, FD_WRITE); kb_incr(&statCounter.server.all.kbytes_out, size); kb_incr(&statCounter.server.http.kbytes_out, size); } @@ -1030,7 +1034,7 @@ return; if (errflag) { err = errorCon(ERR_WRITE_ERROR, HTTP_INTERNAL_SERVER_ERROR); - err->xerrno = reterrno; + err->xerrno = errno; err->request = requestLink(httpState->orig_request); errorAppendEntry(entry, err); comm_close(fd); Index: squid/src/ident.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ident.c,v retrieving revision 1.6.12.1 retrieving revision 1.6.12.2 diff -u -r1.6.12.1 -r1.6.12.2 --- squid/src/ident.c 24 Feb 2001 12:52:42 -0000 1.6.12.1 +++ squid/src/ident.c 7 Mar 2001 07:22:24 -0000 1.6.12.2 @@ -1,6 +1,6 @@ /* - * $Id: ident.c,v 1.6.12.1 2001/02/24 12:52:42 hno Exp $ + * $Id: ident.c,v 1.6.12.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -186,8 +186,10 @@ * start a TCP connection to the peer host on port 113 */ void -identStart(struct sockaddr_in *me, struct sockaddr_in *my_peer, IDCB * callback, void *data) +identStart(struct sockaddr *local, struct sockaddr *remote, IDCB * callback, void *data) { + struct sockaddr_in *me = (struct sockaddr_in *)local; + struct sockaddr_in *my_peer = (struct sockaddr_in *)remote; IdentStateData *state; int fd; char key1[IDENT_KEY_SZ]; Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.19.8.3 retrieving revision 1.19.8.4 diff -u -r1.19.8.3 -r1.19.8.4 --- squid/src/main.c 24 Feb 2001 23:48:43 -0000 1.19.8.3 +++ squid/src/main.c 7 Mar 2001 07:22:24 -0000 1.19.8.4 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.19.8.3 2001/02/24 23:48:43 hno Exp $ + * $Id: main.c,v 1.19.8.4 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -633,6 +633,8 @@ if (checkRunningPid()) exit(1); + memBuf_module_init(); + #if TEST_ACCESS comm_init(); ncomm_module_init(); @@ -671,7 +673,7 @@ /* init comm module */ comm_init(); - ncomm_init(); + ncomm_module_init(); comm_select_init(); if (opt_no_daemon) { Index: squid/src/mime.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mime.c,v retrieving revision 1.8 retrieving revision 1.8.12.1 diff -u -r1.8 -r1.8.12.1 --- squid/src/mime.c 12 Jan 2001 08:20:33 -0000 1.8 +++ squid/src/mime.c 7 Mar 2001 07:22:24 -0000 1.8.12.1 @@ -1,6 +1,6 @@ /* - * $Id: mime.c,v 1.8 2001/01/12 08:20:33 hno Exp $ + * $Id: mime.c,v 1.8.12.1 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -409,7 +409,7 @@ if (storeGetPublic(url, METHOD_GET)) return; snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon); - fd = file_open(path, O_RDONLY | O_BINARY); + fd = open(path, O_RDONLY | O_BINARY, 0); if (fd < 0) { debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror()); return; @@ -441,7 +441,7 @@ buf = memAllocate(MEM_4K_BUF); while ((n = read(fd, buf, 4096)) > 0) storeAppend(e, buf, n); - file_close(fd); + close(fd); EBIT_SET(e->flags, ENTRY_SPECIAL); storeBufferFlush(e); storeComplete(e); Index: squid/src/ncomm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ncomm.c,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -r1.1.2.14 -r1.1.2.15 --- squid/src/ncomm.c 28 Feb 2001 14:39:40 -0000 1.1.2.14 +++ squid/src/ncomm.c 7 Mar 2001 07:22:24 -0000 1.1.2.15 @@ -1,6 +1,42 @@ #include "squid.h" #include "ncomm_internals.h" +/* transparent proxying requires some extra headers... */ + +#if IPF_TRANSPARENT +#if HAVE_SYS_IOCTL_H +#include +#endif +#include +#include +#if HAVE_IP_FIL_COMPAT_H +#include +#elif HAVE_NETINET_IP_FIL_COMPAT_H +#include +#elif HAVE_IP_COMPAT_H +#include +#elif HAVE_NETINET_IP_COMPAT_H +#include +#endif +#if HAVE_IP_FIL_H +#include +#elif HAVE_NETINET_IP_FIL_H +#include +#endif +#if HAVE_IP_NAT_H +#include +#elif HAVE_NETINET_IP_NAT_H +#include +#endif +#endif + +#if LINUX_NETFILTER +#include +#endif + +/* end of headers for transparent proxying */ + + #define UNUSED __attribute__((unused)) typedef enum cbent_type { @@ -50,7 +86,7 @@ { IOBuf *buf, *bufp; buf = cbdataAlloc(IOBuf); - memBufInit(buf, size, size); + memBufInit(buf, size, 1024*1024); /* max 1MB per IOBuf */ bufp = cbdataReference(buf); cbdataFree(buf); return bufp; @@ -410,6 +446,61 @@ if (addrsize < nfh->addrsize) nfh->addrsize = addrsize; +#if IPF_TRANSPARENT + if (fh->transparent && fh->local.sa_family == AF_INET) { + struct natlookup natLookup; + static int natfd = -1; + static const int siocgnatl_cmd = SIOCGNATL & 0xff; + int x; + struct sockaddr_in *local = (struct sockaddr_in *)&fh->local; + struct sockaddr_in *peer = (struct sockaddr_in *)&fh->peer; + + natLookup.nl_inport = local->sin_port; + natLookup.nl_outport = peer->sin_port; + natLookup.nl_inip = local->sin_addr; + natLookup.nl_outip = peer->sin_addr; + natLookup.nl_flags = IPN_TCP; + if (natfd < 0) + natfd = open(IPL_NAT, O_RDONLY, 0); + if (natfd < 0) { + debug(50, 1) ("WARNING: NAT open failed: %s\n", xstrerror()); + } else { + /* + * IP-Filter changed the type for SIOCGNATL between + * 3.3 and 3.4. It also changed the cmd value for + * SIOCGNATL, so at least we can detect it. We could + * put something in configure and use ifdefs here, but + * this seems simpler. + */ + if (63 == siocgnatl_cmd) { + struct natlookup *nlp = &natLookup; + x = ioctl(natfd, SIOCGNATL, &nlp); + } else { + x = ioctl(natfd, SIOCGNATL, &natLookup); + } + if (x < 0) { + if (errno != ESRCH) { + debug(50, 1) ("parseHttpRequest: NAT lookup failed: ioctl(SIOCGNATL)\n"); + close(natfd); + natfd = -1; + } + } else { + local->sin_port = natLookup.nl_realport; + local->sin_addr = natLookup.nl_realip; + nfh->transparent = 1; + } + } + } +#elsif LINUX_NETFILTER + if (fh->transparent) { + int x; + addrsize = sizeof(fh->local); + x = getsockopt(fh->fd, SOL_IP, SO_ORIGINAL_DST, &fh->local, &addrsize); + if (x == 0) + nfh->transparent = 1; + } +#endif + /* Set the flags */ ncommSetCloseOnExec(nfd); ncommSetNonBlocking(nfd); @@ -468,6 +559,18 @@ return fh; } +filehandle * +ncomm_listen_transparent(int sock_type, int proto, struct sockaddr *where, + int addrsize, int backlog, COMMNEWCB *callback, void *cbdata) +{ + filehandle *fh = ncomm_listen(sock_type, proto, where, addrsize, + backlog, callback, cbdata); + if (fh) + fh->transparent = 1; + + return fh; +} + static void destroy_filehandle(void *data) { @@ -665,3 +768,25 @@ { fd_note(fh->fd, note); } + +int +ncomm_sendto(filehandle *fh, const struct sockaddr *to_addr, int addr_len, const void *msg, int msglen) +{ + int error = 0; + int x; + + x = sendto(fh->fd, msg, msglen, 0, to_addr, addr_len); + if (x < 0) { + error = errno; +#ifdef _SQUID_LINUX + if (errno != ECONNREFUSED) +#endif + debug(50, 1) ("ncomm_sendto: FH %p, %s, port %d: %s\n", + fh, + inet_ntoa(((struct sockaddr_in *)to_addr)->sin_addr), + (int) htons(((struct sockaddr_in *)to_addr)->sin_port), + xstrerror()); + return error; + } + return x; +} Index: squid/src/ncomm_internals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ncomm_internals.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid/src/ncomm_internals.h 25 Feb 2001 20:55:22 -0000 1.1.2.4 +++ squid/src/ncomm_internals.h 7 Mar 2001 07:22:24 -0000 1.1.2.5 @@ -46,5 +46,6 @@ COMMEVENTWRITE *write_handler; unsigned int closed:1; unsigned int shutdown:1; + unsigned int transparent:1; /* look up the real destination in NAT */ }; Index: squid/src/ncomm_test.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ncomm_test.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid/src/ncomm_test.c 28 Feb 2001 14:39:40 -0000 1.1.2.8 +++ squid/src/ncomm_test.c 7 Mar 2001 07:22:24 -0000 1.1.2.9 @@ -149,26 +149,51 @@ void storeDirConfigure(void) { } void storeConfigure(void) { } const char *uniqueHostname(void) { return "henrik"; } -int aclPurgeMethodInUse(acl_access *a) { return 0; } -void urlExtMethodConfigure(void) { } -wordlist *aclDumpGeneric(const acl *a) { return NULL; } -const char *aclTypeToStr(squid_acl a) { return NULL; } -void aclParseAclLine(acl **a) { } -void aclDestroyAcls(acl **a) { } void storeAppend(StoreEntry *a, const char *b, int c) { } void storeAppendPrintf(StoreEntry *a, const char *b,...) { } -void aclParseAccessLine(struct _acl_access **a) { } -void aclDestroyAccessList(struct _acl_access **list) { } struct in_addr inaddrFromHostent(const struct hostent *hp) { struct in_addr addr = { s_addr : INADDR_ANY }; return addr; } -const char *httpHeaderNameById(int id) { return NULL; } -int httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * attrs, int end) { return 0; } -int httpHeaderIdByNameDef(const char *name, int name_len) { return 0; } int authenticateAuthSchemeId(const char *typestr) { return -1; } char *neighborTypeStr(const peer * e) { return NULL; } void dump_peer_options(StoreEntry *a, peer *b) { } PeerDigest *peerDigestCreate(peer * p) { return NULL; } void peerClearRR(void *a) { } -void aclParseDenyInfoLine(struct _acl_deny_info_list **a) { } peer *peerFindByName(const char *a) { return NULL; } +int internalCheck(const char *urlpath) { return 0; } +char *internalLocalUri(const char *dir, const char *name) { return "http://UNKNOWN/"; }; +int errorReservePageId(const char *page_name) { return 0; } +auth_user_request_t *authenticateGetAuthUser(const char *proxy_auth) { return NULL; } +int authenticateValidateUser(auth_user_request_t *a) { return 0; } +char *authenticateUserRequestUsername(auth_user_request_t *a) { return NULL; } +void authenticateAuthUserRequestLock(auth_user_request_t *a) { } +void authenticateAuthUserRequestSetIp(auth_user_request_t *a, struct in_addr b) { } +int authenticateUserAuthenticated(auth_user_request_t *a) { return 0; } +void authenticateAuthenticateUser(auth_user_request_t *a, request_t *b, ConnStateData *c, http_hdr_type d) { } +int authenticateDirection(auth_user_request_t *a) { return 0; } +void authenticateAuthUserRequestUnlock(auth_user_request_t *a) { } +int authenticateCheckAuthUserIP(struct in_addr request_src_addr, auth_user_request_t * auth_user) { return 0; } +void authenticateStart(auth_user_request_t *a, RH *b, void *c) { } +void identStart(struct sockaddr_in *me, struct sockaddr_in *peer, IDCB * callback, void *cbdata) { } +void requestUnlink(request_t *a) { } +request_t *requestLink(request_t *) +void +kb_incr(kb_t * k, size_t v) +{ + k->bytes += v; + k->kb += (k->bytes >> 10); + k->bytes &= 0x3FF; +} + +int +stringHasCntl(const char *s) +{ + unsigned char c; + while ((c = (unsigned char) *s++) != '\0') { + if (c <= 0x1f) + return 1; + if (c >= 0x7f && c <= 0x9f) + return 1; + } + return 0; +} Index: squid/src/peer_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_digest.c,v retrieving revision 1.6.8.1 retrieving revision 1.6.8.2 diff -u -r1.6.8.1 -r1.6.8.2 --- squid/src/peer_digest.c 24 Feb 2001 12:52:42 -0000 1.6.8.1 +++ squid/src/peer_digest.c 7 Mar 2001 07:22:24 -0000 1.6.8.2 @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.c,v 1.6.8.1 2001/02/24 12:52:42 hno Exp $ + * $Id: peer_digest.c,v 1.6.8.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -324,7 +324,7 @@ /* push towards peer cache */ debug(72, 3) ("peerDigestRequest: forwarding to fwdStart...\n"); - fwdStart(-1, e, req); + fwdStart(NULL, e, req); cbdataLock(fetch); cbdataLock(fetch->pd); storeClientCopy(fetch->sc, e, 0, 0, 4096, memAllocate(MEM_4K_BUF), Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.18.8.11 retrieving revision 1.18.8.12 diff -u -r1.18.8.11 -r1.18.8.12 --- squid/src/protos.h 28 Feb 2001 14:39:40 -0000 1.18.8.11 +++ squid/src/protos.h 7 Mar 2001 07:22:24 -0000 1.18.8.12 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.18.8.11 2001/02/28 14:39:40 hno Exp $ + * $Id: protos.h,v 1.18.8.12 2001/03/07 07:22:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -140,7 +140,6 @@ extern int commUnsetNonBlocking(int fd); extern void commSetCloseOnExec(int fd); -#if OLD_COMM_CODE extern int comm_accept(int fd, struct sockaddr_in *, struct sockaddr_in *); extern void comm_close(int fd); #if LINGERING_CLOSE @@ -168,7 +167,6 @@ extern void commSetDefer(int fd, DEFER * func, void *); extern int ignoreErrno(int); extern void commCloseAllSockets(void); -#endif /* @@ -212,7 +210,6 @@ /* packs, then prints an object using debug() */ extern void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm); -#if NOT_YET_PORTED /* disk.c */ extern int file_open(const char *path, int mode); extern void file_close(int fd); @@ -220,7 +217,6 @@ extern void file_write_mbuf(int fd, off_t, MemBuf mb, DWCB * handler, void *handler_data); extern void file_read(int, char *, int, off_t, DRCB *, void *); extern void disk_init(void); -#endif /* diskd.c */ extern diskd_queue *afile_create_queue(void); @@ -691,7 +687,7 @@ extern peer *netdbClosestParent(request_t *); extern void netdbHostData(const char *host, int *samp, int *rtt, int *hops); -extern void cachemgrStart(int fd, request_t * request, StoreEntry * entry); +extern void cachemgrStart(request_t * request, StoreEntry * entry); extern void cachemgrRegister(const char *, const char *, OBJH *, int, int); extern void cachemgrInit(void); @@ -705,7 +701,7 @@ extern void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e); /* forward.c */ -extern void fwdStart(int, StoreEntry *, request_t *); +extern void fwdStart(filehandle *fh, StoreEntry *, request_t *); extern DEFER fwdCheckDeferRead; extern void fwdFail(FwdState *, ErrorState *); extern void fwdUnregister(int fd, FwdState *); @@ -778,12 +774,12 @@ extern void start_announce(void *unused); -extern void sslStart(int fd, const char *, request_t *, size_t *, int *); +extern void sslStart(filehandle *client_fh, const char *, request_t *, size_t *, int *); extern void waisStart(FwdState *); /* ident.c */ #if USE_IDENT -extern void identStart(struct sockaddr_in *me, struct sockaddr_in *peer, IDCB * callback, void *cbdata); +extern void identStart(struct sockaddr *local, struct sockaddr *remote, IDCB * callback, void *cbdata); extern void identInit(void); #endif @@ -1308,6 +1304,7 @@ int ncomm_closed(filehandle *fh); void ncomm_abort(filehandle *fh); filehandle * ncomm_listen(int sock_type, int proto, struct sockaddr *where, int addrsize, int backlog, COMMNEWCB *callback, void *cbdata); +filehandle * ncomm_listen_transparent(int sock_type, int proto, struct sockaddr *where, int addrsize, int backlog, COMMNEWCB *callback, void *cbdata); filehandle * ncomm_accept(int sock_type, int proto, struct sockaddr *where, struct sockaddr *from, int addrsize, COMMNEWCB callback, void *cbdata); filehandle * ncomm_connect(int sock_type, int proto, const struct sockaddr *local, const struct sockaddr *remote, int addrsize, COMMNEWCB *callback, void *cbdata); void ncomm_read(filehandle *fh, COMMIOCB *callback, void *cbdata); @@ -1315,6 +1312,7 @@ void ncomm_write(filehandle *fh, IOBuf *buf, COMMIOCB *callback, void *cbdata); void ncomm_write_fragment(filehandle *fh, IOBuf *buf, size_t offset, size_t len, COMMIOCB *callback, void *cbdata); void ncomm_write_mbuf(filehandle *fh, MemBuf mb, COMMIOCB *callback, void *cbdata); +int ncomm_sendto(filehandle *fh, const struct sockaddr *to_addr, int addr_len, const void *msg, int msglen); int ncomm_add_close_handler(filehandle *fh, COMMCLOSECB *handler, void *cbdata); IOBuf *IOBufAlloc(size_t size); IOBuf *IOBufCreate(void *data, size_t size); Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v retrieving revision 1.6.12.1 retrieving revision 1.6.12.2 diff -u -r1.6.12.1 -r1.6.12.2 --- squid/src/ssl.c 24 Feb 2001 12:52:43 -0000 1.6.12.1 +++ squid/src/ssl.c 7 Mar 2001 07:22:24 -0000 1.6.12.2 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.6.12.1 2001/02/24 12:52:43 hno Exp $ + * $Id: ssl.c,v 1.6.12.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ #include "squid.h" +#if NOT_YET_PORTED typedef struct { char *url; char *host; /* either request->host or proxy host */ @@ -431,7 +432,7 @@ CBDATA_TYPE(SslStateData); void -sslStart(int fd, const char *url, request_t * request, size_t * size_ptr, int *status_ptr) +sslStart(filehandle *fh, const char *url, request_t * request, size_t * size_ptr, int *status_ptr) { /* Create state structure. */ SslStateData *sslState = NULL; @@ -603,3 +604,9 @@ sslConnectDone, sslState); } +#else +void +sslStart(filehandle *fh, const char *url, request_t * request, size_t * size_ptr, int *status_ptr) +{ +} +#endif /* NOT_YET_PORTED */ Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.8.8.1 retrieving revision 1.8.8.2 diff -u -r1.8.8.1 -r1.8.8.2 --- squid/src/stat.c 24 Feb 2001 12:52:43 -0000 1.8.8.1 +++ squid/src/stat.c 7 Mar 2001 07:22:24 -0000 1.8.8.2 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.8.8.1 2001/02/24 12:52:43 hno Exp $ + * $Id: stat.c,v 1.8.8.2 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -1397,19 +1397,21 @@ clientHttpRequest *http; ConnStateData *conn; StoreEntry *e; - int fd; + filehandle *fh; for (i = ClientActiveRequests.head; i; i = i->next) { http = i->data; assert(http); conn = http->conn; storeAppendPrintf(s, "Connection: %p\n", conn); if (conn) { - fd = conn->fd; - storeAppendPrintf(s, "\tFD %d, read %d, wrote %d\n", fd, + fh = conn->fh; +#if NOT_YET_PORTED + storeAppendPrintf(s, "\tFH %p, read %d, wrote %d\n", fh, fd_table[fd].bytes_read, fd_table[fd].bytes_written); - storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc); - storeAppendPrintf(s, "\tin: buf %p, offset %d, size %d\n", - conn->in.buf, conn->in.offset, conn->in.size); + storeAppendPrintf(s, "\tFH desc: %s\n", ncomm_get_note(fh)); +#endif + storeAppendPrintf(s, "\tin: buf %p, size %d\n", + conn->in, IOBufSize(conn->in)); storeAppendPrintf(s, "\tpeer: %s:%d\n", inet_ntoa(conn->peer.sin_addr), ntohs(conn->peer.sin_port)); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.24.8.10 retrieving revision 1.24.8.11 diff -u -r1.24.8.10 -r1.24.8.11 --- squid/src/structs.h 26 Feb 2001 22:19:59 -0000 1.24.8.10 +++ squid/src/structs.h 7 Mar 2001 07:22:24 -0000 1.24.8.11 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.24.8.10 2001/02/26 22:19:59 hno Exp $ + * $Id: structs.h,v 1.24.8.11 2001/03/07 07:22:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1021,11 +1021,8 @@ struct _ConnStateData { filehandle *fh; - struct { - char *buf; - off_t offset; - size_t size; - } in; + MemBuf *in; + off_t in_offset; struct { size_t size_left; /* How much body left to process */ request_t *request; /* Parameters passed to clientReadBody */ @@ -1425,7 +1422,7 @@ struct timeval start_ping; IRCB *ping_reply_callback; void *ircb_data; - int fd; /* FD of client creating this entry */ + int old_fd; /* FD of client creating this entry */ struct { STABH *callback; void *data; @@ -1881,7 +1878,7 @@ }; struct _FwdState { - int client_fd; + filehandle *client_fh; StoreEntry *entry; request_t *request; FwdServer *servers; Index: squid/src/urn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/urn.c,v retrieving revision 1.8.8.2 retrieving revision 1.8.8.3 diff -u -r1.8.8.2 -r1.8.8.3 --- squid/src/urn.c 24 Feb 2001 12:52:43 -0000 1.8.8.2 +++ squid/src/urn.c 7 Mar 2001 07:22:24 -0000 1.8.8.3 @@ -1,6 +1,6 @@ /* - * $Id: urn.c,v 1.8.8.2 2001/02/24 12:52:43 hno Exp $ + * $Id: urn.c,v 1.8.8.3 2001/03/07 07:22:24 hno Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -139,7 +139,7 @@ if ((urlres_e = storeGetPublic(urlres, METHOD_GET)) == NULL) { urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET); urnState->sc = storeClientListAdd(urlres_e, urnState); - fwdStart(-1, urlres_e, urlres_r); + fwdStart(NULL, urlres_e, urlres_r); } else { storeLockObject(urlres_e); urnState->sc = storeClientListAdd(urlres_e, urnState);