#45808 [NEW]: stream_socket_enable_crypto() blocks and eats CPU
From: six at aegis-corp dot org
Operating system: Linux 2.6
PHP version: 5.3.0alpha1
PHP Bug Type: Streams related
Bug description: stream_socket_enable_crypto() blocks and eats CPU
Description:
------------
The documentation says about stream_socket_enable_crypto :
Returns TRUE on success, FALSE if negotiation has failed or 0 if there
isn't enough data and you should try again (only for non-blocking sockets).
In practice, if you feed a non blocking server socket to it, it will block
and consume lots of CPU until the SSL/TLS handshake is done or the client
connection is dropped.
Reproduce code:
---------------
<?php
$s = stream_socket_server("tcp://127.0.0.1:8888");
$c = stream_socket_accept($s);
stream_set_blocking($c, false);
$ret = stream_socket_enable_crypto($c, true,
STREAM_CRYPTO_METHOD_TLS_SERVER);
var_dump($ret);
?>
then just "telnet localhost 8888" from another term
Expected result:
----------------
script should print "int(0)" and exit
Actual result:
--------------
script blocks at the stream_socket_enable_crypto() call and is stuck in a
CPU consuming loop until the client connection is either handshaked or
dropped.
--
Edit bug report at http://bugs.php.net/?id=45808&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45808&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45808&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45808&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45808&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45808&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45808&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45808&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45808&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45808&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45808&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45808&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45808&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45808&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45808&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45808&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45808&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45808&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45808&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45808&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45808&r=mysqlcfg
Thread (13 messages)
- six at aegis-corp dot org
- jani@php.net#45808 [Opn->Fbk]: stream_socket_enable_crypto() blocks and eats CPU
- six at aegis-corp dot org#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- six at aegis-corp dot org#45808 [NoF->Opn]: stream_socket_enable_crypto() blocks and eats CPU
- nasam at mailvault dot com#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- singularity_control at rcpt dot at#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- lsmith@php.net#45808 [Opn->Asn]: stream_socket_enable_crypto() blocks and eats CPU
- xl269 at cam dot ac dot uk#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- garretts@php.net#45808 [Asn]: stream_socket_enable_crypto() blocks and eats CPU
- vincent at optilian dot com#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- vincent at optilian dot com#45808 [Com]: stream_socket_enable_crypto() blocks and eats CPU
- felipe@php.netBug #45808 [Asn]: [PATCH] stream_socket_enable_crypto() blocks and eats CPU
- pajoye@php.netBug #45808 [Asn->Csd]: [PATCH] stream_socket_enable_crypto() blocks and eats CPU