#45808 [NEW]: stream_socket_enable_crypto() blocks and eats CPU
[email protected] ("six at aegis-corp dot org")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
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