https://bugs.openldap.org/show_bug.cgi?id=8047
--- Comment #6 from Allen Zhang allen.zhang@audiocodes.com --- HI what we see is, we get stuck at connect() below 120 seconds. if opt_tv is set, the connect will work in non-block mode and return immediately. later in ldap_int_poll(), the network timeout will take effect.
what do you think?
static int ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr *sin, ber_socklen_t addrlen, int async) { int rc, err; struct timeval tv, *opt_tv = NULL;
#ifdef LDAP_CONNECTIONLESS /* We could do a connect() but that would interfere with * attempts to poll a broadcast address */ if (LDAP_IS_UDP(ld)) { if (ld->ld_options.ldo_peer)
ldap_memfree(ld->ld_options.ldo_peer); ld->ld_options.ldo_peer=ldap_memcalloc(1, sizeof(struct sockaddr_storage)); AC_MEMCPY(ld->ld_options.ldo_peer,sin,addrlen); return ( 0 ); } #endif if ( ld->ld_options.ldo_tm_net.tv_sec >= 0 ) { tv = ld->ld_options.ldo_tm_net; opt_tv = &tv; }
osip_debug(ld, "ldap_pvt_connect: fd: %d tm: %ld async: %d\n", s, opt_tv ? tv.tv_sec : -1L, async);
if ( opt_tv && ldap_pvt_ndelay_on(ld, s) == -1 ) return ( -1 );
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 ( !async && 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 ));
if ( err != EINPROGRESS && err != EWOULDBLOCK ) { return ( -1 ); }
if ( async ) { /* caller will call ldap_int_poll() as appropriate? */ return ( -2 ); }
rc = ldap_int_poll( ld, s, opt_tv, 1 );
osip_debug(ld, "ldap_pvt_connect: %d\n", rc, 0, 0);
return rc; }