[Bug 9425] Select behavior different on Wine

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Feb 9 10:04:15 CST 2012


--- Comment #30 from Bruno Jesus <00cpxxx at gmail.com> 2012-02-09 10:04:15 CST ---
(In reply to comment #28)
> 1. POLLHUP can happen always without subscribing it.
> Since a file descriptor can (and usually will) be listed twice in our pollfd
> array it's undefined which particular pollfd struct will receive a POLLHUP. I
> saw any thinkable cases happen. It's only luck if a POLLHUP will finally make
> it into exceptfds.

Yes, it can happen and it's quite natural sometimes. For example a broken
connection is detected when select() sets the READFD and when you try to recv()
on that fd you will receive 0 meaning the connection was half-closed, wine's
current implementation lets that happen. poll() should behave the same in all
systems (posix compliance) but it's well know it does not =)

> 2. IMO it's questionable whether we should always put POLLHUP into exceptfds at
> all.

I've been thinking about this but only tests can prove this and it will
probably vary in the different windows versions.

> 3. Since we ignore some events (so possibly all events) we must poll again to
> really timeout instead of returning 0 without timeouting.

Usually wine coding strategy is to implement things required for real life
applications to run. There are plenty network applications running really well
in wine currently, I think the best example is uTorrent because it uses
hundreds of sockets sending/receiving data and it works fine. If you find a
real application that depends on this I think the best thing to do is open a
new bug report for it, this bug is just to generic =)

> 4. POLLPRI (OOB data) is completely ignored currently.

POLLPRI is not needed there currently, usually the strategy is to use the
OOBINLINE check and then recv() with MSG_OOB. The wine server already takes
care of some POLLPRI stuff as seen in
select() does not return weather there is or not priority data. A real life app
example is putty which works in wine currently using the telnet protocol. Maybe
you say we should test (POLLIN | POLLPRI) in poll to return the readfds? I
don't have objections if that's the case.

> 5. What about POLLERR and POLLNVAL? Can't they happen because of our checks
> before calling poll?

Yeah, I think POLLNVAL will never happen. And POLLERR is also not required
because the current conditions for read/except will allow setting the fd in
this case.

> To fix 1. we need would need a real mapping fd -> "select fds" rather than just
> mapping array positions. If we had this then we also could more cleanly sort
> the events into the right "select fds" when we think about 2-5.

I don't understand what's wrong with the current implementation =)

To convert the write fd errors in exceptions you could use a fd_set to insert
the writefd errors and then in the exceptfs For you could check this fd_set
together with the curren check.

Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.

More information about the wine-bugs mailing list