]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/os-ip.c
Merge remote-tracking branch 'origin/mdb.master'
[openldap] / libraries / libldap / os-ip.c
index 25439cb5463b6252d0e04f067f06aee99dc95014..90b92dfe63d546f9a2a1c456681f9c0b55cef3be 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2012 The OpenLDAP Foundation.
+ * Copyright 1998-2013 The OpenLDAP Foundation.
  * Portions Copyright 1999 Lars Uffmann.
  * All rights reserved.
  *
@@ -422,8 +422,8 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
        if (LDAP_IS_UDP(ld)) {
                if (ld->ld_options.ldo_peer)
                        ldap_memfree(ld->ld_options.ldo_peer);
-               ld->ld_options.ldo_peer=ldap_memalloc(sizeof(struct sockaddr));
-               AC_MEMCPY(ld->ld_options.ldo_peer,sin,sizeof(struct sockaddr));
+               ld->ld_options.ldo_peer=ldap_memcalloc(1, sizeof(struct sockaddr_storage));
+               AC_MEMCPY(ld->ld_options.ldo_peer,sin,addrlen);
                return ( 0 );
        }
 #endif
@@ -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 );
        }