]> git.sur5r.net Git - openldap/commitdiff
ITS#7476 Prevent EINTR from stopping otherwise successful connect
authorDavid Bender <codehero@yahoo.com>
Wed, 19 Dec 2012 07:34:30 +0000 (02:34 -0500)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 9 Jan 2013 20:51:45 +0000 (12:51 -0800)
libraries/libldap/os-ip.c

index 25439cb5463b6252d0e04f067f06aee99dc95014..fbb4d66ee60374d120d07c63ed97293bc58034f5 100644 (file)
@@ -438,13 +438,21 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
        if ( opt_tv && ldap_pvt_ndelay_on(ld, s) == -1 )
                return ( -1 );
 
-       if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) {
-               if ( opt_tv && ldap_pvt_ndelay_off(ld, s) == -1 )
-                       return ( -1 );
-               return ( 0 );
-       }
+       do{
+               osip_debug(ld, "attempting to connect: \n", 0, 0, 0);
+               if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR ) {
+                       osip_debug(ld, "connect success\n", 0, 0, 0);
+
+                       if ( opt_tv && ldap_pvt_ndelay_off(ld, s) == -1 )
+                               return ( -1 );
+                       return ( 0 );
+               }
+               err = sock_errno();
+               osip_debug(ld, "connect errno: %d\n", err, 0, 0);
+
+       } while(err == EINTR &&
+               LDAP_BOOL_GET( &ld->ld_options, LDAP_BOOL_RESTART ));
 
-       err = sock_errno();
        if ( err != EINPROGRESS && err != EWOULDBLOCK ) {
                return ( -1 );
        }