ID: 13566
Updated by: mfischer
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Assigned
Bug Type: Sockets related
Operating System: linux kernel 2.4.2
PHP Version: 4.0CVS-2001-10-05
Old Assigned To: 
Assigned To: mfischer
New Comment:

I don't promise to fix this myself but assigned it so I don't forget about this ...

Assigned to me.

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

[2001-10-05 14:38:40] [EMAIL PROTECTED]


I've been working with the sockets extension for PHP 
4.0.8-dev now for the past few days and I've noticed what 
must be a bug in socket_select(). 

Basically, socket_select() takes two parameters for 
timeout values in place of the single timeval struct that 
the standard select() function takes. With the standard 
select(), using a NULL instead of a timeout struct causes 
select() to block indefinitely. The socket_select() 
function in PHP doesn't have this capability, as calling 
socket_select() with NULL in both sec and usec end up in 
the timeval struct both as 0, setting the blocking timeout 
on the system select() call in turn to 0.

A quick fix: if sec and usec are both less than 0, pass 
NULL to the system select() call instead of a timeval 
struct with 0s for tv_sec and tv_usec. This will cause the 
desired effect of having socket_select() block 
indefinitely, as in system select() function.

Unfortunately, at the same time, this creates an 
incompatibility between socket_select() and system 
select(), since socket_select() will no longer produce the 
same results as calling select() with tv_sec = -1 and 
tv_usec = -1, but I don't think that's much of a problem.

I won't bother posting a patch because this will take all 
of 3 seconds to do. Here's my suggestion:

RETURN_LONG(select(max_fd+1, rfds ? &(rfds->set) : NULL,
                wfds ? &(wfds->set) : NULL,
                xfds ? &(xfds->set) : NULL,
                ((Z_LVAL_PP(arg4) < 0 && Z_LVAL_PP(arg5) < 
0) ? NULL : &tv)));


I was raking my brain trying to figure out why I couldn't 
do jack with socket_select(), and this seems to fix it.

Comments? Is it do-able?

J


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



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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to