|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-11-21 07:15 UTC] mfischer@php.net
[2001-11-21 10:38 UTC] jsmith at tutorbuddy dot com
[2001-11-21 10:40 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
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