mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
Fix retrywrapper when the wrapped stream fails to write or read completely
This commit is contained in:
parent
9ca4027464
commit
d3620e8dc4
2 changed files with 44 additions and 4 deletions
|
|
@ -44,7 +44,7 @@ class RetryWrapper extends Wrapper {
|
|||
$result = parent::stream_read($count);
|
||||
|
||||
$bytesReceived = strlen($result);
|
||||
while ($bytesReceived < $count && !$this->stream_eof()) {
|
||||
while (strlen($result) > 0 && $bytesReceived < $count && !$this->stream_eof()) {
|
||||
$result .= parent::stream_read($count - $bytesReceived);
|
||||
$bytesReceived = strlen($result);
|
||||
}
|
||||
|
|
@ -54,11 +54,13 @@ class RetryWrapper extends Wrapper {
|
|||
|
||||
public function stream_write($data) {
|
||||
$bytesToSend = strlen($data);
|
||||
$result = parent::stream_write($data);
|
||||
$bytesWritten = parent::stream_write($data);
|
||||
$result = $bytesWritten;
|
||||
|
||||
while ($result < $bytesToSend && !$this->stream_eof()) {
|
||||
while ($bytesWritten > 0 && $result < $bytesToSend && !$this->stream_eof()) {
|
||||
$dataLeft = substr($data, $result);
|
||||
$result += parent::stream_write($dataLeft);
|
||||
$bytesWritten = parent::stream_write($dataLeft);
|
||||
$result += $bytesWritten;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue