--------------------- PatchSet 4063 Date: 2007/02/20 16:04:28 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Added an expectMoreAfter() method to allow consumers to detect EOF conditions prior to consuming buffered content. Members: src/BodyPipe.cc:1.1.2.1->1.1.2.2 src/BodyPipe.h:1.1.2.1->1.1.2.2 Index: squid3/src/BodyPipe.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/BodyPipe.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/BodyPipe.cc 14 Feb 2007 04:44:10 -0000 1.1.2.1 +++ squid3/src/BodyPipe.cc 20 Feb 2007 16:04:28 -0000 1.1.2.2 @@ -63,10 +63,16 @@ return static_cast(theBodySize); } +bool BodyPipe::expectMoreAfter(size_t offset) const +{ + assert(theGetSize <= offset); + return offset < thePutSize || // buffer has more now or + (!productionEnded() && mayNeedMoreData()); // buffer will have more +} + bool BodyPipe::exhausted() const { - return theGetSize >= thePutSize && // no old data buffered - !mayNeedMoreData(); // no new data expected + return !expectMoreAfter(theGetSize); } size_t BodyPipe::unproducedSize() const Index: squid3/src/BodyPipe.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/BodyPipe.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/BodyPipe.h 14 Feb 2007 04:44:10 -0000 1.1.2.1 +++ squid3/src/BodyPipe.h 20 Feb 2007 16:04:36 -0000 1.1.2.2 @@ -99,6 +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 exhausted() const; // saw eof/abort and all data consumed const MemBuf &buf() const { return theBuf; }