From a3410db0c8af2331e14c2bb8b7632720ff96a254 Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Fri, 13 Apr 2012 10:30:11 +0000 Subject: [PATCH] THRIFT-1564 Minor fixes to TZlibTransport Patch: Dave Watson git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1325712 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/thrift/transport/TZlibTransport.cpp | 10 ++++++++-- lib/cpp/src/thrift/transport/TZlibTransport.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.cpp b/lib/cpp/src/thrift/transport/TZlibTransport.cpp index fc407cb22..98b25b897 100644 --- a/lib/cpp/src/thrift/transport/TZlibTransport.cpp +++ b/lib/cpp/src/thrift/transport/TZlibTransport.cpp @@ -110,9 +110,15 @@ TZlibTransport::~TZlibTransport() { } bool TZlibTransport::isOpen() { - return (readAvail() > 0) || transport_->isOpen(); + return (readAvail() > 0) || (rstream_->avail_in > 0) || transport_->isOpen(); } +bool TZlibTransport::peek() { + return (readAvail() > 0) || (rstream_->avail_in > 0) || transport_->peek(); +} + + + // READING STRATEGY // // We have two buffers for reading: one containing the compressed data (crbuf_) @@ -253,7 +259,7 @@ void TZlibTransport::flush() { "flush() called after finish()"); } - flushToTransport(Z_SYNC_FLUSH); + flushToTransport(Z_FULL_FLUSH); } void TZlibTransport::finish() { diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.h b/lib/cpp/src/thrift/transport/TZlibTransport.h index b3656415a..607969c86 100644 --- a/lib/cpp/src/thrift/transport/TZlibTransport.h +++ b/lib/cpp/src/thrift/transport/TZlibTransport.h @@ -144,6 +144,7 @@ class TZlibTransport : public TVirtualTransport { ~TZlibTransport(); bool isOpen(); + bool peek(); void open() { transport_->open();