Skip to content

Commit 63f7bfc

Browse files
committed
Report successfully written bytes even on later error
1 parent 5151d3e commit 63f7bfc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

main/streams/streams.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,12 +1094,13 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz
10941094
towrite = stream->chunk_size;
10951095

10961096
justwrote = stream->ops->write(stream, buf, towrite);
1097-
if (justwrote < 0) {
1098-
return justwrote;
1099-
}
1100-
1101-
if (justwrote == 0) {
1102-
break;
1097+
if (justwrote <= 0) {
1098+
/* If we already successfully wrote some bytes and a write error occurred
1099+
* later, report the successfully written bytes. */
1100+
if (didwrite == 0) {
1101+
return justwrote;
1102+
}
1103+
return didwrite;
11031104
}
11041105

11051106
buf += justwrote;

0 commit comments

Comments
 (0)