|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-13 21:42 UTC] sniper@php.net
[2007-05-13 22:05 UTC] sniper@php.net
[2007-05-13 23:43 UTC] sniper@php.net
[2007-07-17 13:29 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ When a stream has been obtained using stream_socket_accept from a non-blocking server, php believes that it is itself non-blocking and refuses to set it non blocking after a call to stream_set_blocking. Reproduce code: --------------- <? $s = stream_socket_server("tcp://0.0.0.0:12345"); stream_set_blocking($s, false); $c = stream_socket_accept($s); // code will work if uncommented //stream_set_blocking($c, true); stream_set_blocking($c, false); ?> Expected result: ---------------- Expected result is that $c is non-blocking, which it is *not* unless the previous stream_set_blocking($c, true) is uncommented (this may reset some internal cache ?) Actual result: -------------- reproduce code strace: listen(3, 5) = 0 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP, revents=POLLIN}], 1, 60000) = 1 accept(3, {sa_family=AF_INET, sin_port=htons(58901), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 [stream_set_blocking($c, false) does nothing here] close(4) = 0 close(3) = 0 [script ends] reproduce code strace with second call uncommented : listen(3, 5) = 0 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP, revents=POLLIN}], 1, 60000) = 1 accept(3, {sa_family=AF_INET, sin_port=htons(58901), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(4, F_SETFL, O_RDWR) = 0 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 [the two stream_set_blocking calls work here] close(4) = 0 close(3) = 0 [script ends]