|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-06-26 23:59 UTC] boen dot robot at gmail dot com
[2014-01-02 13:28 UTC] ab@php.net
-Status: Open
+Status: Feedback
[2014-01-02 13:28 UTC] ab@php.net
[2014-01-02 13:53 UTC] ab@php.net
-Assigned To:
+Assigned To: ab
[2014-04-03 14:27 UTC] heruan at aldu dot net
[2014-04-03 14:49 UTC] boen dot robot at gmail dot com
[2014-08-23 01:04 UTC] daverandom@php.net
[2014-08-27 15:51 UTC] daverandom@php.net
-Status: Feedback
+Status: Closed
[2014-08-27 15:51 UTC] daverandom@php.net
[2014-12-22 14:00 UTC] boen dot robot at gmail dot com
[2015-02-09 13:38 UTC] sjaillet at gmail dot com
[2015-02-09 19:28 UTC] requinix@php.net
-Status: Closed
+Status: Re-Opened
-Assigned To: ab
+Assigned To:
[2015-02-09 19:28 UTC] requinix@php.net
[2015-03-05 23:53 UTC] rdlowrey@php.net
-Assigned To:
+Assigned To: rdlowrey
[2015-03-06 01:02 UTC] rdlowrey@php.net
[2015-03-06 01:15 UTC] boen dot robot at gmail dot com
[2015-03-06 17:35 UTC] rdlowrey@php.net
[2015-03-08 06:56 UTC] boen dot robot at gmail dot com
[2015-03-08 07:10 UTC] rdlowrey@php.net
-Status: Re-Opened
+Status: Closed
[2015-03-11 12:35 UTC] arjen at react dot com
[2015-03-11 14:13 UTC] rdlowrey@php.net
-Status: Closed
+Status: Re-Opened
[2015-03-11 14:13 UTC] rdlowrey@php.net
[2015-03-11 15:51 UTC] rdlowrey@php.net
-Status: Re-Opened
+Status: Closed
[2015-03-11 15:51 UTC] rdlowrey@php.net
[2015-05-15 08:52 UTC] edhelas at movim dot eu
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
Description: ------------ When stream_select() is called on a socket stream created by stream_socket_client() which uses TLS (with ADH), it seems to report too early. That is, it would report that that the stream can be read, but then when you try to read it, it would block, and potentially fail. The exact same code, if called without encryption, would always work just fine. Also, if right before receiving, the script is made to sleep for a while (in my case, about 100 miliseconds did the trick), the script is also fine. Sample code is hard to give, as this occurs only when the server sends large enough data at once over the encrypted connection, and I seem to be unable to mock a TLS+ADH server with PHP (which is a separate issue that, at this point, could be just me being stupid). I *think* the issue might be that stream_select() reports on the underlying socket (i.e. the data being received before decryption), rather than the *readable data* from the socket, while fread() blocks until there's at least 1 byte of readable data to be read. But this shouldn't be so IMHO. Note that this occurs not just with PHP 5.5.0, but also the latest releases of 5.4.16 and 5.3.26, and at least as early as 5.3.8. Test script: --------------- NOTE: This script is an "approximation" so to speak, in that it demonstrates the exact settings for the client where this occurs, but due to the lack of a mock server, it's not confirmed to always fail. <?php $socket = stream_socket_client( 'tls://example.com:8729', $errno, $errstr, 2, STREAM_CLIENT_CONNECT, stream_context_create( array('ssl' => array('ciphers' => 'ADH')) ) ); fwrite($socket, chr(6) . '/login' . chr(0)); $r = array($socket); $w = $e = null; if (1 === stream_select($r, $w, $e, null)) { echo fread($socket, 1); } else { echo 'stream_select() returned with errors'; } Expected result: ---------------- stream_select() should only report the encrypted socket as readable if there's at least 1 byte of readable data in the buffer that can be read by fread(). Actual result: -------------- stream_select() reports the encrypted socket as readable, but fread() blocks, and may even time out.