--------------------- PatchSet 6612 Date: 2008/01/21 21:19:26 Author: serassio Branch: nt Tag: (none) Log: Manually merge of missing changes from HEAD. May be a crashed cvsmerge ? Members: lib/IPAddress.cc:1.2.2.2->1.2.2.3 src/Makefile.am:1.26.2.116->1.26.2.117 src/client_side_reply.cc:1.23.2.79->1.23.2.80 src/http.cc:1.15.2.99->1.15.2.100 src/http.h:1.5.2.20->1.5.2.21 src/mem_node.cc:1.3.2.7->1.3.2.8 src/mem_node.h:1.3.2.7->1.3.2.8 src/neighbors.cc:1.13.2.32->1.13.2.33 src/pconn.cc:1.3.2.16->1.3.2.17 src/pconn.h:1.1.2.6->1.1.2.7 src/snmp_agent.cc:1.4.2.10->1.4.2.11 src/stmem.cc:1.5.2.10->1.5.2.11 src/structs.h:1.22.2.92->1.22.2.93 src/wccp2.cc:1.1.2.19->1.1.2.20 Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/IPAddress.cc,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- squid3/lib/IPAddress.cc 25 Dec 2007 15:47:42 -0000 1.2.2.2 +++ squid3/lib/IPAddress.cc 21 Jan 2008 21:19:26 -0000 1.2.2.3 @@ -1,5 +1,5 @@ /* - * $Id: IPAddress.cc,v 1.2.2.2 2007/12/25 15:47:42 serassio Exp $ + * $Id: IPAddress.cc,v 1.2.2.3 2008/01/21 21:19:26 serassio Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -91,7 +91,7 @@ /* Debugging only. Dump the address content when a fatal assert is encountered. */ #if USE_IPV6 #define IASSERT(a,b) \ - if(!b){ printf("assert \"%s\" at line %d\n", a, __LINE__); \ + if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \ printf("IPAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \ printf("ADDRESS:"); \ for(unsigned int i = 0; i < sizeof(m_SocketAddr.sin6_addr); i++) { \ @@ -100,7 +100,7 @@ } #else #define IASSERT(a,b) \ - if(!b){ printf("assert \"%s\" at line %d\n", a, __LINE__); \ + if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \ printf("IPAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \ printf("ADDRESS: %x\n", (unsigned int)m_SocketAddr.sin_addr.s_addr); \ assert(b); \ @@ -1060,7 +1060,7 @@ } // force a null-terminated string - buf[blen] = '\0'; + buf[blen-1] = '\0'; return buf; } Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v retrieving revision 1.26.2.116 retrieving revision 1.26.2.117 diff -u -r1.26.2.116 -r1.26.2.117 --- squid3/src/Makefile.am 20 Jan 2008 15:39:15 -0000 1.26.2.116 +++ squid3/src/Makefile.am 21 Jan 2008 21:19:27 -0000 1.26.2.117 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.26.2.116 2008/01/20 15:39:15 serassio Exp $ +# $Id: Makefile.am,v 1.26.2.117 2008/01/21 21:19:27 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -434,6 +434,8 @@ carp.cc \ cbdata.cc \ cbdata.h \ + ChunkedCodingParser.cc \ + ChunkedCodingParser.h \ client_db.cc \ client_side.cc \ client_side.h \ @@ -611,6 +613,8 @@ structs.h \ SwapDir.cc \ SwapDir.h \ + TextException.cc \ + TextException.h \ time.cc \ tools.cc \ tunnel.cc \ @@ -683,8 +687,6 @@ ICAP_libicap_a_SOURCES = \ ICAP/AsyncJob.cc \ ICAP/AsyncJob.h \ - ICAP/ChunkedCodingParser.cc \ - ICAP/ChunkedCodingParser.h \ ICAP/ICAPClient.cc \ ICAP/ICAPClient.h \ ICAP/ICAPInitiator.cc \ @@ -707,9 +709,7 @@ ICAP/ICAPServiceRep.cc \ ICAP/ICAPServiceRep.h \ ICAP/ICAPXaction.cc \ - ICAP/ICAPXaction.h \ - ICAP/TextException.cc \ - ICAP/TextException.h + ICAP/ICAPXaction.h unlinkd_SOURCES = unlinkd_daemon.cc SquidNew.cc @@ -785,6 +785,8 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ + ChunkedCodingParser.h \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -887,6 +889,8 @@ store_swapout.cc \ structs.h \ SwapDir.cc \ + TextException.cc \ + TextException.h \ tools.cc \ typedefs.h \ $(UNLINKDSOURCE) \ @@ -1323,6 +1327,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1413,6 +1418,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ + TextException.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1489,6 +1495,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1578,6 +1585,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ + TextException.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1641,6 +1649,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1730,6 +1739,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ + TextException.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1817,6 +1827,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -1912,6 +1923,7 @@ StoreSwapLogData.cc \ String.cc \ SwapDir.cc \ + TextException.cc \ time.cc \ tools.cc \ tunnel.cc \ @@ -1976,6 +1988,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -2066,6 +2079,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ + TextException.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -2332,6 +2346,7 @@ CacheDigest.cc \ carp.cc \ cbdata.cc \ + ChunkedCodingParser.cc \ client_db.cc \ client_side.cc \ client_side_reply.cc \ @@ -2421,6 +2436,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ + TextException.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ Index: squid3/src/client_side_reply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_reply.cc,v retrieving revision 1.23.2.79 retrieving revision 1.23.2.80 diff -u -r1.23.2.79 -r1.23.2.80 --- squid3/src/client_side_reply.cc 20 Jan 2008 15:39:16 -0000 1.23.2.79 +++ squid3/src/client_side_reply.cc 21 Jan 2008 21:19:27 -0000 1.23.2.80 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.23.2.79 2008/01/20 15:39:16 serassio Exp $ + * $Id: client_side_reply.cc,v 1.23.2.80 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1987,7 +1987,6 @@ } buildReply(buf, reqofs); - ssize_t body_size = reqofs; if (reply) { Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.15.2.99 retrieving revision 1.15.2.100 diff -u -r1.15.2.99 -r1.15.2.100 --- squid3/src/http.cc 20 Jan 2008 15:39:17 -0000 1.15.2.99 +++ squid3/src/http.cc 21 Jan 2008 21:19:27 -0000 1.15.2.100 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.15.2.99 2008/01/20 15:39:17 serassio Exp $ + * $Id: http.cc,v 1.15.2.100 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -56,6 +56,16 @@ #include "DelayPools.h" #endif #include "SquidTime.h" +#include "TextException.h" + +#define SQUID_ENTER_THROWING_CODE() try { +#define SQUID_EXIT_THROWING_CODE(status) \ + status = true; \ + } \ + catch (const TextException &e) { \ + debugs (11, 1, "Exception error:" << e.message); \ + status = false; \ + } CBDATA_CLASS_INIT(HttpStateData); @@ -68,7 +78,7 @@ HttpHeader * hdr_out, int we_do_ranges, http_state_flags); HttpStateData::HttpStateData(FwdState *theFwdState) : ServerStateData(theFwdState), - header_bytes_read(0), reply_bytes_read(0) + header_bytes_read(0), reply_bytes_read(0), httpChunkDecoder(NULL) { debugs(11,5,HERE << "HttpStateData " << this << " created"); ignoreCacheControl = false; @@ -119,7 +129,6 @@ entry->setNoDelay(_peer->options.no_delay); #endif - } /* @@ -139,6 +148,9 @@ delete readBuf; + if(httpChunkDecoder) + delete httpChunkDecoder; + HTTPMSGUNLOCK(orig_request); debugs(11,5, HERE << "HttpStateData " << this << " destroyed; FD " << fd); @@ -736,6 +748,12 @@ readBuf->consume(header_bytes_read); } + flags.chunked = 0; + if (newrep->header.hasListMember(HDR_TRANSFER_ENCODING, "chunked", ',')) { + flags.chunked = 1; + httpChunkDecoder = new ChunkedCodingParser; + } + HttpReply *vrep = setVirginReply(newrep); flags.headers_parsed = 1; @@ -897,6 +915,13 @@ if (!flags.headers_parsed) return INCOMPLETE_MSG; + /* In chunked responce we do not know the content length but we are absolutelly + * sure about the end of response, so we are calling the statusIfComplete to + * decide if we can be persistant + */ + if (eof && flags.chunked) + return statusIfComplete(); + if (eof) // already reached EOF return COMPLETE_NONPERSISTENT_MSG; @@ -1099,10 +1124,31 @@ { const char *data = readBuf->content(); int len = readBuf->contentSize(); - addVirginReplyBody(data, len); readBuf->consume(len); +} +bool +HttpStateData::decodeAndWriteReplyBody() +{ + const char *data = NULL; + int len; + bool status = false; + assert(flags.chunked); + assert(httpChunkDecoder); + SQUID_ENTER_THROWING_CODE(); + MemBuf decodedData; + decodedData.init(); + const bool done = httpChunkDecoder->parse(readBuf,&decodedData); + len = decodedData.contentSize(); + data=decodedData.content(); + addVirginReplyBody(data, len); + if (done) { + eof = 1; + flags.do_next_read = 0; + } + SQUID_EXIT_THROWING_CODE(status); + return status; } /* @@ -1135,7 +1181,15 @@ * That means header content has been removed from readBuf and * it contains only body data. */ - writeReplyBody(); + if(flags.chunked){ + if(!decodeAndWriteReplyBody()){ + flags.do_next_read = 0; + serverComplete(); + return; + } + } + else + writeReplyBody(); if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* Index: squid3/src/http.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.h,v retrieving revision 1.5.2.20 retrieving revision 1.5.2.21 diff -u -r1.5.2.20 -r1.5.2.21 --- squid3/src/http.h 10 Aug 2007 10:07:57 -0000 1.5.2.20 +++ squid3/src/http.h 21 Jan 2008 21:19:27 -0000 1.5.2.21 @@ -1,6 +1,6 @@ /* - * $Id: http.h,v 1.5.2.20 2007/08/10 10:07:57 serassio Exp $ + * $Id: http.h,v 1.5.2.21 2008/01/21 21:19:27 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,6 +38,7 @@ #include "comm.h" #include "forward.h" #include "Server.h" +#include "ChunkedCodingParser.h" class HttpStateData : public ServerStateData { @@ -103,6 +104,7 @@ virtual void handleRequestBodyProducerAborted(); void writeReplyBody(); + bool decodeAndWriteReplyBody(); void doneSendingRequestBody(); void requestBodyHandler(MemBuf &); virtual void sentRequestBody(int fd, size_t size, comm_err_t errflag); @@ -113,6 +115,7 @@ http_state_flags flags); static bool decideIfWeDoRanges (HttpRequest * orig_request); + ChunkedCodingParser *httpChunkDecoder; private: CBDATA_CLASS2(HttpStateData); }; Index: squid3/src/mem_node.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/mem_node.cc,v retrieving revision 1.3.2.7 retrieving revision 1.3.2.8 diff -u -r1.3.2.7 -r1.3.2.8 --- squid3/src/mem_node.cc 14 Aug 2007 09:31:20 -0000 1.3.2.7 +++ squid3/src/mem_node.cc 21 Jan 2008 21:19:27 -0000 1.3.2.8 @@ -1,6 +1,6 @@ /* - * $Id: mem_node.cc,v 1.3.2.7 2007/08/14 09:31:20 serassio Exp $ + * $Id: mem_node.cc,v 1.3.2.8 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -38,7 +38,6 @@ static int makeMemNodeDataOffset(); -unsigned long mem_node::store_mem_size; static int _mem_node_data_offset = makeMemNodeDataOffset(); /* @@ -70,9 +69,7 @@ {} mem_node::~mem_node() -{ - store_mem_size -= nodeBuffer.length; -} +{} size_t mem_node::InUseCount() @@ -80,6 +77,12 @@ return Pool().inUseCount(); } +size_t +mem_node::StoreMemSize() +{ + return InUseCount() * SM_PAGE_SIZE; +} + int64_t mem_node::start() const { Index: squid3/src/mem_node.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/mem_node.h,v retrieving revision 1.3.2.7 retrieving revision 1.3.2.8 diff -u -r1.3.2.7 -r1.3.2.8 --- squid3/src/mem_node.h 14 Aug 2007 09:31:20 -0000 1.3.2.7 +++ squid3/src/mem_node.h 21 Jan 2008 21:19:27 -0000 1.3.2.8 @@ -1,6 +1,6 @@ /* - * $Id: mem_node.h,v 1.3.2.7 2007/08/14 09:31:20 serassio Exp $ + * $Id: mem_node.h,v 1.3.2.8 2008/01/21 21:19:27 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,7 +42,7 @@ public: static size_t InUseCount(); - static unsigned long store_mem_size; /* 0 */ + static size_t StoreMemSize(); MEMPROXY_CLASS(mem_node); mem_node(int64_t); Index: squid3/src/neighbors.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/neighbors.cc,v retrieving revision 1.13.2.32 retrieving revision 1.13.2.33 diff -u -r1.13.2.32 -r1.13.2.33 --- squid3/src/neighbors.cc 25 Dec 2007 15:47:51 -0000 1.13.2.32 +++ squid3/src/neighbors.cc 21 Jan 2008 21:19:27 -0000 1.13.2.33 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.13.2.32 2007/12/25 15:47:51 serassio Exp $ + * $Id: neighbors.cc,v 1.13.2.33 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -235,9 +235,8 @@ if (squid_curtime - p->stats.last_query > Config.Timeout.deadPeer) return 1; - if (p->icp.port == echo_port) - if (!neighborUp(p)) - return 0; + if (!neighborUp(p)) + return 0; return 1; } Index: squid3/src/pconn.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/pconn.cc,v retrieving revision 1.3.2.16 retrieving revision 1.3.2.17 diff -u -r1.3.2.16 -r1.3.2.17 --- squid3/src/pconn.cc 25 Dec 2007 15:47:51 -0000 1.3.2.16 +++ squid3/src/pconn.cc 21 Jan 2008 21:19:27 -0000 1.3.2.17 @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.3.2.16 2007/12/25 15:47:51 serassio Exp $ + * $Id: pconn.cc,v 1.3.2.17 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -139,7 +139,7 @@ { assert(nfds); - for (int i = 0; i< nfds; i++) { + for (int i=nfds-1; i>=0; i--) { if (!comm_has_pending_read_callback(fds[i])) { return fds[i]; } @@ -283,7 +283,7 @@ if (list == NULL) return -1; - int fd = list->findUseableFD(); + int fd = list->findUseableFD(); // search from the end. skip pending reads. if (fd >= 0) { Index: squid3/src/pconn.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/pconn.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid3/src/pconn.h 25 Dec 2007 15:47:51 -0000 1.1.2.6 +++ squid3/src/pconn.h 21 Jan 2008 21:19:27 -0000 1.1.2.7 @@ -19,10 +19,10 @@ ~IdleConnList(); int numIdle() { return nfds; } - int findFDIndex(int fd); + int findFDIndex(int fd); ///< search from the end of array void removeFD(int fd); void push(int fd); - int findUseableFD(); + int findUseableFD(); ///< find first from the end not pending read fd. void clearHandlers(int fd); private: Index: squid3/src/snmp_agent.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/snmp_agent.cc,v retrieving revision 1.4.2.10 retrieving revision 1.4.2.11 diff -u -r1.4.2.10 -r1.4.2.11 --- squid3/src/snmp_agent.cc 25 Dec 2007 15:47:51 -0000 1.4.2.10 +++ squid3/src/snmp_agent.cc 21 Jan 2008 21:19:27 -0000 1.4.2.11 @@ -1,5 +1,5 @@ /* - * $Id: snmp_agent.cc,v 1.4.2.10 2007/12/25 15:47:51 serassio Exp $ + * $Id: snmp_agent.cc,v 1.4.2.11 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -60,7 +60,7 @@ case SYSVMSIZ: Answer = snmp_var_new_integer(Var->name, Var->name_length, - mem_node::store_mem_size >> 10, + mem_node::StoreMemSize() >> 10, ASN_INTEGER); break; Index: squid3/src/stmem.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/stmem.cc,v retrieving revision 1.5.2.10 retrieving revision 1.5.2.11 diff -u -r1.5.2.10 -r1.5.2.11 --- squid3/src/stmem.cc 14 Aug 2007 09:31:22 -0000 1.5.2.10 +++ squid3/src/stmem.cc 21 Jan 2008 21:19:27 -0000 1.5.2.11 @@ -1,6 +1,6 @@ /* - * $Id: stmem.cc,v 1.5.2.10 2007/08/14 09:31:22 serassio Exp $ + * $Id: stmem.cc,v 1.5.2.11 2008/01/21 21:19:27 serassio Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -150,8 +150,6 @@ /* Adjust the ptr and len according to what was deposited in the page */ aNode->nodeBuffer.length += copyLen; - mem_node::store_mem_size += copyLen; - return copyLen; } Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.22.2.92 retrieving revision 1.22.2.93 diff -u -r1.22.2.92 -r1.22.2.93 --- squid3/src/structs.h 20 Jan 2008 15:39:17 -0000 1.22.2.92 +++ squid3/src/structs.h 21 Jan 2008 21:19:28 -0000 1.22.2.93 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.22.2.92 2008/01/20 15:39:17 serassio Exp $ + * $Id: structs.h,v 1.22.2.93 2008/01/21 21:19:28 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -917,6 +917,8 @@ unsigned int consume_body_data: 1; + +unsigned int chunked:1; }; struct _ipcache_addrs Index: squid3/src/wccp2.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/wccp2.cc,v retrieving revision 1.1.2.19 retrieving revision 1.1.2.20 diff -u -r1.1.2.19 -r1.1.2.20 --- squid3/src/wccp2.cc 25 Dec 2007 15:47:52 -0000 1.1.2.19 +++ squid3/src/wccp2.cc 21 Jan 2008 21:19:28 -0000 1.1.2.20 @@ -1,6 +1,6 @@ /* - * $Id: wccp2.cc,v 1.1.2.19 2007/12/25 15:47:52 serassio Exp $ + * $Id: wccp2.cc,v 1.1.2.20 2008/01/21 21:19:28 serassio Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven Wilton @@ -1889,7 +1889,7 @@ /* Update the value according the the "correct" formula */ - for (value++; (value & 0x1741) != value; value++) { + for (; (value & 0x1741) != value; value++) { assert(value <= 0x1741); }