From: vnegrier at optilian dot com
Operating system: linux
PHP version: 5.3.1
PHP Bug Type: Streams related
Bug description: stream_set_write_buffer() has no effect on socket streams
Description:
------------
Socket streams do not implement the PHP_STREAM_OPTION_WRITE_BUFFER call,
and the stream chunk size is always fixed at 8192 bytes.
This is not a problem with SOCK_STREAM type sockets, but with SOCK_DGRAM
is breaks the datagrams if they are more than 8192 bytes (which is IMHO a
bug).
Here is a patch against 5.3.1 to add support for stream_set_write_buffer()
with socket streams:
--- main/streams/xp_socket.c.orig 2010-01-17 19:56:39.000000000
+0100
+++ main/streams/xp_socket.c 2010-01-17 19:59:34.000000000 +0100
@@ -266,6 +266,7 @@
int oldmode, flags;
php_netstream_data_t *sock =
(php_netstream_data_t*)stream->abstract;
php_stream_xport_param *xparam;
+ size_t size;
switch(option) {
case PHP_STREAM_OPTION_CHECK_LIVENESS:
@@ -400,6 +401,14 @@
return
PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+ case PHP_STREAM_OPTION_WRITE_BUFFER:
+ if (ptrparam)
+ size = *(size_t *)ptrparam;
+ else
+ size = PHP_SOCK_CHUNK_SIZE;
+ php_stream_set_chunk_size(stream, size);
+ return PHP_STREAM_OPTION_RETURN_OK;
+
default:
return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
--
Edit bug report at http://bugs.php.net/?id=50787&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50787&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50787&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50787&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50787&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50787&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50787&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50787&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50787&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50787&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50787&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50787&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50787&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50787&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50787&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50787&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50787&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50787&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50787&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50787&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50787&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50787&r=mysqlcfg