ID: 32979 User updated by: mjpph at stardust dot fi Reported By: mjpph at stardust dot fi Status: Open Bug Type: Network related Operating System: Linux (Fedora Core 3) PHP Version: 5CVS-2005-05-08 (dev) Assigned To: wez New Comment:
It's too bad that the openssl screws up the stream_select or stream_socket_client in some weird way as I intended to use stream_socket_enable_crypto() with the stream_socket_client() and it's dependant of openssl. Previous Comments: ------------------------------------------------------------------------ [2005-05-27 21:52:35] mjpph at stardust dot fi The strangest thing.. I had time to do some test compiles with the 200505260030 snapshot and I got some working. I took my usual parameters off from configure one by one, after I removed --with-openssl the script started suddenly working. Then I did test compile with ./configure --with-openssl and without any parameters. The one --with-openssl failed the script and the one without it worked just fine. It seems that the openssl support does some havoc which causes the failures. I did proper make clean / make distclean between the compiles and doublechecked the results. Linux is a Fedora Core 3, standard install with development support enabled. The test script is as follows, the host machine has sendmail running as a test service. <? $c = stream_socket_client("tcp://127.0.0.1:25"); while (1) { $streams = array($c); if (stream_select($streams, $write=NULL, $except=NULL, 5, 0)) die("Select OK\n"); } ?> Strace from the working PHP (without any configure parameters): read(3, "<?\n$c = stream_socket_client(\"tc"..., 8192) = 221 read(3, "", 4096) = 0 read(3, "", 8192) = 0 close(3) = 0 munmap(0x2a97b2c000, 4096) = 0 socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3 close(3) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR|O_LARGEFILE) fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 connect(3, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress) poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP, revents=POLLOUT}], 1, 60000) = 1 getsockopt(3, SOL_SOCKET, SO_ERROR, "\0\0\0\0", [12884901892]) = 0 fcntl(3, F_SETFL, O_RDWR) = 0 select(4, [3], [], [], {5, 0}) = 1 (in [3], left {4, 998000}) write(1, "Select OK\n", 10) = 10 close(3) = 0 close(1) = 0 close(0) = 0 ... Strace from the non-working PHP (only --with-openssl added for configure): read(3, "<?\n$c = stream_socket_client(\"tc"..., 8192) = 221 read(3, "", 4096) = 0 read(3, "", 8192) = 0 close(3) = 0 munmap(0x2a97b2f000, 4096) = 0 socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3 close(3) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR|O_LARGEFILE) fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 connect(3, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress) poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP, revents=POLLOUT}], 1, 60000) = 1 getsockopt(3, SOL_SOCKET, SO_ERROR, "\0\0\0\0", [12884901892]) = 0 fcntl(3, F_SETFL, O_RDWR) = 0 select(4, [3], [], [], {5, 0}) = 1 (in [3], left {4, 998000}) select(4, [3], [], [], {5, 0}) = 1 (in [3], left {5, 0}) select(4, [3], [], [], {5, 0}) = 1 (in [3], left {5, 0}) .. continues until the script is killed ------------------------------------------------------------------------ [2005-05-27 16:10:58] [EMAIL PROTECTED] *please* paste the exact script you are using that produced those straces. ------------------------------------------------------------------------ [2005-05-27 15:21:54] [EMAIL PROTECTED] Whenever I see FC3-specific problems I always suspect SELinux. Although I don't see how that can affect a select() ------------------------------------------------------------------------ [2005-05-27 14:14:29] mjpph at stardust dot fi Also, I run constantly a lot more complex PHP-scripts on both FC2 and FC3 servers, on different kernels and by using normal socket and stream functions. They all function perfectly well. All this seems to point to the new stream_socket functions as stream_select works with all the other streams except the ones opened with stream_socket functions. ------------------------------------------------------------------------ [2005-05-27 14:10:52] mjpph at stardust dot fi Only change has been the service port and sometimes the IP if the actual server doesn't host it's own SMTP. I've tested the SMTP availability with telnet and by using fgets instead of stream_select. So yes, the test code fails on FC3 and works on FC2 when the actual ip:port is changed to point to an available SMTP service. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/32979 -- Edit this bug report at http://bugs.php.net/?id=32979&edit=1