git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@704710
13f79535-47bb-0310-9956-
ffa450edef68
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);
}
}
$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_ = '';
}
}