Thrift: Fixing memory leak issue with memory buffer used in TPipedTransport
authorJames Wang <jwang@apache.org>
Tue, 17 Apr 2007 22:38:58 +0000 (22:38 +0000)
committerJames Wang <jwang@apache.org>
Tue, 17 Apr 2007 22:38:58 +0000 (22:38 +0000)
Reviewed by: boz

Test Plan: tested with falcon action_listener using PeekProcessor

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665101 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/transport/TTransportUtils.h

index cb9a95f..3db22e7 100644 (file)
@@ -318,6 +318,12 @@ class TMemoryBuffer : public TTransport {
 
   uint32_t read(uint8_t* buf, uint32_t len);
 
+  void readEnd() {
+    if (rPos_ == wPos_) {
+      resetBuffer();
+    }
+  }
+
   void write(const uint8_t* buf, uint32_t len);
 
   uint32_t available() {
@@ -423,11 +429,14 @@ class TPipedTransport : virtual public TTransport {
   uint32_t read(uint8_t* buf, uint32_t len);
 
   void readEnd() {
+
     if (pipeOnRead_) {
       dstTrans_->write(rBuf_, rLen_);
       dstTrans_->flush();
     }
 
+    srcTrans_->readEnd();
+
     // reset state
     rLen_ = 0;
     rPos_ = 0;