|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesset_read_buffer_patch_v2 (last revision 2010-05-18 19:40 UTC by tjerk dot meesters at gmail dot com)php_stream_set_option_read_buffer (last revision 2010-05-18 18:00 UTC by tjerk dot meesters at gmail dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-05-18 21:39 UTC] pajoye@php.net
[2010-05-18 21:40 UTC] pajoye@php.net
-Status: Open
+Status: Closed
-Operating System: Linux
+Operating System: *
-Assigned To:
+Assigned To: pajoye
[2010-05-18 21:40 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 02:00:02 2025 UTC |
Description: ------------ Recently, the stream_set_read_buffer() was introduced; it's signature suggests that a buffer size can be set. However, when passing any non-zero value, the stream becomes unbuffered. This is because of a missing check inside _php_stream_set_option(): if (value == PHP_STREAM_BUFFER_NONE) { stream->flags |= PHP_STREAM_FLAG_NO_BUFFER; } else { stream->flags ^= PHP_STREAM_FLAG_NO_BUFFER; } Test script: --------------- <?php $f = fopen('/dev/urandom', 'rb'); // setting read buffer to 1024 stream_set_read_buffer($f, 1024); // reading the first 10 bytes $s = fread($f, 10); fclose($f); /* ========= STRACE OUTPUT ========= open("/dev/urandom", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0 lseek(3, 0, SEEK_CUR) = 0 read(3, "\3X\264\rQ\277\273\367\347Z", 10) = 10 close(3) = 0 */ ?> Expected result: ---------------- Either the read() loads 1024 bytes, which would be ideal, or it should still load the default buffer size (8192 bytes). The attached patch addresses the latter behaviour.