Bug #53592 [NEW]: stream_socket_client uses NONBLOCK

From: Date: Wed, 22 Dec 2010 03:06:39 +0000
Subject: Bug #53592 [NEW]: stream_socket_client uses NONBLOCK
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157207@lists.php.net to get a copy of this message
From: Operating system: CentOS 4.4 PHP version: 5.3.4 Package: Sockets related Bug Type: Bug Bug description:stream_socket_client uses NONBLOCK Description: ------------ stream_socket_enable_crypto() changes the stream to NONBLOCK before it attempts the encryption. I'm assuming this is so the timeout can be tracked, but for connections where the handshake doesn't work the process simply chews up CPU while the read() repeatedly EAGAIN fails and gettimeofday() is called. Test script: --------------- $stream = stream_socket_client("tcp://72.14.204.147:80", $errno, $errstr, 5); stream_socket_enable_crypto($stream, TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT); Expected result: ---------------- For the socket to stay in blocked mode. Actual result: -------------- socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("72.14.204.147")}, 16) = -1 EINPROGRESS (Operation now in progress) poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP, revents=POLLOUT}], 1, 1000) = 1 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 fcntl64(3, F_SETFL, O_RDWR) = 0 select(4, [3], [3], [], {5, 0}) = 1 (out [3], left {5, 0}) fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 -- Edit bug report at http://bugs.php.net/bug.php?id=53592&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53592&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53592&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53592&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53592&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53592&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53592&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53592&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53592&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53592&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53592&r=support Expected behavior: http://bugs.php.net/fix.php?id=53592&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53592&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53592&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53592&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53592&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53592&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53592&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53592&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53592&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53592&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53592&r=mysqlcfg

« previous php.bugs (#157207) next »