Hi Manuel,
if I open a TCP connection with connection timeout,
(make-client-socket host port :timeout 500000)
and the host can be resolved but blocks the given port (i.e. immediate
connection error in nonblocking mode),
then I will always get errors like this from the current (4.2c) Bigloo
implementation with C backend:
Operation now in progress (115) -- 127.0.0.1:1234
This is true regardless of the actual cause (EAFNOSUPPORT, EAGAIN,
EALREADY, EBADF, ECONNREFUSED, EFAULT, EISCONN, ENETUNREACH, ETIMEDOUT).
See below for a patch that corrects this problem (and related ones).
Regards,
Robert
--- runtime/Clib/csocket.c~ 2015-12-21 13:31:11.000000000 +0100
+++ runtime/Clib/csocket.c 2016-03-22 12:31:17.804560646 +0100
@@ -1416,7 +1416,6 @@
if( errno == EINPROGRESS ) {
fd_set writefds;
struct timeval timeout;
- int _errno;
FD_ZERO( &writefds );
FD_SET( s, &writefds );
@@ -1431,7 +1430,6 @@
close( s );
socket_timeout_error( hostname, port );
} else {
- _errno = errno;
if( err < 0 ) {
/* we have experienced a failure so we */
/* invalidate the host name entry */
@@ -1443,11 +1441,20 @@
int len = sizeof( int );
int r = getsockopt( s, SOL_SOCKET, SO_ERROR, (void *)&err, (socklen_t *)&len );
- if( (r < 0) || (err != 0) ) {
+ if( r < 0 ) {
/* we have experienced a failure so we */
/* invalidate the host name entry */
+ invalidate_hostbyname( hostname );
+
+ close( s );
+ tcp_client_socket_error( hostname, port, "getsockopt failed", errno );
+ } else if( err != 0 ) {
+ /* we have experienced a failure so we */
+ /* invalidate the host name entry */
+ invalidate_hostbyname( hostname );
+
close( s );
- tcp_client_socket_error( hostname, port, "getsockopt", _errno );
+ tcp_client_socket_error( hostname, port, "connect failed", err );
}
}
}