X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libraries%2Flibldap%2Fos-ip.c;h=b31e05dc9be58227710e18ed694af6b6c2e14427;hb=9121a473dece0cabeac334a373b765508a47c1fc;hp=286425691650f865f630c5fd0b9e0c63571e7051;hpb=d377f353b7053bbe17afa8d97e2eacf810ec3086;p=openldap diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 2864256916..b31e05dc9b 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2012 The OpenLDAP Foundation. + * Copyright 1998-2013 The OpenLDAP Foundation. * Portions Copyright 1999 Lars Uffmann. * All rights reserved. * @@ -276,7 +276,8 @@ int ldap_int_poll( LDAP *ld, ber_socket_t s, - struct timeval *tvp ) + struct timeval *tvp, + int wr ) { int rc; @@ -288,9 +289,10 @@ ldap_int_poll( { struct pollfd fd; int timeout = INFTIM; + short event = wr ? POLL_WRITE : POLL_READ; fd.fd = s; - fd.events = POLL_WRITE; + fd.events = event; if ( tvp != NULL ) { timeout = TV2MILLISEC( tvp ); @@ -310,7 +312,7 @@ ldap_int_poll( return -2; } - if ( fd.revents & POLL_WRITE ) { + if ( fd.revents & event ) { if ( ldap_pvt_is_socket_ready( ld, s ) == -1 ) { return -1; } @@ -436,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 ); } @@ -452,7 +462,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, return ( -2 ); } - rc = ldap_int_poll( ld, s, opt_tv ); + rc = ldap_int_poll( ld, s, opt_tv, 1 ); osip_debug(ld, "ldap_pvt_connect: %d\n", rc, 0, 0);