#44864 [Opn->Fbk]: STREAM_CLIENT_ASYNC_CONNECT does does not work

From: Date: Fri, 02 May 2008 23:15:51 +0000
Subject: #44864 [Opn->Fbk]: STREAM_CLIENT_ASYNC_CONNECT does does not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124683@lists.php.net to get a copy of this message
 ID:               44864
 Updated by:       jani@php.net
 Reported By:      fhoenig at kargo dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Streams related
 Operating System: FreeBSD 7.0 / AMD64
 PHP Version:      5.2.5
 Assigned To:      fb-req-jani


Previous Comments:
------------------------------------------------------------------------

[2008-04-30 16:43:42] fhoenig at kargo dot com

The select issue seems indeed fixed in the 5.2-latest. However, since
the sockets extension was built as a SO, I still need to try whether
it's related to that.

------------------------------------------------------------------------

[2008-04-30 16:16:53] fhoenig at kargo dot com

Yes and it does even more unpredictable things. It seems like I get the
bytes I write to the socket back on the reads... I need to look more
into it though. I just found that the problem does not exist on freebsd
7.0/i386. So it has to do with 64-bit land.

------------------------------------------------------------------------

[2008-04-30 08:48:16] jani@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi



------------------------------------------------------------------------

[2008-04-29 23:56:48] fhoenig at kargo dot com

Actually I cased down the problem a bit further.

socket_select under these conditions is not waiting even is the tv_sec
is set to NULL (in which case it should wait infinitely)

instead of sleep, put: $num_changed_streams = stream_select($rfd, $wfd,
$efd, NULL);

something is wrong with sockets here...

------------------------------------------------------------------------

[2008-04-29 21:25:52] fhoenig at kargo dot com

Description:
------------
The below code only works with sleeping in between
stream_socket_client() and the first IO on the socket. No error though.
Works on FreeBSD 6.2 and linux as well as OSX. Just not on Freebsd 7.0.
was installed through ports with default options.

What changed in freebsd 7 that could cause that? Fix through sysctl
option maybe?

Reproduce code:
---------------
$fp = stream_socket_client("tcp://www.google.com:80", $errno, $errstr,
0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);

//sleep(1); <=== works only with sleep uncommented.

if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    fwrite($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept:
*/*\r\n\r\n");
    while (!feof($fp)) {

        echo fgets($fp, 1024);
    }
    fclose($fp);
}



Expected result:
----------------
The html output from www.google.com/


Actual result:
--------------
Locks up after fwrite and never reads anything from the socket. No
error. 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44864&edit=1



Thread (6 messages)

« previous php.bugs (#124683) next »