|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-04-11 23:02 UTC] requinix@php.net
-Status: Open
+Status: Duplicate
[2015-04-11 23:02 UTC] requinix@php.net
[2015-04-11 23:32 UTC] nathan dot renniewaldock at gmail dot com
[2015-04-13 20:01 UTC] schmidt dot a at rogers dot com
[2015-04-14 15:35 UTC] rdlowrey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 09:00:02 2025 UTC |
Description: ------------ TLS streams are blocking and consuming 100% CPU when there's no data when set to non-blocking. Test script is using a local IRC server so I didn't have to write a server. Removing tls:// and changing the port to 6667 works as expected. Test script: --------------- <?php $context = stream_context_create(); stream_context_set_option($context, "ssl", "verify_peer", false); $fp = stream_socket_client("tls://localhost:6697", $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context) or die(); stream_set_blocking($fp, 0); while (!feof($fp)) { echo microtime(true)." Reading...\n"; $line = fgets($fp); echo microtime(true)." $line\n"; if (!$fp) { usleep(10000); } } @fclose($fp); ?> Expected result: ---------------- "Reading..." should repeat every ~10ms and CPU usage should be low Actual result: -------------- $ php test.php 1428791498.132599 Reading... 1428791498.171197 :localhost NOTICE AUTH :*** Looking up your hostname... 1428791498.171224 Reading... 1428791498.171237 :localhost NOTICE AUTH :*** Found your hostname (cached) 1428791498.171251 Reading... # At this point htop shows it using 100% CPU until the server send a blank line to check the connection hasn't broken 1428791508.17128