Author: mcslee
Date: Tue Oct 14 15:00:36 2008
New Revision: 704710
URL: http://svn.apache.org/viewvc?rev=704710&view=rev
Log:
THRIFT-169: Fixes framed/buffered transport state on underlying flush failure
Modified:
incubator/thrift/trunk/lib/php/src/transport/TBufferedTransport.php
incubator/thrift/trunk/lib/php/src/transport/TFramedTransport.php
Modified: incubator/thrift/trunk/lib/php/src/transport/TBufferedTransport.php
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/transport/TBufferedTransport.php?rev=704710&r1=704709&r2=704710&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/php/src/transport/TBufferedTransport.php
(original)
+++ incubator/thrift/trunk/lib/php/src/transport/TBufferedTransport.php Tue Oct
14 15:00:36 2008
@@ -131,8 +131,13 @@
public function write($buf) {
$this->wBuf_ .= $buf;
if (strlen($this->wBuf_) >= $this->wBufSize_) {
- $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);
}
}
Modified: incubator/thrift/trunk/lib/php/src/transport/TFramedTransport.php
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/transport/TFramedTransport.php?rev=704710&r1=704709&r2=704710&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/php/src/transport/TFramedTransport.php (original)
+++ incubator/thrift/trunk/lib/php/src/transport/TFramedTransport.php Tue Oct
14 15:00:36 2008
@@ -158,9 +158,13 @@
$out = pack('N', strlen($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();
- $this->wBuf_ = '';
}
}