PHP :: Bug #41371 :: stream_set_blocking bug with sockets
| Bug #41371 | stream_set_blocking bug with sockets | ||||
|---|---|---|---|---|---|
| Submitted: | 2007-05-12 00:49 UTC | Modified: | 2007-07-17 13:29 UTC | ||
| From: | six at aegis-corp dot org | Assigned: | |||
| Status: | Closed | Package: | Streams related | ||
| PHP Version: | 5.2.2 | OS: | Linux 2.6 | ||
| Private report: | No | CVE-ID: | None | ||
[2007-05-12 00:49 UTC] six at aegis-corp dot org
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]
Patches
Pull Requests
History
AllCommentsChangesGit/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