This patch is generated from the squid3-largeobj branch of HEAD in squid3 Mon Aug 13 17:29:14 2007 GMT See http://devel.squid-cache.org/ Index: squid3/include/Range.h diff -u squid3/include/Range.h:1.7 squid3/include/Range.h:1.7.10.1 --- squid3/include/Range.h:1.7 Sun Apr 23 04:27:37 2006 +++ squid3/include/Range.h Mon Jun 18 13:59:33 2007 @@ -50,7 +50,7 @@ C start; C end; Range intersection (Range const &) const; - size_t size() const; + C size() const; }; template @@ -75,7 +75,7 @@ } template -size_t +C Range::size() const { return end > start ? end - start : 0; Index: squid3/include/util.h diff -u squid3/include/util.h:1.15 squid3/include/util.h:1.15.6.2 --- squid3/include/util.h:1.15 Sat Oct 14 06:51:15 2006 +++ squid3/include/util.h Thu Apr 19 22:49:07 2007 @@ -135,6 +135,7 @@ SQUIDCEXTERN double xdiv(double nom, double denom); SQUIDCEXTERN const char *xitoa(int num); +SQUIDCEXTERN const char *xint64toa(int64_t num); #if !HAVE_DRAND48 SQUIDCEXTERN double drand48(void); Index: squid3/lib/util.c diff -u squid3/lib/util.c:1.9 squid3/lib/util.c:1.9.6.2 --- squid3/lib/util.c:1.9 Fri Apr 6 05:54:12 2007 +++ squid3/lib/util.c Thu Apr 19 22:49:09 2007 @@ -919,6 +919,15 @@ return buf; } +/* int64_t to string */ +const char * +xint64toa(int64_t num) +{ + static char buf[24]; /* 2^64 = 18446744073709551616 */ + snprintf(buf, sizeof(buf), "%"PRId64, num); + return buf; +} + /* A default failure notifier when the main program hasn't installed any */ void default_failure_notify(const char *message) Index: squid3/src/AccessLogEntry.h diff -u squid3/src/AccessLogEntry.h:1.7 squid3/src/AccessLogEntry.h:1.7.10.3 --- squid3/src/AccessLogEntry.h:1.7 Sun May 28 17:50:18 2006 +++ squid3/src/AccessLogEntry.h Fri Apr 20 15:31:18 2007 @@ -95,9 +95,9 @@ } struct IN_ADDR caddr; - size_t size; - off_t highOffset; - size_t objectSize; + int64_t size; + int64_t highOffset; + int64_t objectSize; log_type code; int msec; const char *rfc931; Index: squid3/src/BodyPipe.cc diff -u squid3/src/BodyPipe.cc:1.3 squid3/src/BodyPipe.cc:1.2.10.3 --- squid3/src/BodyPipe.cc:1.3 Tue May 8 09:51:26 2007 +++ squid3/src/BodyPipe.cc Wed Aug 1 00:14:34 2007 @@ -43,7 +43,7 @@ theBuf.clean(); } -void BodyPipe::setBodySize(size_t aBodySize) +void BodyPipe::setBodySize(uint64_t aBodySize) { assert(!bodySizeKnown()); assert(aBodySize >= 0); @@ -58,13 +58,13 @@ debugs(91,7, HERE << "set body size" << status()); } -size_t BodyPipe::bodySize() const +uint64_t BodyPipe::bodySize() const { assert(bodySizeKnown()); - return static_cast(theBodySize); + return static_cast(theBodySize); } -bool BodyPipe::expectMoreAfter(size_t offset) const +bool BodyPipe::expectMoreAfter(uint64_t offset) const { assert(theGetSize <= offset); return offset < thePutSize || // buffer has more now or @@ -290,9 +290,9 @@ buf.append(" [", 2); - buf.Printf("%d<=%d", (int)theGetSize, (int)thePutSize); + buf.Printf("%"PRIu64"<=%"PRIu64, theGetSize, thePutSize); if (theBodySize >= 0) - buf.Printf("<=%d", (int)theBodySize); + buf.Printf("<=%"PRId64, theBodySize); else buf.append("<=?", 3); Index: squid3/src/BodyPipe.h diff -u squid3/src/BodyPipe.h:1.2 squid3/src/BodyPipe.h:1.2.10.1 --- squid3/src/BodyPipe.h:1.2 Thu Apr 5 21:50:40 2007 +++ squid3/src/BodyPipe.h Mon Jun 18 13:59:34 2007 @@ -52,7 +52,7 @@ public: BodyPipe &pipe; MemBuf &buf; - const size_t offset; // of current content, relative to the body start + const uint64_t offset; // of current content, relative to the body start protected: const size_t checkedOutSize; @@ -81,10 +81,10 @@ BodyPipe(Producer *aProducer); ~BodyPipe(); // asserts that producer and consumer are cleared - void setBodySize(size_t aSize); // set body size + void setBodySize(uint64_t aSize); // set body size bool bodySizeKnown() const { return theBodySize >= 0; } - size_t bodySize() const; - size_t consumedSize() const { return theGetSize; } + uint64_t bodySize() const; + uint64_t consumedSize() const { return theGetSize; } bool productionEnded() const { return !theProducer; } // called by producers @@ -99,7 +99,7 @@ void clearConsumer(); // aborts if still piping size_t getMoreData(MemBuf &buf); void consume(size_t size); - bool expectMoreAfter(size_t offset) const; + bool expectMoreAfter(uint64_t offset) const; bool exhausted() const; // saw eof/abort and all data consumed // start or continue consuming when there is no consumer @@ -140,12 +140,12 @@ AsyncCallWrapper(91,5, BodyPipe, tellBodyProducerAborted); private: - ssize_t theBodySize; // expected total content length, if known + int64_t theBodySize; // expected total content length, if known Producer *theProducer; // content producer, if any Consumer *theConsumer; // content consumer, if any - size_t thePutSize; // ever-increasing total - size_t theGetSize; // ever-increasing total + uint64_t thePutSize; // ever-increasing total + uint64_t theGetSize; // ever-increasing total MemBuf theBuf; // produced but not yet consumed content, if any Index: squid3/src/HttpHdrContRange.cc diff -u squid3/src/HttpHdrContRange.cc:1.6 squid3/src/HttpHdrContRange.cc:1.3.26.4 --- squid3/src/HttpHdrContRange.cc:1.6 Fri May 4 13:51:55 2007 +++ squid3/src/HttpHdrContRange.cc Mon Jun 18 13:59:34 2007 @@ -81,16 +81,16 @@ } /* parse offset */ - if (!httpHeaderParseSize(field, &spec->offset)) + if (!httpHeaderParseOffset(field, &spec->offset)) return 0; p++; /* do we have last-pos ? */ if (p - field < flen) { - ssize_t last_pos; + int64_t last_pos; - if (!httpHeaderParseSize(p, &last_pos)) + if (!httpHeaderParseOffset(p, &last_pos)) return 0; spec->length = size_diff(last_pos + 1, spec->offset); @@ -100,7 +100,7 @@ assert (spec->length >= 0); /* we managed to parse, check if the result makes sence */ - if (known_spec((size_t)spec->length) && spec->length == 0) { + if (known_spec(spec->length) && spec->length == 0) { debugs(68, 2, "invalid range (" << spec->offset << " += " << (long int) spec->length << ") in resp-range-spec near: '" << field << "'"); return 0; @@ -115,11 +115,11 @@ /* Ensure typecast is safe */ assert (spec->length >= 0); - if (!known_spec((size_t)spec->offset) || !known_spec((size_t)spec->length)) + if (!known_spec(spec->offset) || !known_spec(spec->length)) packerPrintf(p, "*"); else - packerPrintf(p, "bytes %ld-%ld", - (long int) spec->offset, (long int) spec->offset + spec->length - 1); + packerPrintf(p, "bytes %"PRId64"-%"PRId64, + spec->offset, spec->offset + spec->length - 1); } /* @@ -175,7 +175,7 @@ if (*p == '*') range->elength = range_spec_unknown; - else if (!httpHeaderParseSize(p, &range->elength)) + else if (!httpHeaderParseOffset(p, &range->elength)) return 0; debugs(68, 8, "parsed content-range field: " << @@ -211,14 +211,14 @@ /* Ensure typecast is safe */ assert (range->elength >= 0); - if (!known_spec((size_t)range->elength)) + if (!known_spec(range->elength)) packerPrintf(p, "/*"); else - packerPrintf(p, "/%ld", (long int) range->elength); + packerPrintf(p, "/%"PRId64, range->elength); } void -httpHdrContRangeSet(HttpHdrContRange * cr, HttpHdrRangeSpec spec, ssize_t ent_len) +httpHdrContRangeSet(HttpHdrContRange * cr, HttpHdrRangeSpec spec, int64_t ent_len) { assert(cr && ent_len >= 0); cr->spec = spec; Index: squid3/src/HttpHdrContRange.h diff -u squid3/src/HttpHdrContRange.h:1.4 squid3/src/HttpHdrContRange.h:1.4.10.1 --- squid3/src/HttpHdrContRange.h:1.4 Sun Apr 23 04:27:37 2006 +++ squid3/src/HttpHdrContRange.h Mon Jun 18 13:59:34 2007 @@ -43,7 +43,7 @@ public: HttpHdrRangeSpec spec; - ssize_t elength; /* entity length, not content length */ + int64_t elength; /* entity length, not content length */ }; /* Http Content Range Header Field */ @@ -55,9 +55,9 @@ SQUIDCEXTERN HttpHdrContRange *httpHdrContRangeDup(const HttpHdrContRange * crange); SQUIDCEXTERN void httpHdrContRangePackInto(const HttpHdrContRange * crange, Packer * p); /* inits with given spec */ -SQUIDCEXTERN void httpHdrContRangeSet(HttpHdrContRange *, HttpHdrRangeSpec, ssize_t); +SQUIDCEXTERN void httpHdrContRangeSet(HttpHdrContRange *, HttpHdrRangeSpec, int64_t); ; -SQUIDCEXTERN void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, ssize_t); +SQUIDCEXTERN void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t); #endif /* SQUID_HTTPHDRCONTRANGE_H */ Index: squid3/src/HttpHdrRange.cc diff -u squid3/src/HttpHdrRange.cc:1.17 squid3/src/HttpHdrRange.cc:1.13.10.5 --- squid3/src/HttpHdrRange.cc:1.17 Tue May 29 06:51:37 2007 +++ squid3/src/HttpHdrRange.cc Wed Aug 8 00:27:26 2007 @@ -63,7 +63,7 @@ /* globals */ size_t HttpHdrRange::ParsedCount = 0; -ssize_t const HttpHdrRangeSpec::UnknownPosition = -1; +int64_t const HttpHdrRangeSpec::UnknownPosition = -1; /* * Range-Spec @@ -93,7 +93,7 @@ /* is it a suffix-byte-range-spec ? */ if (*field == '-') { - if (!httpHeaderParseSize(field + 1, &length)) + if (!httpHeaderParseOffset(field + 1, &length)) return false; } else /* must have a '-' somewhere in _this_ field */ @@ -101,16 +101,16 @@ debugs(64, 2, "ignoring invalid (missing '-') range-spec near: '" << field << "'"); return false; } else { - if (!httpHeaderParseSize(field, &offset)) + if (!httpHeaderParseOffset(field, &offset)) return false; p++; /* do we have last-pos ? */ if (p - field < flen) { - ssize_t last_pos; + int64_t last_pos; - if (!httpHeaderParseSize(p, &last_pos)) + if (!httpHeaderParseOffset(p, &last_pos)) return false; HttpHdrRangeSpec::HttpRange aSpec (offset, last_pos + 1); @@ -132,20 +132,20 @@ HttpHdrRangeSpec::packInto(Packer * packer) const { if (!known_spec(offset)) /* suffix */ - packerPrintf(packer, "-%ld", (long int) length); + packerPrintf(packer, "-%"PRId64, length); else if (!known_spec(length)) /* trailer */ - packerPrintf(packer, "%ld-", (long int) offset); + packerPrintf(packer, "%"PRId64"-", offset); else /* range */ - packerPrintf(packer, "%ld-%ld", - (long int) offset, (long int) offset + length - 1); + packerPrintf(packer, "%"PRId64"-%"PRId64, + offset, offset + length - 1); } void HttpHdrRangeSpec::outputInfo( char const *note) const { debugs(64, 5, "HttpHdrRangeSpec::canonize: " << note << ": [" << - (long int) offset << ", " << (long int) offset + length << - ") len: " << (long int) length); + offset << ", " << offset + length << + ") len: " << length); } /* fills "absent" positions in range specification based on response body size @@ -153,7 +153,7 @@ * range is valid if its intersection with [0,length-1] is not empty */ int -HttpHdrRangeSpec::canonize(size_t clen) +HttpHdrRangeSpec::canonize(int64_t clen) { outputInfo ("have"); HttpRange object(0, clen); @@ -190,8 +190,8 @@ bool merged (false); #if MERGING_BREAKS_NOTHING /* Note: this code works, but some clients may not like its effects */ - size_t rhs = offset + length; /* no -1 ! */ - const size_t donor_rhs = donor->offset + donor->length; /* no -1 ! */ + int64_t rhs = offset + length; /* no -1 ! */ + const int64_t donor_rhs = donor->offset + donor->length; /* no -1 ! */ assert(known_spec(offset)); assert(known_spec(donor->offset)); assert(length > 0); @@ -402,7 +402,7 @@ } int -HttpHdrRange::canonize (size_t newClen) +HttpHdrRange::canonize (int64_t newClen) { clen = newClen; debugs(64, 3, "HttpHdrRange::canonize: started with " << specs.count << @@ -420,7 +420,7 @@ bool HttpHdrRange::isComplex() const { - size_t offset = 0; + int64_t offset = 0; assert(this); /* check that all rangers are in "strong" order */ const_iterator pos (begin()); @@ -429,7 +429,7 @@ /* Ensure typecasts is safe */ assert ((*pos)->offset >= 0); - if ((unsigned int)(*pos)->offset < offset) + if ((*pos)->offset < offset) return 1; offset = (*pos)->offset + (*pos)->length; @@ -450,7 +450,7 @@ assert(this); /* check that all rangers are in "strong" order, */ /* as far as we can tell without the content length */ - size_t offset = 0; + int64_t offset = 0; for (const_iterator pos (begin()); pos != end(); ++pos) { if (!known_spec((*pos)->offset)) /* ignore unknowns */ @@ -459,7 +459,7 @@ /* Ensure typecasts is safe */ assert ((*pos)->offset >= 0); - if ((size_t) (*pos)->offset < offset) + if ((*pos)->offset < offset) return true; offset = (*pos)->offset; @@ -476,10 +476,10 @@ * or HttpHdrRangeSpec::UnknownPosition * this is used for size limiting */ -ssize_t +int64_t HttpHdrRange::firstOffset() const { - ssize_t offset = HttpHdrRangeSpec::UnknownPosition; + int64_t offset = HttpHdrRangeSpec::UnknownPosition; assert(this); const_iterator pos = begin(); @@ -499,15 +499,15 @@ * ranges are combined into one, for example FTP REST. * Use 0 for size if unknown */ -ssize_t -HttpHdrRange::lowestOffset(ssize_t size) const +int64_t +HttpHdrRange::lowestOffset(int64_t size) const { - ssize_t offset = HttpHdrRangeSpec::UnknownPosition; + int64_t offset = HttpHdrRangeSpec::UnknownPosition; const_iterator pos = begin(); assert(this); while (pos != end()) { - ssize_t current = (*pos)->offset; + int64_t current = (*pos)->offset; if (!known_spec(current)) { if ((*pos)->length > size || !known_spec((*pos)->length)) @@ -538,7 +538,7 @@ /* not a range request */ return false; - if (-1 == (ssize_t)Config.rangeOffsetLimit) + if (-1 == Config.rangeOffsetLimit) /* disabled */ return false; @@ -546,7 +546,7 @@ /* tail request */ return true; - if ((ssize_t)Config.rangeOffsetLimit >= firstOffset()) + if (Config.rangeOffsetLimit >= firstOffset()) /* below the limit */ return false; @@ -590,14 +590,14 @@ } } -ssize_t +int64_t HttpHdrRangeIter::debt() const { debugs(64, 3, "HttpHdrRangeIter::debt: debt is " << debt_size); return debt_size; } -void HttpHdrRangeIter::debt(ssize_t newDebt) +void HttpHdrRangeIter::debt(int64_t newDebt) { debugs(64, 3, "HttpHdrRangeIter::debt: was " << debt_size << " now " << newDebt); debt_size = newDebt; Index: squid3/src/HttpHeader.cc diff -u squid3/src/HttpHeader.cc:1.46 squid3/src/HttpHeader.cc:1.40.6.7 --- squid3/src/HttpHeader.cc:1.46 Tue May 29 06:51:39 2007 +++ squid3/src/HttpHeader.cc Wed May 9 00:36:17 2007 @@ -86,7 +86,7 @@ {"Content-Base", HDR_CONTENT_BASE, ftStr}, {"Content-Encoding", HDR_CONTENT_ENCODING, ftStr}, {"Content-Language", HDR_CONTENT_LANGUAGE, ftStr}, - {"Content-Length", HDR_CONTENT_LENGTH, ftInt}, + {"Content-Length", HDR_CONTENT_LENGTH, ftInt64}, {"Content-Location", HDR_CONTENT_LOCATION, ftStr}, {"Content-MD5", HDR_CONTENT_MD5, ftStr}, /* for now */ {"Content-Range", HDR_CONTENT_RANGE, ftPContRange}, @@ -1025,6 +1025,15 @@ } void +HttpHeader::putInt64(http_hdr_type id, int64_t number) +{ + assert_eid(id); + assert(Headers[id].type == ftInt64); /* must be of an appropriate type */ + assert(number >= 0); + addEntry(new HttpHeaderEntry(id, NULL, xint64toa(number))); +} + +void HttpHeader::putTime(http_hdr_type id, time_t htime) { assert_eid(id); @@ -1156,6 +1165,19 @@ return -1; } +int64_t +HttpHeader::getInt64(http_hdr_type id) const +{ + assert_eid(id); + assert(Headers[id].type == ftInt64); /* must be of an appropriate type */ + HttpHeaderEntry *e; + + if ((e = findEntry(id))) + return e->getInt64(); + + return -1; +} + time_t HttpHeader::getTime(http_hdr_type id) const { @@ -1510,6 +1532,20 @@ return val; } +int64_t +HttpHeaderEntry::getInt64() const +{ + assert_eid (id); + assert (Headers[id].type == ftInt64); + int64_t val = -1; + int ok = httpHeaderParseOffset(value.buf(), &val); + httpHeaderNoteParsedEntry(id, value, !ok); + /* XXX: Should we check ok - ie + * return ok ? -1 : value; + */ + return val; +} + static void httpHeaderNoteParsedEntry(http_hdr_type id, String const &context, int error) { Index: squid3/src/HttpHeader.h diff -u squid3/src/HttpHeader.h:1.22 squid3/src/HttpHeader.h:1.18.6.5 --- squid3/src/HttpHeader.h:1.22 Wed Aug 1 16:50:53 2007 +++ squid3/src/HttpHeader.h Sun Aug 12 00:25:25 2007 @@ -124,6 +124,7 @@ typedef enum { ftInvalid = HDR_ENUM_END, /* to catch nasty errors with hdr_id<->fld_type clashes */ ftInt, + ftInt64, ftStr, ftDate_1123, ftETag, @@ -181,6 +182,7 @@ HttpHeaderEntry *clone() const; void packInto(Packer *p) const; int getInt() const; + int64_t getInt64() const; MEMPROXY_CLASS(HttpHeaderEntry); http_hdr_type id; String name; @@ -219,6 +221,7 @@ String getListMember(http_hdr_type id, const char *member, const char separator) const; int has(http_hdr_type id) const; void putInt(http_hdr_type id, int number); + void putInt64(http_hdr_type id, int64_t number); void putTime(http_hdr_type id, time_t htime); void insertTime(http_hdr_type id, time_t htime); void putStr(http_hdr_type id, const char *str); @@ -229,6 +232,7 @@ void putSc(HttpHdrSc *sc); void putExt(const char *name, const char *value); int getInt(http_hdr_type id) const; + int64_t getInt64(http_hdr_type id) const; time_t getTime(http_hdr_type id) const; const char *getStr(http_hdr_type id) const; const char *getLastStr(http_hdr_type id) const; Index: squid3/src/HttpHeaderRange.h diff -u squid3/src/HttpHeaderRange.h:1.11 squid3/src/HttpHeaderRange.h:1.9.10.1 --- squid3/src/HttpHeaderRange.h:1.11 Tue May 29 06:51:39 2007 +++ squid3/src/HttpHeaderRange.h Mon Jun 18 13:59:34 2007 @@ -48,19 +48,19 @@ public: MEMPROXY_CLASS(HttpHdrRangeSpec); - typedef Range HttpRange; - static ssize_t const UnknownPosition; + typedef Range HttpRange; + static int64_t const UnknownPosition; HttpHdrRangeSpec(); static HttpHdrRangeSpec *Create(const char *field, int fieldLen); bool parseInit(const char *field, int flen); - int canonize(size_t clen); + int canonize(int64_t clen); void outputInfo( char const *note) const; void packInto(Packer * p) const; bool mergeWith(const HttpHdrRangeSpec * donor); - ssize_t offset; - ssize_t length; + int64_t offset; + int64_t length; }; MEMPROXY_CLASS_INLINE(HttpHdrRangeSpec) @@ -93,7 +93,7 @@ const_iterator end() const; /* adjust specs after the length is known */ - int canonize(size_t); + int canonize(int64_t); int canonize(HttpReply *rep); /* returns true if ranges are valid; inits HttpHdrRange */ bool parseInit(const String * range_spec); @@ -101,8 +101,8 @@ /* other */ bool isComplex() const; bool willBeComplex() const; - ssize_t firstOffset() const; - ssize_t lowestOffset(ssize_t) const; + int64_t firstOffset() const; + int64_t lowestOffset(int64_t) const; bool offsetLimitExceeded() const; bool contains(HttpHdrRangeSpec& r) const; Vector specs; @@ -110,7 +110,7 @@ private: void getCanonizedSpecs (Vector ©); void merge (Vector &basis); - ssize_t clen; + int64_t clen; }; MEMPROXY_CLASS_INLINE(HttpHdrRange) @@ -124,9 +124,9 @@ HttpHdrRange::iterator pos; const HttpHdrRangeSpec *currentSpec() const; void updateSpec(); - ssize_t debt() const; - void debt(ssize_t); - ssize_t debt_size; /* bytes left to send from the current spec */ + int64_t debt() const; + void debt(int64_t); + int64_t debt_size; /* bytes left to send from the current spec */ String boundary; /* boundary for multipart responses */ bool valid; }; Index: squid3/src/HttpHeaderTools.cc diff -u squid3/src/HttpHeaderTools.cc:1.26 squid3/src/HttpHeaderTools.cc:1.21.6.6 --- squid3/src/HttpHeaderTools.cc:1.26 Tue May 29 06:51:39 2007 +++ squid3/src/HttpHeaderTools.cc Mon Jun 18 13:59:34 2007 @@ -143,7 +143,7 @@ /* wrapper arrounf PutContRange */ void -httpHeaderAddContRange(HttpHeader * hdr, HttpHdrRangeSpec spec, ssize_t ent_len) +httpHeaderAddContRange(HttpHeader * hdr, HttpHdrRangeSpec spec, int64_t ent_len) { HttpHdrContRange *cr = httpHdrContRangeCreate(); assert(hdr && ent_len >= 0); @@ -342,6 +342,16 @@ return res; } +int +httpHeaderParseOffset(const char *start, int64_t * value) +{ + int64_t res = strtoll(start, NULL, 10); + if (!res && EINVAL == errno) /* maybe not portable? */ + return 0; + *value = res; + return 1; +} + /* Parses a quoted-string field (RFC 2616 section 2.2), complains if * something went wrong, returns non-zero on success. Index: squid3/src/HttpMsg.cc diff -u squid3/src/HttpMsg.cc:1.30 squid3/src/HttpMsg.cc:1.29.6.3 --- squid3/src/HttpMsg.cc:1.30 Sat Apr 28 15:51:48 2007 +++ squid3/src/HttpMsg.cc Mon Apr 30 10:08:09 2007 @@ -355,7 +355,7 @@ void HttpMsg::hdrCacheInit() { - content_length = header.getInt(HDR_CONTENT_LENGTH); + content_length = header.getInt64(HDR_CONTENT_LENGTH); assert(NULL == cache_control); cache_control = header.getCc(); } Index: squid3/src/HttpMsg.h diff -u squid3/src/HttpMsg.h:1.14 squid3/src/HttpMsg.h:1.14.6.3 --- squid3/src/HttpMsg.h:1.14 Thu Apr 5 22:52:34 2007 +++ squid3/src/HttpMsg.h Mon Jun 18 13:59:34 2007 @@ -67,7 +67,7 @@ * Also used to report parsed header size if parse() is successful */ int hdr_sz; - int content_length; + int64_t content_length; protocol_t protocol; @@ -86,7 +86,7 @@ virtual int httpMsgParseError(); - virtual bool expectingBody(method_t, ssize_t&) const = 0; + virtual bool expectingBody(method_t, int64_t&) const = 0; void firstLineBuf(MemBuf&); Index: squid3/src/HttpReply.cc diff -u squid3/src/HttpReply.cc:1.42 squid3/src/HttpReply.cc:1.38.6.5 --- squid3/src/HttpReply.cc:1.42 Tue May 29 06:51:39 2007 +++ squid3/src/HttpReply.cc Mon Jun 18 13:59:34 2007 @@ -155,7 +155,7 @@ MemBuf * httpPackedReply(HttpVersion ver, http_status status, const char *ctype, - int clen, time_t lmt, time_t expires) + int64_t clen, time_t lmt, time_t expires) { HttpReply *rep = new HttpReply; rep->setHeaders(ver, status, ctype, NULL, clen, lmt, expires); @@ -207,7 +207,7 @@ void HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason, - const char *ctype, int clen, time_t lmt, time_t expires) + const char *ctype, int64_t clen, time_t lmt, time_t expires) { HttpHeader *hdr; httpStatusLineSet(&sline, ver, status, reason); @@ -223,7 +223,7 @@ content_type = String(); if (clen >= 0) - hdr->putInt(HDR_CONTENT_LENGTH, clen); + hdr->putInt64(HDR_CONTENT_LENGTH, clen); if (expires >= 0) hdr->putTime(HDR_EXPIRES, expires); @@ -249,7 +249,7 @@ hdr = &header; hdr->putStr(HDR_SERVER, full_appname_string); hdr->putTime(HDR_DATE, squid_curtime); - hdr->putInt(HDR_CONTENT_LENGTH, 0); + hdr->putInt64(HDR_CONTENT_LENGTH, 0); hdr->putStr(HDR_LOCATION, loc); date = squid_curtime; content_length = 0; @@ -372,7 +372,7 @@ { HttpMsg::hdrCacheInit(); - content_length = header.getInt(HDR_CONTENT_LENGTH); + content_length = header.getInt64(HDR_CONTENT_LENGTH); date = header.getTime(HDR_DATE); last_modified = header.getTime(HDR_LAST_MODIFIED); surrogate_control = header.getSc(); @@ -414,7 +414,7 @@ /* * Returns the body size of a HTTP response */ -int +int64_t HttpReply::bodySize(method_t method) const { if (sline.version.major < 1) @@ -469,7 +469,7 @@ * along with this response */ bool -HttpReply::expectingBody(method_t req_method, ssize_t& theSize) const +HttpReply::expectingBody(method_t req_method, int64_t& theSize) const { bool expectBody = true; Index: squid3/src/HttpReply.h diff -u squid3/src/HttpReply.h:1.20 squid3/src/HttpReply.h:1.18.10.3 --- squid3/src/HttpReply.h:1.20 Tue May 29 06:51:39 2007 +++ squid3/src/HttpReply.h Mon Jun 18 13:59:34 2007 @@ -39,7 +39,7 @@ extern void httpReplyInitModule(void); /* do everything in one call: init, set, pack, clean, return MemBuf */ -extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int clen, time_t lmt, time_t expires); +extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires); /* Sync changes here with HttpReply.cc */ @@ -97,7 +97,7 @@ public: virtual int httpMsgParseError(); - virtual bool expectingBody(method_t, ssize_t&) const; + virtual bool expectingBody(method_t, int64_t&) const; void updateOnNotModified(HttpReply const *other); @@ -106,7 +106,7 @@ /* set commonly used info with one call */ void setHeaders(HttpVersion ver, http_status status, - const char *reason, const char *ctype, int clen, time_t lmt, time_t expires); + const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires); /* mem-pack: returns a ready to use mem buffer with a packed reply */ MemBuf *pack(); @@ -116,7 +116,7 @@ void redirect(http_status, const char *); - int bodySize(method_t) const; + int64_t bodySize(method_t) const; int validatorsMatch (HttpReply const *other) const; Index: squid3/src/HttpRequest.cc diff -u squid3/src/HttpRequest.cc:1.42 squid3/src/HttpRequest.cc:1.38.2.3 --- squid3/src/HttpRequest.cc:1.42 Tue May 29 06:51:39 2007 +++ squid3/src/HttpRequest.cc Sun Jul 22 01:50:26 2007 @@ -370,7 +370,7 @@ * along with this request */ bool -HttpRequest::expectingBody(method_t unused, ssize_t& theSize) const +HttpRequest::expectingBody(method_t unused, int64_t& theSize) const { bool expectBody = false; Index: squid3/src/HttpRequest.h diff -u squid3/src/HttpRequest.h:1.29 squid3/src/HttpRequest.h:1.26.2.2 --- squid3/src/HttpRequest.h:1.29 Tue May 29 06:51:39 2007 +++ squid3/src/HttpRequest.h Sun Jul 22 01:50:26 2007 @@ -135,7 +135,7 @@ int parseHeader(const char *parse_start, int len); - virtual bool expectingBody(method_t unused, ssize_t&) const; + virtual bool expectingBody(method_t unused, int64_t&) const; bool bodyNibbled() const; // the request has a [partially] consumed body Index: squid3/src/Makefile.am diff -u squid3/src/Makefile.am:1.122 squid3/src/Makefile.am:1.116.4.6 --- squid3/src/Makefile.am:1.122 Tue Jun 19 15:51:04 2007 +++ squid3/src/Makefile.am Wed Aug 8 00:28:54 2007 @@ -584,6 +584,8 @@ StoreMetaMD5.h \ StoreMetaSTD.cc \ StoreMetaSTD.h \ + StoreMetaSTDLFS.cc \ + StoreMetaSTDLFS.h \ StoreMetaUnpacker.cc \ StoreMetaUnpacker.h \ StoreMetaURL.cc \ @@ -732,6 +734,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -1358,6 +1361,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -1522,6 +1526,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -1673,6 +1678,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -1852,6 +1858,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -2006,6 +2013,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -2155,6 +2163,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ @@ -2341,6 +2350,7 @@ StoreMeta.cc \ StoreMetaMD5.cc \ StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ Index: squid3/src/MemObject.cc diff -u squid3/src/MemObject.cc:1.26 squid3/src/MemObject.cc:1.22.6.7 --- squid3/src/MemObject.cc:1.26 Tue May 29 06:51:39 2007 +++ squid3/src/MemObject.cc Wed Aug 1 13:41:47 2007 @@ -186,7 +186,7 @@ struct LowestMemReader : public unary_function { - LowestMemReader(off_t seed):current(seed){} + LowestMemReader(int64_t seed):current(seed){} void operator() (store_client const &x) { @@ -194,7 +194,7 @@ current = x.copyInto.offset; } - off_t current; + int64_t current; }; struct StoreClientStats : public unary_function @@ -215,27 +215,27 @@ { mb->Printf("\t%s %s\n", RequestMethodStr[method], log_url); - mb->Printf("\tinmem_lo: %d\n", (int) inmem_lo); - mb->Printf("\tinmem_hi: %d\n", (int) data_hdr.endOffset()); - mb->Printf("\tswapout: %d bytes queued\n", - (int) swapout.queue_offset); + mb->Printf("\tinmem_lo: %"PRId64"\n", inmem_lo); + mb->Printf("\tinmem_hi: %"PRId64"\n", data_hdr.endOffset()); + mb->Printf("\tswapout: %"PRId64" bytes queued\n", + swapout.queue_offset); if (swapout.sio.getRaw()) - mb->Printf("\tswapout: %d bytes written\n", - (int) swapout.sio->offset()); + mb->Printf("\tswapout: %"PRId64" bytes written\n", + (int64_t) swapout.sio->offset()); StoreClientStats statsVisitor(mb); for_each(clients, statsVisitor); } -off_t +int64_t MemObject::endOffset () const { return data_hdr.endOffset(); } -size_t +int64_t MemObject::size() const { if (object_sz < 0) @@ -254,7 +254,7 @@ } -off_t +int64_t MemObject::lowestMemReaderOffset() const { LowestMemReader lowest (endOffset() + 1); @@ -268,7 +268,7 @@ bool MemObject::readAheadPolicyCanRead() const { - return (size_t)endOffset() - getReply()->hdr_sz < lowestMemReaderOffset() + (Config.readAheadGap << 10); + return endOffset() - getReply()->hdr_sz < lowestMemReaderOffset() + Config.readAheadGap; } void @@ -290,7 +290,7 @@ /* * How much of the object data is on the disk? */ -size_t +int64_t MemObject::objectBytesOnDisk() const { /* @@ -308,25 +308,25 @@ if (swapout.sio.getRaw() == NULL) return 0; - off_t nwritten = swapout.sio->offset(); + int64_t nwritten = swapout.sio->offset(); - if (nwritten <= (off_t)swap_hdr_sz) + if (nwritten <= swap_hdr_sz) return 0; - return (size_t) (nwritten - swap_hdr_sz); + return (nwritten - swap_hdr_sz); } -off_t +int64_t MemObject::policyLowestOffsetToKeep() const { /* * Careful. lowest_offset can be greater than endOffset(), such * as in the case of a range request. */ - off_t lowest_offset = lowestMemReaderOffset(); + int64_t lowest_offset = lowestMemReaderOffset(); if (endOffset() < lowest_offset || - endOffset() - inmem_lo > (ssize_t)Config.Store.maxInMemObjSize) + endOffset() - inmem_lo > Config.Store.maxInMemObjSize) return lowest_offset; return inmem_lo; @@ -335,7 +335,7 @@ void MemObject::trimSwappable() { - off_t new_mem_lo = policyLowestOffsetToKeep(); + int64_t new_mem_lo = policyLowestOffsetToKeep(); /* * We should only free up to what we know has been written * to disk, not what has been queued for writing. Otherwise @@ -344,7 +344,7 @@ * The -1 makes sure the page isn't freed until storeSwapOut has * walked to the next page. (mem->swapout.memnode) */ - off_t on_disk; + int64_t on_disk; if ((on_disk = objectBytesOnDisk()) - 1 < new_mem_lo) new_mem_lo = on_disk - 1; @@ -360,7 +360,7 @@ void MemObject::trimUnSwappable() { - off_t new_mem_lo = policyLowestOffsetToKeep(); + int64_t new_mem_lo = policyLowestOffsetToKeep(); assert (new_mem_lo > 0); data_hdr.freeDataUpto(new_mem_lo); @@ -371,7 +371,7 @@ bool MemObject::isContiguous() const { - bool result = data_hdr.hasContigousContentRange (Range(inmem_lo, endOffset())); + bool result = data_hdr.hasContigousContentRange (Range(inmem_lo, endOffset())); /* XXX : make this higher level */ debugs (19, result ? 4 :3, "MemObject::isContiguous: Returning " << (result ? "true" : "false")); return result; Index: squid3/src/MemObject.h diff -u squid3/src/MemObject.h:1.14 squid3/src/MemObject.h:1.13.10.4 --- squid3/src/MemObject.h:1.14 Fri Apr 20 00:58:35 2007 +++ squid3/src/MemObject.h Tue Jul 31 14:09:45 2007 @@ -63,17 +63,17 @@ HttpReply const *getReply() const; void replaceHttpReply(HttpReply *newrep); void stat (MemBuf * mb) const; - off_t endOffset () const; - size_t size() const; + int64_t endOffset () const; + int64_t size() const; void reset(); - off_t lowestMemReaderOffset() const; + int64_t lowestMemReaderOffset() const; bool readAheadPolicyCanRead() const; void addClient(store_client *); /* XXX belongs in MemObject::swapout, once swaphdrsz is managed * better */ - size_t objectBytesOnDisk() const; - off_t policyLowestOffsetToKeep() const; + int64_t objectBytesOnDisk() const; + int64_t policyLowestOffsetToKeep() const; void trimSwappable(); void trimUnSwappable(); bool isContiguous() const; @@ -93,7 +93,7 @@ method_t method; char *url; mem_hdr data_hdr; - off_t inmem_lo; + int64_t inmem_lo; dlink_list clients; /* TODO: move into .cc or .cci */ size_t clientCount() const {return nclients;} @@ -106,7 +106,7 @@ { public: - off_t queue_offset; /* relative to in-mem data */ + int64_t queue_offset; /* relative to in-mem data */ mem_node *memnode; /* which node we're currently paging out */ StoreIOState::Pointer sio; }; @@ -130,7 +130,7 @@ char *log_url; RemovalPolicyNode repl; int id; - ssize_t object_sz; + int64_t object_sz; size_t swap_hdr_sz; #if URL_CHECKSUM_DEBUG Index: squid3/src/Parsing.cc diff -u squid3/src/Parsing.cc:1.3 squid3/src/Parsing.cc:1.3.6.1 --- squid3/src/Parsing.cc:1.3 Sun Oct 8 06:51:46 2006 +++ squid3/src/Parsing.cc Mon Jun 18 13:59:34 2007 @@ -125,3 +125,23 @@ return false; } + +bool +StringToInt64(const char *s, int64_t &result, const char **p, int base) +{ + if (s) { + char *ptr = 0; + const int64_t h = (int64_t) strtoll(s, &ptr, base); + + if (ptr != s && ptr) { + result = h; + + if (p) + *p = ptr; + + return true; + } + } + + return false; +} Index: squid3/src/Parsing.h diff -u squid3/src/Parsing.h:1.3 squid3/src/Parsing.h:1.3.6.1 --- squid3/src/Parsing.h:1.3 Sun Oct 8 06:51:46 2006 +++ squid3/src/Parsing.h Mon Jun 18 13:59:34 2007 @@ -47,5 +47,6 @@ // on success, returns true and sets *p (if any) to the end of the integer extern bool StringToInt(const char *str, int &result, const char **p, int base); +extern bool StringToInt64(const char *str, int64_t &result, const char **p, int base); #endif /* SQUID_PARSING_H */ Index: squid3/src/Server.cc diff -u squid3/src/Server.cc:1.18 squid3/src/Server.cc:1.6.6.6 --- squid3/src/Server.cc:1.18 Thu Aug 9 16:51:10 2007 +++ squid3/src/Server.cc Sun Aug 12 00:25:25 2007 @@ -386,9 +386,9 @@ // check whether we should be sending a body as well // start body pipe to feed ICAP transaction if needed assert(!virginBodyDestination); - HttpReply *vrep = virginReply(); + HttpReply *vrep = virginReply(); assert(!vrep->body_pipe); - ssize_t size = 0; + int64_t size = 0; if (vrep->expectingBody(cause->method, size) && size) { virginBodyDestination = new BodyPipe(this); vrep->body_pipe = virginBodyDestination; Index: squid3/src/Store.h diff -u squid3/src/Store.h:1.34 squid3/src/Store.h:1.27.2.6 --- squid3/src/Store.h:1.34 Tue May 29 06:51:40 2007 +++ squid3/src/Store.h Mon Jun 18 13:59:34 2007 @@ -127,7 +127,7 @@ time_t lastref; time_t expires; time_t lastmod; - size_t swap_file_sz; + uint64_t swap_file_sz; u_short refcount; u_short flags; /* END OF ON-DISK STORE_META_STD */ @@ -178,8 +178,8 @@ /* reduce the memory lock count on the entry */ virtual int unlock(); /* increate the memory lock count on the entry */ - virtual ssize_t objectLen() const; - virtual int contentLen() const; + virtual int64_t objectLen() const; + virtual int64_t contentLen() const; virtual void lock() @@ -292,7 +292,7 @@ virtual void maintain() = 0; /* perform regular maintenance should be private and self registered ... */ /* These should really be private */ - virtual void updateSize(size_t size, int sign) = 0; + virtual void updateSize(int64_t size, int sign) = 0; private: static RefCount CurrentRoot; @@ -301,6 +301,9 @@ typedef RefCount StorePointer; SQUIDCEXTERN size_t storeEntryInUse(); +#if UNUSED_CODE_20070420 +SQUIDCEXTERN off_t storeLowestMemReaderOffset(const StoreEntry * entry); +#endif SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *); extern void storeEntryReplaceObject(StoreEntry *, HttpReply *); Index: squid3/src/StoreClient.h diff -u squid3/src/StoreClient.h:1.13 squid3/src/StoreClient.h:1.13.10.1 --- squid3/src/StoreClient.h:1.13 Mon May 22 13:50:47 2006 +++ squid3/src/StoreClient.h Fri Apr 20 15:31:21 2007 @@ -64,7 +64,7 @@ void operator delete (void *); store_client(StoreEntry *); ~store_client(); - bool memReaderHasLowerOffset(off_t) const; + bool memReaderHasLowerOffset(int64_t) const; int getType() const; void fail(); void callback(ssize_t len, bool error = false); @@ -73,7 +73,7 @@ void copy(StoreEntry *, StoreIOBuffer, STCB *, void *); void dumpStats(MemBuf * output, int clientNumber) const; - off_t cmp_offset; + int64_t cmp_offset; #if STORE_CLIENT_LIST_DEBUG void *owner; Index: squid3/src/StoreHashIndex.h diff -u squid3/src/StoreHashIndex.h:1.4 squid3/src/StoreHashIndex.h:1.2.16.1 --- squid3/src/StoreHashIndex.h:1.4 Tue May 29 06:51:40 2007 +++ squid3/src/StoreHashIndex.h Mon Jun 18 13:59:34 2007 @@ -75,7 +75,7 @@ virtual void maintain(); - virtual void updateSize(size_t, int); + virtual void updateSize(int64_t, int); virtual StoreSearch *search(String const url, HttpRequest *); Index: squid3/src/StoreIOBuffer.h diff -u squid3/src/StoreIOBuffer.h:1.6 squid3/src/StoreIOBuffer.h:1.6.6.3 --- squid3/src/StoreIOBuffer.h:1.6 Sat Oct 14 06:51:15 2006 +++ squid3/src/StoreIOBuffer.h Fri Apr 20 15:31:21 2007 @@ -45,7 +45,7 @@ public: StoreIOBuffer():length(0), offset (0), data (NULL){flags.error = 0;} - StoreIOBuffer(size_t aLength, off_t anOffset, char *someData) : + StoreIOBuffer(size_t aLength, int64_t anOffset, char *someData) : length (aLength), offset (anOffset), data (someData) { flags.error = 0; @@ -53,7 +53,7 @@ /* Create a StoreIOBuffer from a MemBuf and offset */ /* NOTE that MemBuf still "owns" the pointers, StoreIOBuffer is just borrowing them */ - StoreIOBuffer(MemBuf *aMemBuf, off_t anOffset) : + StoreIOBuffer(MemBuf *aMemBuf, int64_t anOffset) : length(aMemBuf->contentSize()), offset (anOffset), data(aMemBuf->content()) @@ -61,9 +61,9 @@ flags.error = 0; } - Range range() const + Range range() const { - return Range(offset, offset + length); + return Range(offset, offset + length); } void dump() const @@ -81,7 +81,7 @@ flags; size_t length; - off_t offset; + int64_t offset; char *data; }; Index: squid3/src/StoreMeta.cc diff -u squid3/src/StoreMeta.cc:1.5 squid3/src/StoreMeta.cc:1.4.24.3 --- squid3/src/StoreMeta.cc:1.5 Sat Apr 28 15:51:48 2007 +++ squid3/src/StoreMeta.cc Sun Jul 29 06:51:00 2007 @@ -40,6 +40,7 @@ #include "StoreMetaMD5.h" #include "StoreMetaURL.h" #include "StoreMetaSTD.h" +#include "StoreMetaSTDLFS.h" #include "StoreMetaVary.h" bool @@ -127,6 +128,10 @@ result = new StoreMetaSTD; break; + case STORE_META_STD_LFS: + result = new StoreMetaSTDLFS; + break; + case STORE_META_VARY_HEADERS: result = new StoreMetaVary; break; @@ -183,6 +188,12 @@ case STORE_META_STD: break; + case STORE_META_STD_LFS: + break; + + case STORE_META_OBJSIZE: + break; + default: debugs(20, 1, "WARNING: got unused STORE_META type " << getType()); break; Index: squid3/src/StoreMetaSTD.cc diff -u squid3/src/StoreMetaSTD.cc:1.5 squid3/src/StoreMetaSTD.cc:1.5.22.1 --- squid3/src/StoreMetaSTD.cc:1.5 Mon Aug 30 19:14:26 2004 +++ squid3/src/StoreMetaSTD.cc Tue Jul 24 00:34:00 2007 @@ -41,5 +41,5 @@ bool StoreMetaSTD::validLength(int len) const { - return len == STORE_HDR_METASIZE; + return len == STORE_HDR_METASIZE_OLD; } Index: squid3/src/StoreMetaSTDLFS.cc diff -u /dev/null squid3/src/StoreMetaSTDLFS.cc:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid3/src/StoreMetaSTDLFS.cc Tue Jul 24 00:34:00 2007 @@ -0,0 +1,44 @@ + +/* + * $Id: squid3-squid3-largeobj-HEAD.patch,v 1.8 2007/08/13 17:29:49 squidadm Exp $ + * + * DEBUG: section 20 Storage Manager Swapfile Metadata + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" +#include "StoreMetaSTDLFS.h" +#include "Store.h" +#include "MemObject.h" + +bool +StoreMetaSTDLFS::validLength(int len) const +{ + return len == STORE_HDR_METASIZE; +} Index: squid3/src/StoreMetaSTDLFS.h diff -u /dev/null squid3/src/StoreMetaSTDLFS.h:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid3/src/StoreMetaSTDLFS.h Tue Jul 24 00:34:00 2007 @@ -0,0 +1,53 @@ + +/* + * $Id: squid3-squid3-largeobj-HEAD.patch,v 1.8 2007/08/13 17:29:49 squidadm Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef SQUID_STOREMETASTDLFS_H +#define SQUID_STOREMETASTDLFS_H + +#include "StoreMeta.h" + +class StoreMetaSTDLFS : public StoreMeta +{ + +public: + MEMPROXY_CLASS(StoreMetaSTDLFS); + + char getType() const {return STORE_META_STD_LFS;} + + bool validLength(int) const; + // bool checkConsistency(StoreEntry *) const; +}; + +MEMPROXY_CLASS_INLINE(StoreMetaSTDLFS) + +#endif /* SQUID_STOREMETASTDLFS_H */ Index: squid3/src/StoreSwapLogData.cc diff -u squid3/src/StoreSwapLogData.cc:1.3 squid3/src/StoreSwapLogData.cc:1.3.22.1 --- squid3/src/StoreSwapLogData.cc:1.3 Mon Aug 30 19:14:26 2004 +++ squid3/src/StoreSwapLogData.cc Thu Jul 26 15:15:43 2007 @@ -38,3 +38,8 @@ { memset (key, '\0', sizeof(key)); } + +StoreSwapLogHeader::StoreSwapLogHeader():op(SWAP_LOG_VERSION), version(1) +{ + record_size = sizeof(StoreSwapLogData); +} Index: squid3/src/StoreSwapLogData.h diff -u squid3/src/StoreSwapLogData.h:1.3 squid3/src/StoreSwapLogData.h:1.3.22.2 --- squid3/src/StoreSwapLogData.h:1.3 Mon Aug 30 19:14:26 2004 +++ squid3/src/StoreSwapLogData.h Thu Jul 26 15:15:43 2007 @@ -57,7 +57,7 @@ time_t lastref; time_t expires; time_t lastmod; - size_t swap_file_sz; + uint64_t swap_file_sz; u_short refcount; u_short flags; unsigned char key[MD5_DIGEST_CHARS]; @@ -65,4 +65,14 @@ MEMPROXY_CLASS_INLINE(StoreSwapLogData) +class StoreSwapLogHeader +{ +public: + StoreSwapLogHeader(); + char op; + int version; + int record_size; +}; + + #endif /* SQUID_STORESWAPLOGDATA_H */ Index: squid3/src/SwapDir.cc diff -u squid3/src/SwapDir.cc:1.13 squid3/src/SwapDir.cc:1.8.2.4 --- squid3/src/SwapDir.cc:1.13 Tue May 29 06:51:40 2007 +++ squid3/src/SwapDir.cc Mon Jun 18 13:59:34 2007 @@ -245,7 +245,7 @@ if (!value) self_destruct(); - ssize_t size = xatoi(value); + int64_t size = strtoll(value, NULL, 10); if (reconfiguring && max_objsize != size) debugs(3, 1, "Cache dir '" << path << "' max object size now " << size); @@ -259,7 +259,7 @@ SwapDir::optionMaxSizeDump(StoreEntry * e) const { if (max_objsize != -1) - storeAppendPrintf(e, " max-size=%ld", (long int) max_objsize); + storeAppendPrintf(e, " max-size=%"PRId64, max_objsize); } /* Swapdirs do not have an index of their own - thus they ask their parent.. Index: squid3/src/SwapDir.h diff -u squid3/src/SwapDir.h:1.14 squid3/src/SwapDir.h:1.12.10.1 --- squid3/src/SwapDir.h:1.14 Tue May 29 06:51:40 2007 +++ squid3/src/SwapDir.h Mon Jun 18 13:59:34 2007 @@ -80,7 +80,7 @@ virtual void dereference(StoreEntry &); /* Unreference this object */ - virtual void updateSize(size_t size, int sign); + virtual void updateSize(int64_t size, int sign); /* the number of store dirs being rebuilt. */ static int store_dirs_rebuilding; @@ -142,7 +142,7 @@ virtual void stat (StoreEntry &anEntry) const; virtual StoreSearch *search(String const url, HttpRequest *) = 0; - virtual void updateSize(size_t size, int sign); + virtual void updateSize(int64_t size, int sign); /* migrated from store_dir.cc */ bool objectSizeIsAcceptable(ssize_t objsize) const; @@ -164,7 +164,7 @@ int max_size; char *path; int index; /* This entry's index into the swapDirs array */ - ssize_t max_objsize; + int64_t max_objsize; RemovalPolicy *repl; int removals; int scanned; Index: squid3/src/access_log.cc diff -u squid3/src/access_log.cc:1.47 squid3/src/access_log.cc:1.41.6.8 --- squid3/src/access_log.cc:1.47 Tue May 29 06:51:40 2007 +++ squid3/src/access_log.cc Wed Aug 8 00:28:54 2007 @@ -531,6 +531,8 @@ long int outint = 0; int doint = 0; int dofree = 0; + int64_t outoff = 0; + int dooff = 0; switch (fmt->type) { @@ -786,9 +788,9 @@ /*case LFT_REQUEST_SIZE_BODY_NO_TE: */ case LFT_REPLY_SIZE_TOTAL: - outint = al->cache.size; + outoff = al->cache.size; - doint = 1; + dooff = 1; break; @@ -833,7 +835,11 @@ break; } - if (doint) { + if (dooff) { + snprintf(tmp, sizeof(tmp), "%0*lld", fmt->zero ? (int) fmt->width : 0, outoff); + out = tmp; + + } else if (doint) { snprintf(tmp, sizeof(tmp), "%0*ld", fmt->zero ? (int) fmt->width : 0, outint); out = tmp; } @@ -1289,14 +1295,14 @@ safe_free(user); if (!Config.onoff.log_mime_hdrs) { - logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %ld %s %s %s %s%s/%s %s", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %"PRId64" %s %s %s %s%s/%s %s", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->cache.msec, client, log_tags[al->cache.code], al->http.code, - (long int) al->cache.size, + al->cache.size, al->_private.method_str, al->url, user ? user : dash_str, @@ -1307,14 +1313,14 @@ } else { char *ereq = log_quote(al->headers.request); char *erep = log_quote(al->headers.reply); - logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %ld %s %s %s %s%s/%s %s [%s] [%s]", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %"PRId64" %s %s %s %s%s/%s %s [%s] [%s]", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->cache.msec, client, log_tags[al->cache.code], al->http.code, - (long int) al->cache.size, + al->cache.size, al->_private.method_str, al->url, user ? user : dash_str, @@ -1347,7 +1353,7 @@ user2 = accessLogFormatName(al->cache.rfc931); - logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %ld %s:%s", + logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %"PRId64" %s:%s", client, user2 ? user2 : dash_str, user1 ? user1 : dash_str, @@ -1356,7 +1362,7 @@ al->url, al->http.version.major, al->http.version.minor, al->http.code, - (long int) al->cache.size, + al->cache.size, log_tags[al->cache.code], hier_strings[al->hier.code]); Index: squid3/src/cache_cf.cc diff -u squid3/src/cache_cf.cc:1.85 squid3/src/cache_cf.cc:1.79.4.6 --- squid3/src/cache_cf.cc:1.85 Wed Aug 1 18:50:51 2007 +++ squid3/src/cache_cf.cc Sun Aug 12 00:25:25 2007 @@ -143,6 +143,7 @@ #endif #endif /* USE_SSL */ static void parse_b_size_t(size_t * var); +static void parse_b_int64_t(int64_t * var); /* * LegacyParser is a parser for legacy code that uses the global @@ -162,7 +163,7 @@ update_maxobjsize(void) { int i; - ssize_t ms = -1; + int64_t ms = -1; for (i = 0; i < Config.cacheSwap.n_configured; i++) { assert (Config.cacheSwap.swapDirs[i].getRaw()); @@ -171,7 +172,6 @@ max_objsize > ms) ms = dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())->max_objsize; } - store_maxobjsize = ms; } @@ -700,12 +700,51 @@ } static void +parseBytesLine64(int64_t * bptr, const char *units) +{ + char *token; + double d; + int64_t m; + int64_t u; + + if ((u = parseBytesUnits(units)) == 0) + self_destruct(); + + if ((token = strtok(NULL, w_space)) == NULL) + self_destruct(); + + if (strcmp(token, "none") == 0 || strcmp(token, "-1") == 0) { + *bptr = static_cast(-1); + return; + } + + d = xatof(token); + + m = u; /* default to 'units' if none specified */ + + if (0.0 == d) + (void) 0; + else if ((token = strtok(NULL, w_space)) == NULL) + debugs(3, 0, "WARNING: No units on '" << + config_input_line << "', assuming " << + d << " " << units ); + else if ((m = parseBytesUnits(token)) == 0) + self_destruct(); + + *bptr = static_cast(m * d / u); + + if (static_cast(*bptr) * 2 != m * d / u * 2) + self_destruct(); +} + + +static void parseBytesLine(size_t * bptr, const char *units) { char *token; double d; - size_t m; - size_t u; + int m; + int u; if ((u = parseBytesUnits(units)) == 0) self_destruct(); @@ -1028,7 +1067,7 @@ l = cbdataAlloc(acl_size_t); - parse_b_size_t(&l->size); + parse_b_int64_t(&l->size); aclParseAclList(LegacyParser, &l->aclList); @@ -2287,6 +2326,18 @@ } static void +dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var) +{ + storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_BYTES_STR); +} + +static void +dump_kb_int64_t(StoreEntry * entry, const char *name, int64_t var) +{ + storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_KBYTES_STR); +} + +static void parse_size_t(size_t * var) { int i; @@ -2307,15 +2358,34 @@ } static void +parse_b_int64_t(int64_t * var) +{ + parseBytesLine64(var, B_BYTES_STR); +} + +static void +parse_kb_int64_t(int64_t * var) +{ + parseBytesLine64(var, B_KBYTES_STR); +} + +static void free_size_t(size_t * var) { *var = 0; } +static void +free_b_int64_t(int64_t * var) +{ + *var = 0; +} + #define free_b_size_t free_size_t #define free_kb_size_t free_size_t #define free_mb_size_t free_size_t #define free_gb_size_t free_size_t +#define free_kb_int64_t free_b_int64_t static void dump_ushort(StoreEntry * entry, const char *name, u_short var) Index: squid3/src/cf.data.pre diff -u squid3/src/cf.data.pre:1.129 squid3/src/cf.data.pre:1.117.2.6 --- squid3/src/cf.data.pre:1.129 Thu Aug 2 16:51:22 2007 +++ squid3/src/cf.data.pre Sun Aug 12 00:25:25 2007 @@ -929,7 +929,7 @@ NAME: maximum_object_size COMMENT: (bytes) -TYPE: b_size_t +TYPE: b_int64_t DEFAULT: 4096 KB LOC: Config.Store.maxObjectSize DOC_START @@ -947,7 +947,7 @@ NAME: minimum_object_size COMMENT: (bytes) -TYPE: b_size_t +TYPE: b_int64_t DEFAULT: 0 KB LOC: Config.Store.minObjectSize DOC_START @@ -2096,8 +2096,8 @@ DOC_END NAME: request_body_max_size -COMMENT: (KB) -TYPE: b_size_t +COMMENT: (bytes) +TYPE: b_int64_t DEFAULT: 0 KB LOC: Config.maxRequestBodySize DOC_START @@ -2213,14 +2213,14 @@ NAME: quick_abort_min COMMENT: (KB) -TYPE: kb_size_t +TYPE: kb_int64_t DEFAULT: 16 KB LOC: Config.quickAbort.min DOC_NONE NAME: quick_abort_max COMMENT: (KB) -TYPE: kb_size_t +TYPE: kb_int64_t DEFAULT: 16 KB LOC: Config.quickAbort.max DOC_NONE @@ -2261,7 +2261,7 @@ NAME: read_ahead_gap COMMENT: buffer-size -TYPE: kb_size_t +TYPE: b_int64_t LOC: Config.readAheadGap DEFAULT: 16 KB DOC_START @@ -2304,7 +2304,7 @@ NAME: range_offset_limit COMMENT: (bytes) -TYPE: b_size_t +TYPE: b_int64_t LOC: Config.rangeOffsetLimit DEFAULT: 0 KB DOC_START Index: squid3/src/client_side.cc diff -u squid3/src/client_side.cc:1.130 squid3/src/client_side.cc:1.121.2.12 --- squid3/src/client_side.cc:1.130 Thu Jul 26 14:51:09 2007 +++ squid3/src/client_side.cc Sun Aug 12 00:25:25 2007 @@ -139,8 +139,8 @@ static void clientSetKeepaliveFlag(ClientHttpRequest *); static int clientIsContentLengthValid(HttpRequest * r); static bool okToAccept(); -static int clientIsRequestBodyValid(int bodyLength); -static int clientIsRequestBodyTooLargeForPolicy(size_t bodyLength); +static int clientIsRequestBodyValid(int64_t bodyLength); +static int clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength); static void clientUpdateStatHistCounters(log_type logType, int svc_time); static void clientUpdateStatCounters(log_type logType); @@ -683,7 +683,7 @@ } int -clientIsRequestBodyValid(int bodyLength) +clientIsRequestBodyValid(int64_t bodyLength) { if (bodyLength >= 0) return 1; @@ -692,7 +692,7 @@ } int -clientIsRequestBodyTooLargeForPolicy(size_t bodyLength) +clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength) { if (Config.maxRequestBodySize && bodyLength > Config.maxRequestBodySize) @@ -748,9 +748,10 @@ } size_t -ClientSocketContext::lengthToSend(Range const &available) +ClientSocketContext::lengthToSend(Range const &available) { - size_t maximum = available.size(); + /*the size of available range can always fit in a size_t type*/ + size_t maximum = (size_t)available.size(); if (!http->request->range) return maximum; @@ -763,10 +764,10 @@ assert (http->range_iter.debt() > 0); /* TODO this + the last line could be a range intersection calculation */ - if ((ssize_t)available.start < http->range_iter.currentSpec()->offset) + if (available.start < http->range_iter.currentSpec()->offset) return 0; - return XMIN(http->range_iter.debt(), (ssize_t)maximum); + return XMIN(http->range_iter.debt(), (int64_t)maximum); } void @@ -871,7 +872,7 @@ ClientSocketContext::packRange(StoreIOBuffer const &source, MemBuf * mb) { HttpHdrRangeIter * i = &http->range_iter; - Range available (source.range()); + Range available (source.range()); char const *buf = source.data; while (i->currentSpec() && available.size()) { @@ -931,7 +932,7 @@ return; } - off_t next = getNextRangeOffset(); + int64_t next = getNextRangeOffset(); assert (next >= http->out.offset); @@ -960,7 +961,7 @@ int ClientHttpRequest::mRangeCLen() { - int clen = 0; + int64_t clen = 0; MemBuf mb; assert(memObject()); @@ -1110,9 +1111,10 @@ request->range->contains(rep->content_range->spec) : true; const int spec_count = http->request->range->specs.count; - int actual_clen = -1; + int64_t actual_clen = -1; - debugs(33, 3, "clientBuildRangeHeader: range spec count: " << spec_count << " virgin clen: " << rep->content_length); + debugs(33, 3, "clientBuildRangeHeader: range spec count: " << + spec_count << " virgin clen: " << rep->content_length); assert(spec_count > 0); /* ETags should not be returned with Partial Content replies? */ hdr->delById(HDR_ETAG); @@ -1164,7 +1166,7 @@ hdr->delById(HDR_CONTENT_LENGTH); - hdr->putInt(HDR_CONTENT_LENGTH, actual_clen); + hdr->putInt64(HDR_CONTENT_LENGTH, actual_clen); debugs(33, 3, "clientBuildRangeHeader: actual content length: " << actual_clen); @@ -1423,32 +1425,28 @@ return http->range_iter.currentSpec() ? true : false; } -off_t +int64_t ClientSocketContext::getNextRangeOffset() const { if (http->request->range) { /* offset in range specs does not count the prefix of an http msg */ - debugs(33, 5, "ClientSocketContext::getNextRangeOffset: http offset " << (long unsigned)http->out.offset); + debugs (33, 5, "ClientSocketContext::getNextRangeOffset: http offset " << http->out.offset); /* check: reply was parsed and range iterator was initialized */ assert(http->range_iter.valid); /* filter out data according to range specs */ assert (canPackMoreRanges()); { - off_t start; /* offset of still missing data */ + int64_t start; /* offset of still missing data */ assert(http->range_iter.currentSpec()); start = http->range_iter.currentSpec()->offset + http->range_iter.currentSpec()->length - http->range_iter.debt(); - debugs(33, 3, "clientPackMoreRanges: in: offset: " << - (long int) http->out.offset); - debugs(33, 3, "clientPackMoreRanges: out: start: " << - (long int) start << " spec[" << - (long int) (http->range_iter.pos - http->request->range->begin()) << - "]: [" << (long int) http->range_iter.currentSpec()->offset << - ", " << - (long int) (http->range_iter.currentSpec()->offset + http->range_iter.currentSpec()->length) << - "), len: " << - (long int) http->range_iter.currentSpec()->length << - " debt: " << (long int) http->range_iter.debt()); - + debugs(33, 3, "clientPackMoreRanges: in: offset: " << http->out.offset); + debugs(33, 3, "clientPackMoreRanges: out:" + " start: " << start << + " spec[" << http->range_iter.pos - http->request->range->begin() << "]:" << + " [" << http->range_iter.currentSpec()->offset << + ", " << http->range_iter.currentSpec()->offset + http->range_iter.currentSpec()->length << ")," + " len: " << http->range_iter.currentSpec()->length << + " debt: " << http->range_iter.debt()); if (http->range_iter.currentSpec()->length != -1) assert(http->out.offset <= start); /* we did not miss it */ Index: squid3/src/client_side.h diff -u squid3/src/client_side.h:1.19 squid3/src/client_side.h:1.18.6.4 --- squid3/src/client_side.h:1.19 Wed May 9 00:50:40 2007 +++ squid3/src/client_side.h Sun Jul 22 01:50:29 2007 @@ -98,12 +98,12 @@ DeferredParams deferredparams; off_t writtenToSocket; void pullData(); - off_t getNextRangeOffset() const; + int64_t getNextRangeOffset() const; bool canPackMoreRanges() const; clientStream_status_t socketState(); void sendBody(HttpReply * rep, StoreIOBuffer bodyData); void sendStartOfMessage(HttpReply * rep, StoreIOBuffer bodyData); - size_t lengthToSend(Range const &available); + size_t lengthToSend(Range const &available); void noteSentBodyBytes(size_t); void buildRangeHeader(HttpReply * rep); int fd() const; Index: squid3/src/client_side_reply.cc diff -u squid3/src/client_side_reply.cc:1.103 squid3/src/client_side_reply.cc:1.91.2.9 --- squid3/src/client_side_reply.cc:1.103 Tue May 29 06:51:40 2007 +++ squid3/src/client_side_reply.cc Sun Jul 22 01:50:29 2007 @@ -977,8 +977,13 @@ int clientReplyContext::storeOKTransferDone() const { - if (http->out.offset >= http->storeEntry()->objectLen() - headers_sz) + if (http->out.offset >= http->storeEntry()->objectLen() - headers_sz) { + debugs(88,3,HERE << "storeOKTransferDone " << + " out.offset=" << http->out.offset << + " objectLen()=" << http->storeEntry()->objectLen() << + " headers_sz=" << headers_sz); return 1; + } return 0; } @@ -1015,12 +1020,16 @@ if (reply->content_length < 0) return 0; - size_t expectedLength = http->out.headers_sz + reply->content_length; + int64_t expectedLength = reply->content_length + http->out.headers_sz; if (http->out.size < expectedLength) return 0; - else + else { + debugs(88,3,HERE << "storeNotOKTransferDone " << + " out.size=" << http->out.size << + " expectedLength=" << expectedLength); return 1; + } } @@ -1033,23 +1042,22 @@ int clientHttpRequestStatus(int fd, ClientHttpRequest const *http) { -#if SIZEOF_SIZE_T == 4 - +#if SIZEOF_INT64_T == 4 if (http->out.size > 0x7FFF0000) { - debugs(88, 1, "WARNING: closing FD " << fd << " to prevent counter overflow" ); - debugs(88, 1, "\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr)) ); - debugs(88, 1, "\treceived " << http->out.size << " bytes" ); - debugs(88, 1, "\tURI " << http->log_uri ); + debugs(88, 1, "WARNING: closing FD " << fd << " to prevent out.size counter overflow"); + debugs(88, 1, "\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr))); + debugs(88, 1, "\treceived " << http->out.size << " bytes"); + debugs(88, 1, "\tURI " << http->log_uri); return 1; } #endif -#if SIZEOF_OFF_T == 4 +#if SIZEOF_INT64_T == 4 if (http->out.offset > 0x7FFF0000) { - debugs(88, 1, "WARNING: closing FD " << fd << " to prevent counter overflow" ); - debugs(88, 1, "\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr)) ); - debugs(88, 1, "\treceived " << http->out.size << " bytes (offset " << http->out.offset << ")" ); - debugs(88, 1, "\tURI " << http->log_uri ); + debugs(88, 1, ("WARNING: closing FD " << fd < " to prevent out.offset counter overflow"); + debugs(88, 1, ("\tclient " << (inet_ntoa(http->getConn() != NULL ? http->getConn()->peer.sin_addr : no_addr))); + debugs(88, 1, ("\treceived " << http->out.size " << " bytes, offset " << http->out.offset); + debugs(88, 1, ("\tURI " << http->log_uri); return 1; } @@ -1915,9 +1923,12 @@ makeThisHead(); debugs(88, 5, "clientReplyContext::sendMoreData: " << http->uri << ", " << - (int) reqofs << " bytes (" << (unsigned int)result.length << + reqofs << " bytes (" << result.length << " new bytes)"); - debugs(88, 5, "clientReplyContext::sendMoreData: FD " << fd << " '" << entry->url() << "', out.offset=" << http->out.offset << " " ); + debugs(88, 5, "clientReplyContext::sendMoreData:" + " FD " << fd << + " '" << entry->url() << "'" << + " out.offset=" << http->out.offset); /* update size of the request */ reqsize = reqofs; Index: squid3/src/client_side_request.cc diff -u squid3/src/client_side_request.cc:1.77 squid3/src/client_side_request.cc:1.66.6.5 --- squid3/src/client_side_request.cc:1.77 Wed Jul 18 17:51:10 2007 +++ squid3/src/client_side_request.cc Sun Jul 22 01:50:29 2007 @@ -918,19 +918,19 @@ } void -ClientHttpRequest::maxReplyBodySize(ssize_t clen) +ClientHttpRequest::maxReplyBodySize(int64_t clen) { maxReplyBodySize_ = clen; } -ssize_t +int64_t ClientHttpRequest::maxReplyBodySize() const { return maxReplyBodySize_; } bool -ClientHttpRequest::isReplyBodyTooLarge(ssize_t clen) const +ClientHttpRequest::isReplyBodyTooLarge(int64_t clen) const { if (0 == maxReplyBodySize()) return 0; /* disabled */ Index: squid3/src/client_side_request.h diff -u squid3/src/client_side_request.h:1.29 squid3/src/client_side_request.h:1.25.6.5 --- squid3/src/client_side_request.h:1.29 Sat Jun 2 05:50:57 2007 +++ squid3/src/client_side_request.h Sun Jul 22 01:50:30 2007 @@ -99,8 +99,8 @@ struct { - off_t offset; - size_t size; + int64_t offset; + int64_t size; size_t headers_sz; } @@ -144,16 +144,16 @@ dlink_list client_stream; int mRangeCLen(); - ssize_t maxReplyBodySize() const; - void maxReplyBodySize(ssize_t size); - bool isReplyBodyTooLarge(ssize_t len) const; + int64_t maxReplyBodySize() const; + void maxReplyBodySize(int64_t size); + bool isReplyBodyTooLarge(int64_t len) const; ClientRequestContext *calloutContext; void doCallouts(); private: CBDATA_CLASS(ClientHttpRequest); - ssize_t maxReplyBodySize_; + int64_t maxReplyBodySize_; StoreEntry *entry_; StoreEntry *loggingEntry_; ConnStateData::Pointer conn_; @@ -196,7 +196,7 @@ /* ones that should be elsewhere */ SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *); -SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, size_t *, int *); +SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *); #ifdef _USE_INLINE_ #include "Store.h" Index: squid3/src/defines.h diff -u squid3/src/defines.h:1.15 squid3/src/defines.h:1.15.10.1 --- squid3/src/defines.h:1.15 Sun Aug 20 18:51:49 2006 +++ squid3/src/defines.h Tue Jul 24 00:34:00 2007 @@ -202,7 +202,8 @@ #define SwapMetaType(x) (char)x[0] #define SwapMetaSize(x) &x[sizeof(char)] #define SwapMetaData(x) &x[STORE_META_TLD_START] -#define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(size_t)) +#define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(uint64_t)) +#define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(size_t)) #define PINGER_PAYLOAD_SZ 8192 Index: squid3/src/enums.h diff -u squid3/src/enums.h:1.37 squid3/src/enums.h:1.35.4.5 --- squid3/src/enums.h:1.37 Fri May 4 15:51:11 2007 +++ squid3/src/enums.h Sun Jul 29 06:51:00 2007 @@ -440,6 +440,8 @@ STORE_META_HITMETERING, /* reserved for hit metering */ STORE_META_VALID, STORE_META_VARY_HEADERS, /* Stores Vary request headers */ + STORE_META_STD_LFS, /* standard metadata in lfs format */ + STORE_META_OBJSIZE, /* object size, not impleemented, squid26 compatibility */ STORE_META_END }; @@ -455,6 +457,7 @@ SWAP_LOG_NOP, SWAP_LOG_ADD, SWAP_LOG_DEL, + SWAP_LOG_VERSION, SWAP_LOG_MAX } swap_log_op; Index: squid3/src/fde.cc diff -u squid3/src/fde.cc:1.7 squid3/src/fde.cc:1.6.6.3 --- squid3/src/fde.cc:1.7 Wed Apr 25 04:51:03 2007 +++ squid3/src/fde.cc Mon Jun 18 13:59:35 2007 @@ -56,11 +56,11 @@ #ifdef _SQUID_MSWIN_ - storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7d%c %7d%c %-21s %s\n", + storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7"PRId64"%c %7"PRId64"%c %-21s %s\n", fdNumber, win32.handle, #else - storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7d%c %7d%c %-21s %s\n", + storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7"PRId64"%c %7"PRId64"%c %-21s %s\n", fdNumber, #endif fdTypeStr[type], Index: squid3/src/fde.h diff -u squid3/src/fde.h:1.13 squid3/src/fde.h:1.13.6.1 --- squid3/src/fde.h:1.13 Fri Sep 15 13:51:21 2006 +++ squid3/src/fde.h Tue May 1 09:31:53 2007 @@ -75,8 +75,8 @@ unsigned int write_pending:1; } flags; - int bytes_read; - int bytes_written; + int64_t bytes_read; + int64_t bytes_written; struct { int uses; /* ie # req's over persistent conn */ Index: squid3/src/ftp.cc diff -u squid3/src/ftp.cc:1.85 squid3/src/ftp.cc:1.63.2.17 --- squid3/src/ftp.cc:1.85 Mon Aug 13 03:51:23 2007 +++ squid3/src/ftp.cc Mon Aug 13 09:46:42 2007 @@ -126,12 +126,12 @@ int login_att; ftp_state_t state; time_t mdtm; - int size; + int64_t theSize; wordlist *pathcomps; char *filepath; char *dirpath; - int restart_offset; - int restarted_offset; + int64_t restart_offset; + int64_t restarted_offset; char *proxy_host; size_t list_width; wordlist *cwd_message; @@ -145,7 +145,7 @@ int fd; char *buf; size_t size; - off_t offset; + size_t offset; wordlist *message; char *last_command; char *last_reply; @@ -192,7 +192,7 @@ int checkAuth(const HttpHeader * req_hdr); void checkUrlpath(); void buildTitleUrl(); - void writeReplyBody(const char *, int len); + void writeReplyBody(const char *, size_t len); void printfReplyBody(const char *fmt, ...); virtual int dataDescriptor() const; virtual void maybeReadVirginBody(); @@ -211,7 +211,7 @@ static IOCB ftpReadControlReply; static IOCB ftpWriteCommandCallback; static HttpReply *ftpAuthRequired(HttpRequest * request, const char *realm); - static wordlist *ftpParseControlReply(char *, size_t, int *, int *); + static wordlist *ftpParseControlReply(char *, size_t, int *, size_t *); // sending of the request body to the server virtual void sentRequestBody(int fd, size_t size, comm_err_t errflag); @@ -247,7 +247,7 @@ typedef struct { char type; - int size; + int64_t size; char *date; char *name; char *showname; @@ -370,7 +370,7 @@ statCounter.server.ftp.requests++; ctrl.fd = theFwdState->server_fd; data.fd = -1; - size = -1; + theSize = -1; mdtm = -1; if (Config.Ftp.passive && !theFwdState->ftpPasvFailed()) @@ -715,7 +715,7 @@ if ((copyFrom = strstr(buf, tbuf))) { p->type = *tokens[0]; - p->size = atoi(size); + p->size = strtoll(size, NULL, 10); p->date = xstrdup(tbuf); if (flags.skip_whitespace) { @@ -752,7 +752,7 @@ p->type = 'd'; } else { p->type = '-'; - p->size = atoi(tokens[2]); + p->size = strtoll(tokens[2], NULL, 10); } snprintf(tbuf, 128, "%s %s", tokens[0], tokens[1]); @@ -1043,7 +1043,7 @@ snprintf(icon, 2048, "\"%-6s\"", mimeGetIconURL(parts->name), "[FILE]"); - snprintf(size, 2048, " %6dk", parts->size); + snprintf(size, 2048, " %6"PRId64"k", parts->size); break; } @@ -1313,7 +1313,7 @@ { debugs(9, 5, HERE << "FtpStateData::processReplyBody starting."); - if (request->method == METHOD_HEAD && (flags.isdir || size != -1)) { + if (request->method == METHOD_HEAD && (flags.isdir || theSize != -1)) { serverComplete(); return; } @@ -1598,7 +1598,7 @@ } wordlist * -FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) +FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, size_t *used) { char *s; char *sbuf; @@ -1608,7 +1608,7 @@ wordlist *head = NULL; wordlist *list; wordlist **tail = &head; - off_t offset; + size_t offset; size_t linelen; int code = -1; debugs(9, 5, "ftpParseControlReply"); @@ -1673,7 +1673,7 @@ tail = &list->next; } - *used = (int) (s - sbuf); + *used = (size_t) (s - sbuf); safe_free(sbuf); if (!complete) @@ -1734,7 +1734,7 @@ return; } - assert(ftpState->ctrl.offset < (off_t)ftpState->ctrl.size); + assert(ftpState->ctrl.offset < ftpState->ctrl.size); if (errflag == COMM_OK && len > 0) { fd_bytes(fd, len, FD_READ); @@ -1777,7 +1777,7 @@ FtpStateData::handleControlReply() { wordlist **W; - int bytes_used = 0; + size_t bytes_used = 0; wordlistDestroy(&ctrl.message); ctrl.message = ftpParseControlReply(ctrl.buf, ctrl.offset, &ctrl.replycode, &bytes_used); @@ -1785,7 +1785,7 @@ if (ctrl.message == NULL) { /* didn't get complete reply yet */ - if (ctrl.offset == (off_t)ctrl.size) { + if (ctrl.offset == ctrl.size) { ctrl.buf = (char *)memReallocBuf(ctrl.buf, ctrl.size << 1, &ctrl.size); } @@ -2208,14 +2208,13 @@ if (code == 213) { ftpState->unhack(); - ftpState->size = atoi(ftpState->ctrl.last_reply); + ftpState->theSize = strtoll(ftpState->ctrl.last_reply, NULL, 10); - if (ftpState->size == 0) { + if (ftpState->theSize == 0) { debugs(9, 2, "ftpReadSize: SIZE reported " << - ftpState->ctrl.last_reply << " on " << - ftpState->title_url.buf()); - - ftpState->size = -1; + ftpState->ctrl.last_reply << " on " << + ftpState->title_url.buf()); + ftpState->theSize = -1; } } else if (code < 0) { ftpFail(ftpState); @@ -2237,7 +2236,7 @@ debugs(9, 3, HERE << "ftpSendPasv started"); - if (ftpState->request->method == METHOD_HEAD && (ftpState->flags.isdir || ftpState->size != -1)) { + if (ftpState->request->method == METHOD_HEAD && (ftpState->flags.isdir || ftpState->theSize != -1)) { ftpState->processHeadResponse(); // may call serverComplete return; } @@ -2645,7 +2644,7 @@ snprintf(cbuf, 1024, "STOR %s\r\n", ftpState->filepath); ftpState->writeCommand(cbuf); ftpState->state = SENT_STOR; - } else if (ftpState->request->header.getInt(HDR_CONTENT_LENGTH) > 0) { + } else if (ftpState->request->header.getInt64(HDR_CONTENT_LENGTH) > 0) { /* File upload without a filename. use STOU to generate one */ snprintf(cbuf, 1024, "STOU\r\n"); ftpState->writeCommand(cbuf); @@ -2705,7 +2704,7 @@ if(!ftpState || !ftpState->haveControlChannel("ftpSendRest")) return; - snprintf(cbuf, 1024, "REST %d\r\n", ftpState->restart_offset); + snprintf(cbuf, 1024, "REST %"PRId64"\r\n", ftpState->restart_offset); ftpState->writeCommand(cbuf); ftpState->state = SENT_REST; } @@ -2722,15 +2721,15 @@ if (!flags.binary) return 0; - if (size <= 0) + if (theSize <= 0) return 0; - int desired_offset = request->range->lowestOffset((size_t) size); + int64_t desired_offset = request->range->lowestOffset(theSize); if (desired_offset <= 0) return 0; - if (desired_offset >= size) + if (desired_offset >= theSize) return 0; restart_offset = desired_offset; @@ -3016,7 +3015,7 @@ if (!ftpState->flags.isdir && /* Not a directory */ !ftpState->flags.try_slash_hack && /* Not in slash hack */ - ftpState->mdtm <= 0 && ftpState->size < 0 && /* Not known as a file */ + ftpState->mdtm <= 0 && ftpState->theSize < 0 && /* Not known as a file */ ftpState->request->urlpath.caseCmp("/%2f", 4) != 0) { /* No slash encoded */ switch (ftpState->state) { @@ -3226,28 +3225,28 @@ if (0 == restarted_offset) { /* Full reply */ reply->setHeaders(version, HTTP_OK, "Gatewaying", - mime_type, size, mdtm, -2); - } else if (size < restarted_offset) { + mime_type, theSize, mdtm, -2); + } else if (theSize < restarted_offset) { /* * DPW 2007-05-04 - * offset should not be larger than size. We should + * offset should not be larger than theSize. We should * not be seeing this condition any more because we'll only - * send REST if we know the size and if it is less than size. + * send REST if we know the theSize and if it is less than theSize. */ debugs(0,0,HERE << "Whoops! " << " restarted_offset=" << restarted_offset << - ", but size=" << size << + ", but theSize=" << theSize << ". assuming full content response"); reply->setHeaders(version, HTTP_OK, "Gatewaying", - mime_type, size, mdtm, -2); + mime_type, theSize, mdtm, -2); } else { /* Partial reply */ HttpHdrRangeSpec range_spec; range_spec.offset = restarted_offset; - range_spec.length = size - restarted_offset; + range_spec.length = theSize - restarted_offset; reply->setHeaders(version, HTTP_PARTIAL_CONTENT, "Gatewaying", - mime_type, size - restarted_offset, mdtm, -2); - httpHeaderAddContRange(&reply->header, range_spec, size); + mime_type, theSize - restarted_offset, mdtm, -2); + httpHeaderAddContRange(&reply->header, range_spec, theSize); } /* additional info */ @@ -3344,7 +3343,7 @@ * which should be sent to either StoreEntry, or to ICAP... */ void -FtpStateData::writeReplyBody(const char *data, int len) +FtpStateData::writeReplyBody(const char *data, size_t len) { debugs(9,5,HERE << "writing " << len << " bytes to the reply"); addVirginReplyBody(data, len); Index: squid3/src/globals.h diff -u squid3/src/globals.h:1.31 squid3/src/globals.h:1.31.4.1 --- squid3/src/globals.h:1.31 Sun Apr 15 08:00:41 2007 +++ squid3/src/globals.h Mon Jun 18 13:59:35 2007 @@ -156,7 +156,7 @@ extern int store_swap_low; /* 0 */ extern int store_swap_high; /* 0 */ extern size_t store_pages_max; /* 0 */ - extern ssize_t store_maxobjsize; /* -1 */ + extern int64_t store_maxobjsize; /* -1 */ extern hash_table *proxy_auth_username_cache; /* NULL */ extern int incoming_sockets_accepted; #ifdef _SQUID_MSWIN_ Index: squid3/src/http.cc diff -u squid3/src/http.cc:1.120 squid3/src/http.cc:1.99.4.10 --- squid3/src/http.cc:1.120 Thu Aug 9 16:51:11 2007 +++ squid3/src/http.cc Sun Aug 12 00:25:25 2007 @@ -899,7 +899,7 @@ if (eof) // already reached EOF return COMPLETE_NONPERSISTENT_MSG; - const int clen = vrep->bodySize(request->method); + const int64_t clen = vrep->bodySize(request->method); debugs(11, 5, "persistentConnStatus: clen=" << clen); @@ -911,7 +911,7 @@ if (clen > 0) { // old technique: // if (entry->mem_obj->endOffset() < vrep->content_length + vrep->hdr_sz) - const int body_bytes_read = reply_bytes_read - header_bytes_read; + const int64_t body_bytes_read = reply_bytes_read - header_bytes_read; debugs(11,5, "persistentConnStatus: body_bytes_read=" << body_bytes_read << " content_length=" << vrep->content_length); Index: squid3/src/mem_node.cc diff -u squid3/src/mem_node.cc:1.10 squid3/src/mem_node.cc:1.10.6.3 --- squid3/src/mem_node.cc:1.10 Tue Sep 19 18:50:46 2006 +++ squid3/src/mem_node.cc Fri Apr 20 15:31:23 2007 @@ -66,7 +66,7 @@ n->write_pending = 0; } -mem_node::mem_node(off_t offset):nodeBuffer(0,offset,data) +mem_node::mem_node(int64_t offset):nodeBuffer(0,offset,data) {} mem_node::~mem_node() @@ -80,23 +80,23 @@ return Pool().inUseCount(); } -size_t +int64_t mem_node::start() const { assert (nodeBuffer.offset >= 0); return nodeBuffer.offset; } -size_t +int64_t mem_node::end() const { return nodeBuffer.offset + nodeBuffer.length; } -Range +Range mem_node::dataRange() const { - return Range (start(), end()); + return Range (start(), end()); } size_t @@ -106,7 +106,7 @@ } bool -mem_node::contains (size_t const &location) const +mem_node::contains (int64_t const &location) const { if (start() <= location && end() > location) return true; @@ -116,7 +116,7 @@ /* nodes can not be sparse */ bool -mem_node::canAccept (size_t const &location) const +mem_node::canAccept (int64_t const &location) const { if (location == end() && space() > 0) return true; Index: squid3/src/mem_node.h diff -u squid3/src/mem_node.h:1.10 squid3/src/mem_node.h:1.10.14.3 --- squid3/src/mem_node.h:1.10 Wed Sep 14 19:12:42 2005 +++ squid3/src/mem_node.h Fri Apr 20 15:31:23 2007 @@ -45,14 +45,14 @@ static unsigned long store_mem_size; /* 0 */ MEMPROXY_CLASS(mem_node); - mem_node(off_t); + mem_node(int64_t); ~mem_node(); size_t space() const; - size_t start() const; - size_t end() const; - Range dataRange() const; - bool contains (size_t const &location) const; - bool canAccept (size_t const &location) const; + int64_t start() const; + int64_t end() const; + Range dataRange() const; + bool contains (int64_t const &location) const; + bool canAccept (int64_t const &location) const; bool operator < (mem_node const & rhs) const; /* public */ StoreIOBuffer nodeBuffer; Index: squid3/src/mime.cc diff -u squid3/src/mime.cc:1.25 squid3/src/mime.cc:1.22.6.3 --- squid3/src/mime.cc:1.25 Sat Apr 28 15:51:56 2007 +++ squid3/src/mime.cc Tue May 1 09:49:31 2007 @@ -586,7 +586,7 @@ HttpVersion version(1, 0); reply->setHeaders(version, HTTP_OK, NULL, - mimeGetContentType(icon), (int) sb.st_size, sb.st_mtime, -1); + mimeGetContentType(icon), sb.st_size, sb.st_mtime, -1); reply->cache_control = httpHdrCcCreate(); Index: squid3/src/peer_digest.cc diff -u squid3/src/peer_digest.cc:1.33 squid3/src/peer_digest.cc:1.27.6.4 --- squid3/src/peer_digest.cc:1.33 Tue May 29 06:51:50 2007 +++ squid3/src/peer_digest.cc Mon Jun 18 13:59:35 2007 @@ -787,7 +787,7 @@ if (!reason && !size) { if (!pd->cd) reason = "null digest?!"; - else if (fetch->mask_offset != (off_t)pd->cd->mask_size) + else if (fetch->mask_offset != (int)pd->cd->mask_size) reason = "premature end of digest?!"; else if (!peerDigestUseful(pd)) reason = "useless digest"; Index: squid3/src/protos.h diff -u squid3/src/protos.h:1.85 squid3/src/protos.h:1.80.4.5 --- squid3/src/protos.h:1.85 Tue May 29 06:51:50 2007 +++ squid3/src/protos.h Sun Jul 22 01:50:39 2007 @@ -245,6 +245,7 @@ SQUIDCEXTERN const char *getStringPrefix(const char *str, const char *end); SQUIDCEXTERN int httpHeaderParseInt(const char *start, int *val); SQUIDCEXTERN int httpHeaderParseSize(const char *start, ssize_t * sz); +SQUIDCEXTERN int httpHeaderParseOffset(const char *start, int64_t * off); #if STDC_HEADERS SQUIDCEXTERN void httpHeaderPutStrf(HttpHeader * hdr, http_hdr_type id, const char *fmt,...) PRINTF_FORMAT_ARG3; Index: squid3/src/squid.h diff -u squid3/src/squid.h:1.33 squid3/src/squid.h:1.32.6.2 --- squid3/src/squid.h:1.33 Tue Apr 24 09:54:49 2007 +++ squid3/src/squid.h Wed Apr 25 09:45:14 2007 @@ -35,6 +35,11 @@ #ifndef SQUID_H #define SQUID_H +/* + * On linux this must be defined to get PRId64 and friends + */ +#define __STDC_FORMAT_MACROS + #include "config.h" #ifdef _SQUID_MSWIN_ Index: squid3/src/stat.cc diff -u squid3/src/stat.cc:1.41 squid3/src/stat.cc:1.36.4.3 --- squid3/src/stat.cc:1.41 Tue May 29 06:51:50 2007 +++ squid3/src/stat.cc Tue May 1 09:31:53 2007 @@ -1657,7 +1657,7 @@ if (conn != NULL) { fd = conn->fd; - storeAppendPrintf(s, "\tFD %d, read %d, wrote %d\n", fd, + storeAppendPrintf(s, "\tFD %d, read %"PRId64", wrote %"PRId64"\n", fd, 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 %ld, size %ld\n", Index: squid3/src/stmem.cc diff -u squid3/src/stmem.cc:1.17 squid3/src/stmem.cc:1.16.14.5 --- squid3/src/stmem.cc:1.17 Sat Apr 28 15:51:56 2007 +++ squid3/src/stmem.cc Tue Jul 31 14:09:46 2007 @@ -55,7 +55,7 @@ return aNode->data; } -int +int64_t mem_hdr::lowestOffset () const { const SplayNode *theStart = nodes.start(); @@ -66,10 +66,10 @@ return 0; } -off_t +int64_t mem_hdr::endOffset () const { - off_t result = 0; + int64_t result = 0; const SplayNode *theEnd = nodes.finish(); if (theEnd) @@ -100,8 +100,8 @@ return true; } -int -mem_hdr::freeDataUpto(int target_offset) +int64_t +mem_hdr::freeDataUpto(int64_t target_offset) { /* keep the last one to avoid change to other part of code */ @@ -111,7 +111,7 @@ if (theStart == nodes.finish()) break; - if (theStart->data->end() > (size_t) target_offset ) + if (theStart->data->end() > target_offset ) break; if (!unlink(theStart->data)) @@ -131,7 +131,7 @@ } size_t -mem_hdr::writeAvailable(mem_node *aNode, size_t location, size_t amount, char const *source) +mem_hdr::writeAvailable(mem_node *aNode, int64_t location, size_t amount, char const *source) { /* if we attempt to overwrite existing data or leave a gap within a node */ assert (location == aNode->nodeBuffer.offset + aNode->nodeBuffer.length); @@ -144,7 +144,7 @@ xmemcpy(aNode->nodeBuffer.data + aNode->nodeBuffer.length, source, copyLen); - if (inmem_hi <= (off_t) location) + if (inmem_hi <= location) inmem_hi = location + copyLen; /* Adjust the ptr and len according to what was deposited in the page */ @@ -194,7 +194,7 @@ * If no node contains the start, it returns NULL. */ mem_node * -mem_hdr::getBlockContainingLocation (size_t location) const +mem_hdr::getBlockContainingLocation (int64_t location) const { mem_node target (location); target.nodeBuffer.length = 1; @@ -207,12 +207,12 @@ } size_t -mem_hdr::copyAvailable(mem_node *aNode, size_t location, size_t amount, char *target) const +mem_hdr::copyAvailable(mem_node *aNode, int64_t location, size_t amount, char *target) const { - if (aNode->nodeBuffer.offset > (off_t) location) + if (aNode->nodeBuffer.offset > location) return 0; - assert (aNode->nodeBuffer.offset <= (off_t) location); + assert (aNode->nodeBuffer.offset <= location); assert (aNode->end() > location); @@ -246,6 +246,7 @@ mem_hdr::copy(StoreIOBuffer const &target) const { + assert(target.range().end > target.range().start); debugs(19, 6, "memCopy: " << target.range()); /* we shouldn't ever ask for absent offsets */ @@ -261,7 +262,7 @@ assert(target.length > 0); /* Seek our way into store */ - mem_node *p = getBlockContainingLocation((size_t)target.offset); + mem_node *p = getBlockContainingLocation(target.offset); if (!p) { debugs(19, 1, "memCopy: could not find start of " << target.range() << @@ -273,7 +274,7 @@ size_t bytes_to_go = target.length; char *ptr_to_buf = target.data; - off_t location = target.offset; + int64_t location = target.offset; /* Start copying begining with this block until * we're satiated */ @@ -300,9 +301,9 @@ } bool -mem_hdr::hasContigousContentRange(Range const & range) const +mem_hdr::hasContigousContentRange(Range const & range) const { - size_t currentStart = range.start; + int64_t currentStart = range.start; while (mem_node *curr = getBlockContainingLocation(currentStart)) { currentStart = curr->end(); @@ -324,7 +325,7 @@ } mem_node * -mem_hdr::nodeToRecieve(off_t offset) +mem_hdr::nodeToRecieve(int64_t offset) { /* case 1: Nothing in memory */ @@ -375,7 +376,7 @@ assert (writeBuffer.offset >= 0); mem_node *target; - off_t currentOffset = writeBuffer.offset; + int64_t currentOffset = writeBuffer.offset; char *currentSource = writeBuffer.data; size_t len = writeBuffer.length; Index: squid3/src/stmem.h diff -u squid3/src/stmem.h:1.9 squid3/src/stmem.h:1.9.14.4 --- squid3/src/stmem.h:1.9 Wed Sep 14 19:12:42 2005 +++ squid3/src/stmem.h Tue Jul 31 14:09:47 2007 @@ -49,18 +49,18 @@ mem_hdr(); ~mem_hdr(); void freeContent(); - int lowestOffset () const; - off_t endOffset () const; - int freeDataUpto (int); + int64_t lowestOffset () const; + int64_t endOffset () const; + int64_t freeDataUpto (int64_t); ssize_t copy (StoreIOBuffer const &) const; - bool hasContigousContentRange(Range const &range) const; + bool hasContigousContentRange(Range const &range) const; /* success or fail */ bool write (StoreIOBuffer const &); void dump() const; size_t size() const; /* Not an iterator - thus the start, not begin() */ mem_node const *start() const; - mem_node *getBlockContainingLocation (size_t location) const; + mem_node *getBlockContainingLocation (int64_t location) const; /* access the contained nodes - easier than punning * as a contianer ourselves */ @@ -78,11 +78,11 @@ void makeAppendSpace(); int appendToNode(mem_node *aNode, const char *data, int maxLength); void appendNode (mem_node *aNode); - size_t copyAvailable(mem_node *aNode, size_t location, size_t amount, char *target) const; + size_t copyAvailable(mem_node *aNode, int64_t location, size_t amount, char *target) const; bool unionNotEmpty (StoreIOBuffer const &); - mem_node *nodeToRecieve(off_t offset); - size_t writeAvailable(mem_node *aNode, size_t location, size_t amount, char const *source); - off_t inmem_hi; + mem_node *nodeToRecieve(int64_t offset); + size_t writeAvailable(mem_node *aNode, int64_t location, size_t amount, char const *source); + int64_t inmem_hi; Splay nodes; }; Index: squid3/src/store.cc diff -u squid3/src/store.cc:1.63 squid3/src/store.cc:1.53.2.9 --- squid3/src/store.cc:1.63 Tue May 29 06:51:50 2007 +++ squid3/src/store.cc Sun Jul 22 01:50:40 2007 @@ -940,11 +940,10 @@ if (STORE_OK == store_status) if (mem_obj->object_sz < 0 || - static_cast(mem_obj->object_sz) - < Config.Store.minObjectSize) + mem_obj->object_sz < Config.Store.minObjectSize) return 1; if (getReply()->content_length > -1) - if (getReply()->content_length < (int) Config.Store.minObjectSize) + if (getReply()->content_length < Config.Store.minObjectSize) return 1; return 0; } @@ -970,12 +969,12 @@ store_check_cachable_hist.no.negative_cached++; return 0; /* avoid release call below */ } else if ((getReply()->content_length > 0 && - static_cast(getReply()->content_length) + getReply()->content_length > Config.Store.maxObjectSize) || - static_cast(mem_obj->endOffset()) > Config.Store.maxObjectSize) { + mem_obj->endOffset() > Config.Store.maxObjectSize) { debugs(20, 2, "StoreEntry::checkCachable: NO: too big"); store_check_cachable_hist.no.too_big++; - } else if (getReply()->content_length > (int) Config.Store.maxObjectSize) { + } else if (getReply()->content_length > Config.Store.maxObjectSize) { debugs(20, 2, "StoreEntry::checkCachable: NO: too big"); store_check_cachable_hist.no.too_big++; } else if (checkTooSmall()) { @@ -1356,7 +1355,7 @@ bool StoreEntry::validLength() const { - int diff; + int64_t diff; const HttpReply *reply; assert(mem_obj != NULL); reply = getReply(); @@ -1659,14 +1658,14 @@ } } -ssize_t +int64_t StoreEntry::objectLen() const { assert(mem_obj != NULL); return mem_obj->object_sz; } -int +int64_t StoreEntry::contentLen() const { assert(mem_obj != NULL); Index: squid3/src/store_client.cc diff -u squid3/src/store_client.cc:1.37 squid3/src/store_client.cc:1.29.2.12 --- squid3/src/store_client.cc:1.37 Mon Apr 30 10:51:41 2007 +++ squid3/src/store_client.cc Mon Aug 6 23:32:15 2007 @@ -81,7 +81,7 @@ } bool -store_client::memReaderHasLowerOffset(off_t anOffset) const +store_client::memReaderHasLowerOffset(int64_t anOffset) const { return getType() == STORE_MEM_CLIENT && copyInto.offset < anOffset; } @@ -229,7 +229,7 @@ assert (data); assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED)); debugs(90, 3, "store_client::copy: " << entry->getMD5Text() << ", from " << - (unsigned long) copyRequest.offset << ", for length " << + copyRequest.offset << ", for length " << (int) copyRequest.length << ", cb " << callback_fn << ", cbdata " << data); @@ -276,7 +276,7 @@ static int storeClientNoMoreToSend(StoreEntry * e, store_client * sc) { - ssize_t len; + int64_t len; if (e->store_status == STORE_PENDING) return 0; @@ -341,11 +341,12 @@ MemObject *mem = entry->mem_obj; debugs(33, 5, "store_client::doCopy: co: " << - (unsigned long) copyInto.offset << ", hi: " << - (long int) mem->endOffset()); + copyInto.offset << ", hi: " << + mem->endOffset()); if (storeClientNoMoreToSend(entry, this)) { /* There is no more to send! */ + debugs(33, 3, HERE << "There is no more to send!"); callback(0); flags.store_copying = 0; return; @@ -459,7 +460,7 @@ if (mem->swap_hdr_sz != 0) if (entry->swap_status == SWAPOUT_WRITING) - assert(mem->swapout.sio->offset() > copyInto.offset + (off_t)mem->swap_hdr_sz); + assert(mem->swapout.sio->offset() > copyInto.offset + (int64_t)mem->swap_hdr_sz); storeRead(swapin_sio, copyInto.data, @@ -580,7 +581,7 @@ */ size_t body_sz = len - mem->swap_hdr_sz; - if (static_cast(copyInto.offset) < body_sz) { + if (copyInto.offset < static_cast(body_sz)) { /* * we have (part of) what they want */ @@ -697,6 +698,14 @@ return 1; } +#if UNUSED_CODE_20070420 +off_t +storeLowestMemReaderOffset(const StoreEntry * entry) +{ + return entry->mem_obj->lowestMemReaderOffset(); +} +#endif + /* Call handlers waiting for data to be appended to E. */ void StoreEntry::invokeHandlers() @@ -756,17 +765,15 @@ return 1; } - size_t expectlen = entry->getReply()->content_length + entry->getReply()->hdr_sz; + int64_t expectlen = entry->getReply()->content_length + entry->getReply()->hdr_sz; if (expectlen < 0) /* expectlen is < 0 if *no* information about the object has been recieved */ return 1; - size_t curlen = (size_t) mem->endOffset (); - - size_t minlen = (size_t) Config.quickAbort.min << 10; + int64_t curlen = mem->endOffset (); - if (minlen < 0) { + if (Config.quickAbort.min < 0) { debugs(90, 3, "CheckQuickAbort2: NO disabled"); return 0; } @@ -776,7 +783,7 @@ return 1; } - if ((expectlen - curlen) < minlen) { + if ((expectlen - curlen) < (Config.quickAbort.min << 10)) { debugs(90, 3, "CheckQuickAbort2: NO only little more left"); return 0; } @@ -791,7 +798,7 @@ return 0; } - if ((curlen / (expectlen / 100)) > (size_t)Config.quickAbort.pct) { + if ((curlen / (expectlen / 100)) > (Config.quickAbort.pct)) { debugs(90, 3, "CheckQuickAbort2: NO past point of no return"); return 0; } @@ -828,8 +835,8 @@ output->Printf("\tClient #%d, %p\n", clientNumber, _callback.callback_data); - output->Printf("\t\tcopy_offset: %lu\n", - (unsigned long) copyInto.offset); + output->Printf("\t\tcopy_offset: %"PRId64"\n", + copyInto.offset); output->Printf("\t\tcopy_size: %d\n", (int) copyInto.length); Index: squid3/src/store_digest.cc diff -u squid3/src/store_digest.cc:1.23 squid3/src/store_digest.cc:1.18.10.5 --- squid3/src/store_digest.cc:1.23 Mon Apr 30 10:51:41 2007 +++ squid3/src/store_digest.cc Mon Jun 18 13:59:35 2007 @@ -247,7 +247,7 @@ } /* do not digest huge objects */ - if (e->swap_file_sz > Config.Store.maxObjectSize) { + if (e->swap_file_sz > (uint64_t )Config.Store.maxObjectSize) { debugs(71, 6, "storeDigestAddable: NO: too big"); return 0; } Index: squid3/src/store_dir.cc diff -u squid3/src/store_dir.cc:1.24 squid3/src/store_dir.cc:1.21.2.3 --- squid3/src/store_dir.cc:1.24 Tue May 29 06:51:50 2007 +++ squid3/src/store_dir.cc Mon Jun 18 13:59:36 2007 @@ -330,13 +330,13 @@ } void -StoreController::updateSize(size_t size, int sign) +StoreController::updateSize(int64_t size, int sign) { fatal("StoreController has no independent size\n"); } void -SwapDir::updateSize(size_t size, int sign) +SwapDir::updateSize(int64_t size, int sign) { int blks = (size + fs.blksize - 1) / fs.blksize; int k = (blks * fs.blksize >> 10) * sign; @@ -707,6 +707,8 @@ StoreHashIndex::StoreHashIndex() { + if (store_table) + abort(); assert (store_table == NULL); } @@ -880,7 +882,7 @@ } void -StoreHashIndex::updateSize(size_t, int) +StoreHashIndex::updateSize(int64_t, int) {} void Index: squid3/src/store_log.cc diff -u squid3/src/store_log.cc:1.11 squid3/src/store_log.cc:1.7.2.4 --- squid3/src/store_log.cc:1.11 Tue May 29 06:51:50 2007 +++ squid3/src/store_log.cc Mon Apr 30 10:08:17 2007 @@ -76,7 +76,7 @@ * Because if we print it before the swap file number, it'll break * the existing log format. */ - logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d %s %d/%d %s %s\n", + logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d %s %"PRId64"/%"PRId64" %s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], Index: squid3/src/store_swapmeta.cc diff -u squid3/src/store_swapmeta.cc:1.8 squid3/src/store_swapmeta.cc:1.6.10.3 --- squid3/src/store_swapmeta.cc:1.8 Sat Apr 28 15:51:56 2007 +++ squid3/src/store_swapmeta.cc Tue Jul 24 00:34:00 2007 @@ -73,7 +73,7 @@ } T = StoreMeta::Add(T, t); - t = StoreMeta::Factory(STORE_META_STD,STORE_HDR_METASIZE,&e->timestamp); + t = StoreMeta::Factory(STORE_META_STD_LFS,STORE_HDR_METASIZE,&e->timestamp); if (!t) { storeSwapTLVFree(TLV); Index: squid3/src/store_swapout.cc diff -u squid3/src/store_swapout.cc:1.27 squid3/src/store_swapout.cc:1.19.2.9 --- squid3/src/store_swapout.cc:1.27 Mon Apr 30 10:51:41 2007 +++ squid3/src/store_swapout.cc Tue Jul 31 14:09:47 2007 @@ -165,7 +165,7 @@ if (anEntry->swap_status != SWAPOUT_WRITING) break; - ssize_t swapout_size = (ssize_t) (mem->endOffset() - mem->swapout.queue_offset); + int64_t swapout_size = mem->endOffset() - mem->swapout.queue_offset; if (anEntry->store_status == STORE_PENDING) if (swapout_size < SM_PAGE_SIZE) @@ -189,20 +189,20 @@ if (!swapoutPossible()) return; - debugs(20, 7, "storeSwapOut: mem_obj->inmem_lo = " << mem_obj->inmem_lo); - debugs(20, 7, "storeSwapOut: mem_obj->endOffset() = " << mem_obj->endOffset()); - debugs(20, 7, "storeSwapOut: swapout.queue_offset = " << mem_obj->swapout.queue_offset); + debugs(20, 7, HERE << "storeSwapOut: mem->inmem_lo = " << mem_obj->inmem_lo); + debugs(20, 7, HERE << "storeSwapOut: mem->endOffset() = " << mem_obj->endOffset()); + debugs(20, 7, HERE << "storeSwapOut: swapout.queue_offset = " << mem_obj->swapout.queue_offset); if (mem_obj->swapout.sio != NULL) debugs(20, 7, "storeSwapOut: storeOffset() = " << mem_obj->swapout.sio->offset() ); - ssize_t swapout_maxsize = (ssize_t) (mem_obj->endOffset() - mem_obj->swapout.queue_offset); + int64_t swapout_maxsize = mem_obj->endOffset() - mem_obj->swapout.queue_offset; assert(swapout_maxsize >= 0); - off_t const lowest_offset = mem_obj->lowestMemReaderOffset(); + int64_t const lowest_offset = mem_obj->lowestMemReaderOffset(); - debugs(20, 7, "storeSwapOut: lowest_offset = " << lowest_offset); + debugs(20, 7, HERE << "storeSwapOut: lowest_offset = " << lowest_offset); /* * Grab the swapout_size and check to see whether we're going to defer @@ -224,17 +224,17 @@ } trimMemory(); -#if SIZEOF_OFF_T == 4 +#if SIZEOF_INT64_T == 4 if (mem_obj->endOffset() > 0x7FFF0000) { - debugs(20, 0, "WARNING: preventing off_t overflow for " << url() ); + debugs(20, 0, "WARNING: preventing int64_t overflow for %s\n", url()); abort(); return; } #endif if (swap_status == SWAPOUT_WRITING) - assert(mem_obj->inmem_lo <= (off_t)mem_obj->objectBytesOnDisk() ); + assert(mem_obj->inmem_lo <= mem_obj->objectBytesOnDisk() ); if (!swapOutAble()) return; Index: squid3/src/structs.h diff -u squid3/src/structs.h:1.111 squid3/src/structs.h:1.106.2.5 --- squid3/src/structs.h:1.111 Wed Aug 1 18:50:51 2007 +++ squid3/src/structs.h Sun Aug 12 00:25:26 2007 @@ -107,7 +107,7 @@ { acl_size_t *next; acl_list *aclList; - size_t size; + int64_t size; }; struct _ushortlist @@ -209,13 +209,13 @@ struct { - size_t min; + int64_t min; int pct; - size_t max; + int64_t max; } quickAbort; - size_t readAheadGap; + int64_t readAheadGap; RemovalPolicySettings *replPolicy; RemovalPolicySettings *memPolicy; time_t negativeTtl; @@ -254,7 +254,7 @@ Timeout; size_t maxRequestHeaderSize; - size_t maxRequestBodySize; + int64_t maxRequestBodySize; size_t maxReplyHeaderSize; acl_size_t *ReplyBodySize; @@ -476,8 +476,8 @@ { int objectsPerBucket; size_t avgObjectSize; - size_t maxObjectSize; - size_t minObjectSize; + int64_t maxObjectSize; + int64_t minObjectSize; size_t maxInMemObjSize; } @@ -660,7 +660,7 @@ comm_incoming; int max_open_disk_fds; int uri_whitespace; - size_t rangeOffsetLimit; + int64_t rangeOffsetLimit; #if MULTICAST_MISS_STREAM struct Index: squid3/src/tunnel.cc diff -u squid3/src/tunnel.cc:1.31 squid3/src/tunnel.cc:1.28.6.5 --- squid3/src/tunnel.cc:1.31 Sat Jun 2 05:50:57 2007 +++ squid3/src/tunnel.cc Sun Jul 22 01:50:40 2007 @@ -90,7 +90,7 @@ void dataSent (size_t amount); int len; char *buf; - size_t *size_ptr; /* pointer to size in an ConnStateData for logging */ + int64_t *size_ptr; /* pointer to size in an ConnStateData for logging */ private: int fd_; @@ -579,7 +579,7 @@ } void -tunnelStart(ClientHttpRequest * http, size_t * size_ptr, int *status_ptr) +tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) { /* Create state structure. */ TunnelStateData *tunnelState = NULL; Index: squid3/src/ufsdump.cc diff -u squid3/src/ufsdump.cc:1.10 squid3/src/ufsdump.cc:1.10.6.2 --- squid3/src/ufsdump.cc:1.10 Wed Sep 13 12:50:43 2006 +++ squid3/src/ufsdump.cc Thu Jul 26 15:15:43 2007 @@ -56,6 +56,26 @@ #endif /* end stub functions */ +struct MetaStd{ + time_t timestamp; + time_t lastref; + time_t expires; + time_t lastmod; + size_t swap_file_sz; + u_short refcount; + u_short flags; +}; + +struct MetaStdLfs{ + time_t timestamp; + time_t lastref; + time_t expires; + time_t lastmod; + uint64_t swap_file_sz; + u_short refcount; + u_short flags; +}; + struct DumpStoreMeta : public unary_function { DumpStoreMeta(){} @@ -69,13 +89,27 @@ break; case STORE_META_STD: + std::cout << "STD, Size:" << ((struct MetaStd*)x.value)->swap_file_sz << + " Flags: 0x" << std::hex << ((struct MetaStd*)x.value)->flags << std::dec << + " Refcount: " << ((struct MetaStd*)x.value)->refcount << + std::endl; + break; + + case STORE_META_STD_LFS: + std::cout << "STD_LFS, Size: " << ((struct MetaStdLfs*)x.value)->swap_file_sz << + " Flags: 0x" << std::hex << ((struct MetaStdLfs*)x.value)->flags << std::dec << + " Refcount: " << ((struct MetaStdLfs*)x.value)->refcount << + std::endl; break; case STORE_META_URL: assert (((char *)x.value)[x.length - 1] == 0); std::cout << "URL: " << (char *)x.value << std::endl; + break; default: + std::cout << "Unknown store meta type: " << (int)x.getType() << + " of length " << x.length << std::endl; break; } } Index: squid3/src/ICAP/ChunkedCodingParser.cc diff -u squid3/src/ICAP/ChunkedCodingParser.cc:1.4 squid3/src/ICAP/ChunkedCodingParser.cc:1.4.6.1 --- squid3/src/ICAP/ChunkedCodingParser.cc:1.4 Fri Apr 6 05:54:14 2007 +++ squid3/src/ICAP/ChunkedCodingParser.cc Mon Jun 18 13:59:36 2007 @@ -66,10 +66,10 @@ if (findCrlf(crlfBeg, crlfEnd)) { debugs(93,7, "found chunk-size end: " << crlfBeg << "-" << crlfEnd); - int size = -1; + int64_t size = -1; const char *p = 0; - if (StringToInt(theIn->content(), size, &p, 16)) { + if (StringToInt64(theIn->content(), size, &p, 16)) { if (size < 0) { throw TexcHere("negative chunk size"); return; @@ -104,7 +104,7 @@ { Must(theLeftBodySize > 0); // Should, really - const size_t availSize = XMIN(theLeftBodySize, (size_t)theIn->contentSize()); + const size_t availSize = XMIN(theLeftBodySize, (uint64_t)theIn->contentSize()); const size_t safeSize = XMIN(availSize, (size_t)theOut->potentialSpaceSize()); doNeedMoreData = availSize < theLeftBodySize; Index: squid3/src/ICAP/ChunkedCodingParser.h diff -u squid3/src/ICAP/ChunkedCodingParser.h:1.2 squid3/src/ICAP/ChunkedCodingParser.h:1.2.20.1 --- squid3/src/ICAP/ChunkedCodingParser.h:1.2 Mon Nov 21 19:13:08 2005 +++ squid3/src/ICAP/ChunkedCodingParser.h Mon Jun 18 13:59:36 2007 @@ -82,8 +82,8 @@ MemBuf *theOut; Step theStep; - size_t theChunkSize; - size_t theLeftBodySize; + uint64_t theChunkSize; + uint64_t theLeftBodySize; bool doNeedMoreData; }; Index: squid3/src/ICAP/ICAPModXact.cc diff -u squid3/src/ICAP/ICAPModXact.cc:1.29 squid3/src/ICAP/ICAPModXact.cc:1.19.6.6 --- squid3/src/ICAP/ICAPModXact.cc:1.29 Thu Aug 9 16:51:11 2007 +++ squid3/src/ICAP/ICAPModXact.cc Sun Aug 12 00:25:27 2007 @@ -333,20 +333,20 @@ { Must(act.active()); // asbolute start of unprocessed data - const size_t start = act.offset(); + const uint64_t start = act.offset(); // absolute end of buffered data - const size_t end = virginConsumed + virgin.body_pipe->buf().contentSize(); + const uint64_t end = virginConsumed + virgin.body_pipe->buf().contentSize(); Must(virginConsumed <= start && start <= end); - return end - start; + return static_cast(end - start); } // pointer to buffered virgin body data available for the specified activity const char *ICAPModXact::virginContentData(const VirginBodyAct &act) const { Must(act.active()); - const size_t start = act.offset(); + const uint64_t start = act.offset(); Must(virginConsumed <= start); - return virgin.body_pipe->buf().content() + (start-virginConsumed); + return virgin.body_pipe->buf().content() + static_cast(start-virginConsumed); } void ICAPModXact::virginConsume() @@ -374,8 +374,8 @@ } const size_t have = static_cast(bp.buf().contentSize()); - const size_t end = virginConsumed + have; - size_t offset = end; + const uint64_t end = virginConsumed + have; + uint64_t offset = end; debugs(93, 9, HERE << "max virgin consumption offset=" << offset << " acts " << virginBodyWriting.active() << virginBodySending.active() << @@ -390,7 +390,7 @@ Must(virginConsumed <= offset && offset <= end); - if (const size_t size = offset - virginConsumed) { + if (const size_t size = static_cast(offset - virginConsumed)) { debugs(93, 8, HERE << "consuming " << size << " out of " << have << " virgin body bytes"); bp.consume(size); @@ -1215,7 +1215,7 @@ ad = 0; else if (virginBody.knownSize()) - ad = XMIN(ad, virginBody.size()); // not more than we have + ad = XMIN(static_cast(ad), virginBody.size()); // not more than we have debugs(93, 5, "ICAPModXact should offer " << ad << "-byte preview " << "(service wanted " << wantedSize << ")"); @@ -1370,7 +1370,7 @@ else method = METHOD_NONE; - ssize_t size; + int64_t size; // expectingBody returns true for zero-sized bodies, but we will not // get a pipe for that body, so we treat the message as bodyless if (method != METHOD_NONE && msg->expectingBody(method, size) && size) { @@ -1410,9 +1410,9 @@ : theData(dtUnexpected) {} -void SizedEstimate::expect(ssize_t aSize) +void SizedEstimate::expect(int64_t aSize) { - theData = (aSize >= 0) ? aSize : (ssize_t)dtUnknown; + theData = (aSize >= 0) ? aSize : (int64_t)dtUnknown; } bool SizedEstimate::expected() const @@ -1426,10 +1426,10 @@ return theData != dtUnknown; } -size_t SizedEstimate::size() const +uint64_t SizedEstimate::size() const { Must(knownSize()); - return static_cast(theData); + return static_cast(theData); } @@ -1453,13 +1453,13 @@ { Must(active()); Must(size >= 0); - theStart += size; + theStart += static_cast(size); } -size_t VirginBodyAct::offset() const +uint64_t VirginBodyAct::offset() const { Must(active()); - return theStart; + return static_cast(theStart); } Index: squid3/src/ICAP/ICAPModXact.h diff -u squid3/src/ICAP/ICAPModXact.h:1.8 squid3/src/ICAP/ICAPModXact.h:1.6.6.3 --- squid3/src/ICAP/ICAPModXact.h:1.8 Tue Jun 19 14:52:08 2007 +++ squid3/src/ICAP/ICAPModXact.h Sun Jul 22 01:50:42 2007 @@ -59,17 +59,17 @@ public: SizedEstimate(); // not expected by default - void expect(ssize_t aSize); // expect with any, even unknown size + void expect(int64_t aSize); // expect with any, even unknown size bool expected() const; /* other members can be accessed iff expected() */ bool knownSize() const; - size_t size() const; // can be accessed iff knownSize() + uint64_t size() const; // can be accessed iff knownSize() private: enum { dtUnexpected = -2, dtUnknown = -1 }; - ssize_t theData; // combines expectation and size info to save RAM + int64_t theData; // combines expectation and size info to save RAM }; // Virgin body may be used for two activities: (a) writing preview or prime @@ -91,11 +91,11 @@ // methods below require active() - size_t offset() const; // the absolute beginning of not-yet-acted-on data + uint64_t offset() const; // the absolute beginning of not-yet-acted-on data void progress(size_t size); // note processed body bytes private: - size_t theStart; // unprocessed virgin body data offset + int64_t theStart; // unprocessed virgin body data offset typedef enum { stUndecided, stActive, stDisabled } State; State theState; @@ -255,7 +255,7 @@ SizedEstimate virginBody; VirginBodyAct virginBodyWriting; // virgin body writing state VirginBodyAct virginBodySending; // virgin body sending state - size_t virginConsumed; // virgin data consumed so far + uint64_t virginConsumed; // virgin data consumed so far ICAPPreview preview; // use for creating (writing) the preview ChunkedCodingParser *bodyParser; // ICAP response body parser Index: squid3/src/fs/coss/CossSwapDir.h diff -u squid3/src/fs/coss/CossSwapDir.h:1.8 squid3/src/fs/coss/CossSwapDir.h:1.6.10.2 --- squid3/src/fs/coss/CossSwapDir.h:1.8 Tue May 29 06:51:52 2007 +++ squid3/src/fs/coss/CossSwapDir.h Fri Aug 3 13:06:10 2007 @@ -66,16 +66,16 @@ dlink_list membufs; CossMemBuf *current_membuf; - size_t current_offset; /* in Blocks */ + off_t current_offset; /* in Blocks */ int numcollisions; dlink_list cossindex; unsigned int blksz_bits; unsigned int blksz_mask; /* just 1< theFile; - char *storeCossMemPointerFromDiskOffset(size_t offset, CossMemBuf ** mb); + char *storeCossMemPointerFromDiskOffset(off_t offset, CossMemBuf ** mb); void storeCossMemBufUnlock(StoreIOState::Pointer); - CossMemBuf *createMemBuf(size_t start, sfileno curfn, int *collision); + CossMemBuf *createMemBuf(off_t start, sfileno curfn, int *collision); sfileno allocate(const StoreEntry * e, int which); void startMembuf(); Index: squid3/src/fs/coss/store_coss.h diff -u squid3/src/fs/coss/store_coss.h:1.14 squid3/src/fs/coss/store_coss.h:1.14.6.1 --- squid3/src/fs/coss/store_coss.h:1.14 Tue Sep 19 01:52:40 2006 +++ squid3/src/fs/coss/store_coss.h Mon Jun 18 13:59:36 2007 @@ -24,8 +24,8 @@ void maybeWrite(CossSwapDir * SD); void write(CossSwapDir * SD); dlink_node node; - size_t diskstart; /* in blocks */ - size_t diskend; /* in blocks */ + off_t diskstart; /* in blocks */ + off_t diskend; /* in blocks */ CossSwapDir *SD; int lockcount; char buffer[COSS_MEMBUF_SZ]; @@ -61,7 +61,7 @@ char *requestbuf; size_t requestlen; size_t requestoffset; /* in blocks */ - sfileno reqdiskoffset; /* in blocks */ + int64_t reqdiskoffset; /* in blocks */ struct { @@ -76,7 +76,7 @@ flags; CossMemBuf *locked_membuf; - size_t st_size; + off_t st_size; void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data); void write(char const *buf, size_t size, off_t offset, FREE * free_func); void close(); Index: squid3/src/fs/coss/store_dir_coss.cc diff -u squid3/src/fs/coss/store_dir_coss.cc:1.37 squid3/src/fs/coss/store_dir_coss.cc:1.30.6.4 --- squid3/src/fs/coss/store_dir_coss.cc:1.37 Tue May 29 06:51:52 2007 +++ squid3/src/fs/coss/store_dir_coss.cc Mon Jun 18 13:59:36 2007 @@ -81,7 +81,7 @@ static EVH storeCossRebuildFromSwapLog; static StoreEntry *storeCossAddDiskRestore(CossSwapDir * SD, const cache_key * key, int file_number, - size_t swap_file_sz, + uint64_t swap_file_sz, time_t expires, time_t timestamp, time_t lastref, @@ -514,7 +514,7 @@ static StoreEntry * storeCossAddDiskRestore(CossSwapDir * SD, const cache_key * key, int file_number, - size_t swap_file_sz, + uint64_t swap_file_sz, time_t expires, time_t timestamp, time_t lastref, @@ -1034,7 +1034,7 @@ { unsigned int i; unsigned int size; - unsigned long max_offset; + off_t max_offset; i = GetInteger(); size = i << 10; /* Mbytes to Kbytes */ @@ -1066,9 +1066,9 @@ * largest possible sfileno, assuming sfileno is a 25-bit * signed integer, as defined in structs.h. */ - max_offset = (unsigned long) 0xFFFFFF << blksz_bits; + max_offset = (off_t) 0xFFFFFF << blksz_bits; - if ((unsigned long)max_size > (unsigned long)(max_offset>>10)) { + if ((off_t)max_size > (max_offset>>10)) { debugs(47, 0, "COSS block-size = " << (1< ((size_t)max_size << 10)) { + if ((current_offset + allocsize) > ((off_t)max_size << 10)) { /* * tried to allocate past the end of the disk, so wrap * back to the beginning @@ -163,9 +163,9 @@ sio->swap_dirn = index; sio->swap_filen = allocate(&e, COSS_ALLOC_ALLOCATE); debugs(79, 3, "storeCossCreate: offset " << - (long int) storeCossFilenoToDiskOffset(sio->swap_filen) << + storeCossFilenoToDiskOffset(sio->swap_filen) << ", size " << (long int) cstate->st_size << ", end " << - (long int) (sio->swap_filen + cstate->st_size)); + (sio->swap_filen + cstate->st_size)); /* assume allocate() always succeeds */ assert(-1 != sio->swap_filen); @@ -301,7 +301,7 @@ offset_ = offset; flags.reading = 1; - if ((offset + size) > st_size) + if ((offset + (off_t)size) > st_size) size = st_size - offset; requestlen = size; @@ -431,7 +431,7 @@ } char * -CossSwapDir::storeCossMemPointerFromDiskOffset(size_t offset, CossMemBuf ** mb) +CossSwapDir::storeCossMemPointerFromDiskOffset(off_t offset, CossMemBuf ** mb) { CossMemBuf *t; dlink_node *m; @@ -485,7 +485,7 @@ { CossMemBuf *t; dlink_node *m; - int end; + off_t end; /* First, flush pending IO ops */ io->sync(); @@ -505,7 +505,7 @@ end = (t == current_membuf) ? current_offset : t->diskend; - if ((size_t)end > t->diskstart) + if (end > t->diskstart) theFile->write(new CossWrite(WriteRequest((char const *)&t->buffer, t->diskstart, end - t->diskstart, NULL), t)); /* and flush */ @@ -539,7 +539,7 @@ } CossMemBuf * -CossSwapDir::createMemBuf(size_t start, sfileno curfn, int *collision) +CossSwapDir::createMemBuf(off_t start, sfileno curfn, int *collision) { CossMemBuf *newmb; CossMemBuf *t; Index: squid3/src/fs/ufs/store_dir_ufs.cc diff -u squid3/src/fs/ufs/store_dir_ufs.cc:1.33 squid3/src/fs/ufs/store_dir_ufs.cc:1.28.6.5 --- squid3/src/fs/ufs/store_dir_ufs.cc:1.33 Tue May 29 06:51:52 2007 +++ squid3/src/fs/ufs/store_dir_ufs.cc Thu Jul 26 15:15:44 2007 @@ -682,7 +682,7 @@ StoreEntry * UFSSwapDir::addDiskRestore(const cache_key * key, sfileno file_number, - size_t swap_file_sz, + uint64_t swap_file_sz, time_t expires, time_t timestamp, time_t lastref, @@ -753,6 +753,13 @@ debugs(47, 3, "Cache Dir #" << index << " log opened on FD " << fd); } +static void +FreeHeader(void *address) +{ + StoreSwapLogHeader *anObject = static_cast (address); + delete anObject; +} + FILE * UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag) { @@ -765,6 +772,7 @@ struct stat clean_sb; FILE *fp; int fd; + StoreSwapLogHeader *head; if (::stat(swaplog_path, &log_sb) < 0) { debugs(47, 1, "Cache Dir #" << index << ": No log file"); @@ -782,13 +790,19 @@ /* open a write-only FD for the new log */ fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); - + if (fd < 0) { debugs(50, 1, "" << new_path << ": " << xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); } - + swaplog_fd = fd; + + head = new StoreSwapLogHeader; + + file_write(swaplog_fd, -1, head, head->record_size, + NULL, NULL, FreeHeader); + /* open a read-only stream of the old log */ fp = fopen(swaplog_path, "rb"); @@ -850,6 +864,7 @@ UFSSwapDir::writeCleanStart() { UFSCleanLog *state = new UFSCleanLog(this); + StoreSwapLogHeader header; #if HAVE_FCHMOD struct stat sb; @@ -869,6 +884,10 @@ state->cln = xstrdup(logFile(".last-clean")); state->outbuf = (char *)xcalloc(CLEAN_BUF_SZ, 1); state->outbuf_offset = 0; + /*copy the header */ + xmemcpy(state->outbuf, &header, sizeof(StoreSwapLogHeader)); + state->outbuf_offset += header.record_size; + state->walker = repl->WalkInit(repl); ::unlink(state->cln); debugs(47, 3, "storeDirWriteCleanLogs: opened " << state->newLog << ", FD " << state->fd); @@ -878,9 +897,9 @@ fchmod(state->fd, sb.st_mode); #endif + cleanLog = state; - return 0; } Index: squid3/src/fs/ufs/ufscommon.cc diff -u squid3/src/fs/ufs/ufscommon.cc:1.12 squid3/src/fs/ufs/ufscommon.cc:1.8.6.6 --- squid3/src/fs/ufs/ufscommon.cc:1.12 Wed Aug 1 16:50:53 2007 +++ squid3/src/fs/ufs/ufscommon.cc Sun Jul 29 06:51:00 2007 @@ -45,7 +45,129 @@ CBDATA_CLASS_INIT(RebuildState); -RebuildState::RebuildState (RefCount aSwapDir) : sd (aSwapDir), e(NULL), fromLog(true), _done (false) + +class UFSSwapLogParser_old:public UFSSwapLogParser{ +public: + struct StoreSwapLogDataOld{ + char op; + sfileno swap_filen; + time_t timestamp; + time_t lastref; + time_t expires; + time_t lastmod; + size_t swap_file_sz; + u_short refcount; + u_short flags; + unsigned char key[MD5_DIGEST_CHARS]; + }; + UFSSwapLogParser_old(FILE *fp):UFSSwapLogParser(fp) + { + record_size = sizeof(UFSSwapLogParser_old::StoreSwapLogDataOld); + } + bool ReadRecord(StoreSwapLogData &swapData); +}; + + +bool UFSSwapLogParser_old::ReadRecord(StoreSwapLogData &swapData){ + UFSSwapLogParser_old::StoreSwapLogDataOld readData; + int bytes = sizeof(UFSSwapLogParser_old::StoreSwapLogDataOld); + + assert(log); + + if (fread(&readData, bytes, 1, log) != 1){ + return false; + } + swapData.op = readData.op; + swapData.swap_filen = readData.swap_filen; + swapData.timestamp = readData.timestamp; + swapData.lastref = readData.lastref; + swapData.expires = readData.expires; + swapData.lastmod = readData.lastmod; + swapData.swap_file_sz = readData.swap_file_sz; + swapData.refcount = readData.refcount; + swapData.flags = readData.flags; + xmemcpy(swapData.key, readData.key, MD5_DIGEST_CHARS); + return true; +} + + +class UFSSwapLogParser_v1:public UFSSwapLogParser{ +public: + UFSSwapLogParser_v1(FILE *fp):UFSSwapLogParser(fp) + { + record_size = sizeof(StoreSwapLogData); + } + bool ReadRecord(StoreSwapLogData &swapData); +}; + + +bool UFSSwapLogParser_v1::ReadRecord(StoreSwapLogData &swapData) +{ + int bytes = sizeof(StoreSwapLogData); + + assert(log); + + if (fread(&swapData, bytes, 1, log) != 1){ + return false; + } + return true; +} + + +UFSSwapLogParser *UFSSwapLogParser::GetUFSSwapLogParser(FILE *fp) +{ + StoreSwapLogHeader header; + + assert(fp); + + if (fread(&header, sizeof(StoreSwapLogHeader), 1, fp) != 1) + return NULL; + + if (header.op != SWAP_LOG_VERSION){ + debugs(47, 1, "Old swap file detected... "); + fseek(fp, 0, SEEK_SET); + return new UFSSwapLogParser_old(fp); + } + + if (header.version == 1){ + if (f