select() on sockets considered harmful, use poll() instead?

Damjan Jovanovic damjan.jov at gmail.com
Mon Nov 6 00:42:45 CST 2006


On 11/1/06, Alexandre Julliard <julliard at winehq.org> wrote:
> Juan Lang <juan_lang at yahoo.com> writes:
>
> > Dan wrote:
> >> The suspect statements are:
> >>
> >> dinput/joystick_linux.c:      if (1>select(This->joyfd+1,&readfds,...
> >> dinput/joystick_linuxinput.c: if (1>select(This->joyfd+1,&readfds,...
> >> icmp/icmp_main.c:             while ((res=select(icp->sid+1,&fdr,...
> >> netapi32/nbt.c:               r = select(fd + 1, &fds, ...
> >> wininet/internet.c:           if (select(nSocket+1,&infd,...
> >> wininet/netconnection.c:      if
> > (select(connection->socketFD+1,&infd,...
> >
> > These, at least, are safe:  they poll on a single file descriptor.
>
> A single file descriptor can still be above 1024. select() should
> really be avoided.

Well I'm not a new wine hacker, but I was bored this weekend, so:

> dinput/joystick_linux.c:      if (1>select(This->joyfd+1,&readfds,...
patch sent

> dinput/joystick_linuxinput.c: if (1>select(This->joyfd+1,&readfds,...
patch sent

> icmp/icmp_main.c:             while ((res=select(icp->sid+1,&fdr,...
patch sent

> netapi32/nbt.c:               r = select(fd + 1, &fds, ...
This is a winsock select, which is okay: the winsock fd_set is just an
array, meaning the single fd can be > 1024. Alexandre's WS_select patch
makes WS_select use poll internally, so this will always work. Besides,
there's no real alternative to select in winsock ;-).

So changing select->poll only needs to be done for the Linux select.

> wininet/internet.c:           if (select(nSocket+1,&infd,...
patch sent

> wininet/netconnection.c:      if (select(connection->socketFD+1,&infd,...
patch sent

> ws2_32/socket.c:              if( (highfd = select(highfd + 1, p_read,
> p_write, p_except, timeoutaddr))
Alexandre's WS_select patch fixes this

cscope did not find any more select() calls in wine 0.9.24 dlls, except
a few used for timing and yielding execution. Should we change those too
for consistency?

Damjan



More information about the wine-devel mailing list