[#4858] Build fails on OSX Tiger 10.4 — noreply@...

Bugs item #1883, was opened at 2005-05-06 14:55

21 messages 2005/05/06
[#4862] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Yukihiro Matsumoto <matz@...> 2005/05/07

Hi,

[#4865] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Ryan Davis <ryand-ruby@...> 2005/05/07

[#4868] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — nobu.nokada@... 2005/05/07

Hi,

[#5053] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Shugo Maeda <shugo@...> 2005/05/19

Hi,

[#5056] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Mark Hubbart <discordantus@...> 2005/05/19

On 5/19/05, Shugo Maeda <shugo@ruby-lang.org> wrote:

[#4874] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...>

Hello all,

31 messages 2005/05/10
[#4879] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Pit Capitain <pit@...> 2005/05/11

Ilias Lazaridis schrieb:

[#4883] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

Pit Capitain wrote:

[#4884] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ryan Davis <ryand-ruby@...> 2005/05/12

[#4888] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

Ryan Davis wrote:

[#4889] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — ES <ruby-ml@...> 2005/05/12

[#4890] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

ES wrote:

[#4891] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Alexander Kellett <ruby-lists@...> 2005/05/12

On May 12, 2005, at 3:13 PM, Ilias Lazaridis wrote:

[#4911] Pointless argc check in Array#select — noreply@...

Patches item #1900, was opened at 2005-05-12 09:33

11 messages 2005/05/12

[#4919] - Hierarchical/Modular Directory Structure — Ilias Lazaridis <ilias@...>

The source-code structure should be simplified, lowering barriers for

20 messages 2005/05/12

Re: select() on non-sockets in eval.c

From: BG - Ben Armstrong <BArmstrong@...>
Date: 2005-05-27 13:49:50 UTC
List: ruby-core #5113
Nobu, if I understand this code correctly, I think I see a problem:

On Wednesday, May 25, 2005 6:25 AM, nobuyoshi nakada wrote:
> +    /* count socket and non-socket fds */
...
> +	    if (is_socket(i)) {
> +		if (r) FD_SET(i, (rp = &rs));
> +		if (w) FD_SET(i, (wp = &ws));
> +		if (e) FD_SET(i, (ep = &es));
> +		maxsock = i + 1;
> +		socks++;
> +	    }

So we now have socket fds in rp, wp & ep.

Later, once we have ruled out the socket-only & non-socket-only cases
which are trivial, we go on to just select against the socket fds: 

> +    ret = select(maxsock, rp, wp, ep, &z);

If an error was returned, we just ignore it and return nsocks, the # of
non-socket fds, and return the non-socket fd bits in rfd, wfd & efd.  So
far, so good.

But if select returned >= 0, then for each set bit in rp, wp & ep, we
set a bit in rfd, wfd & efd to return:

> +    for (i = 0; i < maxsock; ++i) {
> +	if (rp && FD_ISSET(i, rp)) {
> +	    FD_SET(i, rfd);
> +	    ret++;
> +	}
... etc. ...

This is where I get confused about what you intended.  Ret started as
the return value from select on the sockets, and rp, wp and ep should
already contain the ready socket fds.  Why are we adding into ret the
count of *socket* fds ready?  Shouldn't this be setting rfd, wfd and efd
to the returned rp, wp and ep, and then add in the *non-socket* bits
(and increment ret per ready non-socket fd)?  But we don't have any
variables storing just the non-socket bits, so we can't do that.

Supposing ret were zero after performing the select() on the socket fds,
as I am seeing in my tests.  Then rp, wp and ep will all have no bits
set, so ret isn't incremented any further.  The combined
socket+nonsocket ret is 0, whereas it should have been a count of all
non-socket fds (which are assumed to be ready).  My debug print
statements confirm this.

So to fix this, we want to keep track of the non-socket fds from rfd,
wfd & efd (before we called select()) and then add back in those bits
(and count them in ret) after we get a non-negative result from the real
select().

I'm going to compare this again with what is done in win32.c just to
make sure before proceeding.

Thanks,
Ben


In This Thread

Prev Next