server: Make sock_check_pollhup() more reliable on Solaris.

Francois Gouget fgouget at
Fri Nov 26 11:08:30 CST 2010

If given a null timeout poll() will sometimes return nothing on Solaris, thus preventing sock_check_pollhup() from figuring out what happens when a socket is closed.

For steps to reproduce this problem see bug 25301.

It looks like Solaris can delay generating the events a little bit until 
it finds a 'convenient' time, probably for performance reasons. Still, 
in my tests even with the 1ms timeout poll() runs in 0.046ms at most. So 
probably all Solaris wants is a yield of some form.

Note that in any case this code is not performace critical, the timing 
data just hints at what may be happening. If someone knows more about 
what is going on let me know.

 server/sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/server/sock.c b/server/sock.c
index 04ae748..d37a316 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -203,7 +203,8 @@ static sock_shutdown_t sock_check_pollhup(void) = POLLIN;
     pfd.revents = 0;
-    n = poll( &pfd, 1, 0 );
+    /* Solaris' poll() sometimes returns nothing if given a 0ms timeout here */
+    n = poll( &pfd, 1, 1 );
     if ( n != 1 ) goto out; /* error or timeout */
     if ( pfd.revents & POLLHUP )

More information about the wine-patches mailing list