Yoann Vandoorselaere wrote:
> Le lundi 15 septembre 2008 à 21:21 +0200, Paolo Bonzini a écrit :
>>> The poll-tests module that is now available in the GnuLib repository
>>> currently fail on OpenBSD:
>>>
>>> Unconnected socket test... failed (huh, connect succeeded?)
>>> Connected sockets test... failed (huh, connect succeeded?)
>> Uhm, this means O_NONBLOCK sockets do not work there?
> 
> To me, this rather look like a bug in connect_to_socket(), which assume
> that connecting a non blocking socket should never succeed on first try.
> Where does this assumption come from? 

>From the fact that the socket is listening, but not accepting yet.  I
added the check mostly to see how Winsock behaved, but yes, it can be
relaxed for OpenBSD.  I pushed the following patch:

diff --git a/tests/test-poll.c b/tests/test-poll.c
index e8beb55..b65b7b3 100644
--- a/tests/test-poll.c
+++ b/tests/test-poll.c
@@ -139,16 +139,12 @@ connect_to_socket (int blocking)
 #endif
     }

-  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
+  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
+      && (blocking || errno != EINPROGRESS))
     {
-      if (errno != EINPROGRESS)
-       {
-         perror ("connect");
-         exit (77);
-       }
+      perror ("connect");
+      exit (77);
     }
-  else if (!blocking)
-    failed ("huh, connect succeeded?");

   return s;
 }

I suppose you don't have similar build bots for Windows, do you?

Paolo


Reply via email to