Bug #53592 [Opn]: stream_socket_enable_crypto() uses NONBLOCK

From: Date: Wed, 22 Dec 2010 13:59:25 +0000
Subject: Bug #53592 [Opn]: stream_socket_enable_crypto() uses NONBLOCK
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157247@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53592&edit=1 ID: 53592 User updated by: jerry dot wilborn at paetec dot com Reported by: jerry dot wilborn at paetec dot com -Summary: stream_socket_client uses NONBLOCK +Summary: stream_socket_enable_crypto() uses NONBLOCK Status: Open Type: Bug Package: Sockets related Operating System: CentOS 4.4 PHP Version: 5.3.4 Block user comment: N Private report: N New Comment: Fix summary. Previous Comments: ------------------------------------------------------------------------ [2010-12-22 04:06:38] jerry dot wilborn at paetec dot com 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 this bug report at http://bugs.php.net/bug.php?id=53592&edit=1

« previous php.bugs (#157247) next »