ID:               46917
 Updated by:       fel...@php.net
 Reported By:      jost_boekemeier at users dot sf dot net
 Status:           Open
 Bug Type:         Streams related
 Operating System: *
 PHP Version:      5.2.8
 New Comment:

I changed the EGAIN to EWOULDBLOCK in the checking.

http://news.php.net/php.cvs/55434


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

[2009-01-06 19:51:15] jost_boekemeier at users dot sf dot net

The windows equivalent to EAGAIN is EWOULDBLOCK or WSAEWOULDBLOCK. 

Could it be that EAGAIN is 0 on windows?


Unfortunately I don't have the time and resources to debug this at the
moment.

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

[2009-01-06 19:15:52] jost_boekemeier at users dot sf dot net

Well, the initialization is okay now.

However, the code still doesn't work on windows. Which means that
there's another bug.

The php_socket_errno() != EAGAIN looks  suspicious.

"Depending on whether your socket is blocking or non-blocking, you 
either get FD_CLOSE notification, or recv() returns 0 (graceful 
disconnection), or recv() returns WSAECONNRESET error."

I don' see how the current code handles these three cases properly.

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

[2009-01-06 17:41:49] fel...@php.net

Currently the WSASetLastError(0); already exists for Windows in the
code.

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

[2009-01-06 16:15:20] jost_boekemeier at users dot sf dot net

Hi,

the code is okay for Linux, but on Windows it fails constantly.

+       WSASetLastError(0);
        n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv :
NULL);

IMHO this means that select always returns EAGAIN on windows, so that
the following test cannot detect a broken connection. As I've said, I am
not sure what the EAGAIN test should do, anyway.


To reproduce this: 

1) start a simple socket server on windows >= xp, call pfsockopen() and
let the PHP instance return to the HTTP server's pool w/o closing the
connection

2) kill the socket server and start it again

3) pull the PHP instance from the pool and call pfsockopen() again.
pfsockopen() will use the broken connection until you kill the pool
(i.e.: restart apache or IIS).


Regards,
Jost Bökemeier

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

[2009-01-03 17:00:01] fel...@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I added the Win part minutes ago:
-#ifndef PHP_WIN32
+/* Reseting/initializing */
+#ifdef PHP_WIN32
+       WSASetLastError(0);
+#else
        errno = 0;
 #endif

Ok, then, closed. Thanks.

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

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/46917

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

Reply via email to