[
https://issues.apache.org/jira/browse/THRIFT-2359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13903502#comment-13903502
]
Jens Geyer commented on THRIFT-2359:
------------------------------------
Hi [~solarnz],
if that's such an "easyfix", I'd love to review and commit your patch ;-)
What do you think?
> TBufferedTransport doesn't clear it's buffer on a failed flush call
> -------------------------------------------------------------------
>
> Key: THRIFT-2359
> URL: https://issues.apache.org/jira/browse/THRIFT-2359
> Project: Thrift
> Issue Type: Bug
> Components: PHP - Library
> Affects Versions: 0.9.1
> Reporter: Chris Trotman
> Labels: easyfix
>
> On flush in the php implementation of the TBufferedTransport it doesn't clear
> the internal buffer before calling the underlying write function. However the
> write function in TBufferedTransport does.
> {code:title=TBufferedTransport.php}
> public function write($buf) {
> $this->wBuf_ .= $buf;
> if (TStringFuncFactory::create()->strlen($this->wBuf_) >=
> $this->wBufSize_) {
> $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);
> }
> }
> public function flush() {
> if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) {
> $this->transport_->write($this->wBuf_);
> $this->wBuf_ = '';
> }
> $this->transport_->flush();
> }
> {code}
> If a write on the underlying transport fails when we call flush, the internal
> buffer won't be cleared.
> This causes some interesting issues when this happens. If you happen to call
> the same function twice (first call fails to write, but the second one
> succeeds), it will call the function on the server with the data provided in
> the first call, rather than your current call.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)