From 4fd2dbaf0698662ad46bdb4b0a1507f325a0b051 Mon Sep 17 00:00:00 2001 From: James Wang Date: Tue, 17 Apr 2007 22:38:58 +0000 Subject: [PATCH] Thrift: Fixing memory leak issue with memory buffer used in TPipedTransport 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/cpp/src/transport/TTransportUtils.h b/lib/cpp/src/transport/TTransportUtils.h index cb9a95f7..3db22e7c 100644 --- a/lib/cpp/src/transport/TTransportUtils.h +++ b/lib/cpp/src/transport/TTransportUtils.h @@ -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; -- 2.17.1