You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/02/18 21:56:27 UTC

git commit: THRIFT-2359 TBufferedTransport doesn't clear it's buffer on a failed flush call

Repository: thrift
Updated Branches:
  refs/heads/master 06ad7218a -> 8c1779d67


THRIFT-2359 TBufferedTransport doesn't clear it's buffer on a failed flush call

Patch: Chris Trotman


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/8c1779d6
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/8c1779d6
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/8c1779d6

Branch: refs/heads/master
Commit: 8c1779d6712f102f2844621508e9f445540be7d2
Parents: 06ad721
Author: Jens Geyer <je...@apache.org>
Authored: Tue Feb 18 21:55:43 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Feb 18 21:55:43 2014 +0100

----------------------------------------------------------------------
 lib/php/lib/Thrift/Transport/TBufferedTransport.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/8c1779d6/lib/php/lib/Thrift/Transport/TBufferedTransport.php
----------------------------------------------------------------------
diff --git a/lib/php/lib/Thrift/Transport/TBufferedTransport.php b/lib/php/lib/Thrift/Transport/TBufferedTransport.php
index 0d3ad98..270c004 100644
--- a/lib/php/lib/Thrift/Transport/TBufferedTransport.php
+++ b/lib/php/lib/Thrift/Transport/TBufferedTransport.php
@@ -156,8 +156,13 @@ class TBufferedTransport extends TTransport {
 
   public function flush() {
     if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) {
-      $this->transport_->write($this->wBuf_);
+      $out = $this->wBuf_;
+
+      // Note that we clear the internal wBuf_ prior to the underlying write
+      // to ensure we're in a sane state (i.e. internal buffer cleaned)
+      // if the underlying write throws up an exception
       $this->wBuf_ = '';
+      $this->transport_->write($out);
     }
     $this->transport_->flush();
   }