Skip to content

Commit 0083726

Browse files
committed
io: remove wrong pipe drain in splice
1 parent 78a9355 commit 0083726

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

main/io/php_io_copy_linux.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,8 @@ ssize_t php_io_linux_copy_generic_to_any(int src_fd, int dest_fd, size_t maxlen)
179179
ssize_t in_pipe = splice(src_fd, NULL, pipefd[1], NULL, to_copy, 0);
180180

181181
if (in_pipe < 0) {
182-
/* Error on splice in - drain pipe if anything is there, then fall back */
183-
char drain_buf[1024];
184-
ssize_t drained;
185-
while ((drained = read(pipefd[0], drain_buf, sizeof(drain_buf))) > 0) {
186-
ssize_t written = write(dest_fd, drain_buf, drained);
187-
if (written <= 0) {
188-
close(pipefd[0]);
189-
close(pipefd[1]);
190-
return total_copied > 0 ? (ssize_t) total_copied : -1;
191-
}
192-
total_copied += written;
193-
}
182+
/* Nothing was spliced into the pipe this iteration, so nothing to drain.
183+
* Close pipe and fall back to generic copy for remaining data. */
194184
close(pipefd[0]);
195185
close(pipefd[1]);
196186

0 commit comments

Comments
 (0)