From: Howard Chu Date: Fri, 26 Mar 2004 23:34:27 +0000 (+0000) Subject: Import ITS#2982 fix from HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_1_29~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c1560aff2c2a40de71839fab704fc0c91dc1136a;p=openldap Import ITS#2982 fix from HEAD --- diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 7f9f77ea9d..455a5a6c18 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -64,7 +64,7 @@ static int ldap_mark_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid )); static int wait4msg LDAP_P(( LDAP *ld, ber_int_t msgid, int all, struct timeval *timeout, LDAPMessage **result )); static ber_tag_t try_read1msg LDAP_P(( LDAP *ld, ber_int_t msgid, - int all, Sockbuf *sb, LDAPConn *lc, LDAPMessage **result )); + int all, Sockbuf *sb, LDAPConn **lc, LDAPMessage **result )); static ber_tag_t build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr )); static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); static LDAPMessage * chkResponseList LDAP_P(( LDAP *ld, int msgid, int all)); @@ -298,11 +298,12 @@ wait4msg( rc = (*result)->lm_msgtype; } else { - for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { + for ( lc = ld->ld_conns; lc != NULL; lc = nextlc ) { + nextlc = lc->lconn_next; if ( ber_sockbuf_ctrl( lc->lconn_sb, LBER_SB_OPT_DATA_READY, NULL ) ) { - rc = try_read1msg( ld, msgid, all, lc->lconn_sb, - lc, result ); + rc = try_read1msg( ld, msgid, all, lc->lconn_sb, + &lc, result ); break; } } @@ -352,7 +353,8 @@ wait4msg( ldap_is_read_ready( ld, lc->lconn_sb )) { rc = try_read1msg( ld, msgid, all, - lc->lconn_sb, lc, result ); + lc->lconn_sb, &lc, result ); + if ( lc == NULL ) lc = nextlc; } } } @@ -388,7 +390,7 @@ try_read1msg( ber_int_t msgid, int all, Sockbuf *sb, - LDAPConn *lc, + LDAPConn **lcp, LDAPMessage **result ) { BerElement *ber; @@ -398,6 +400,7 @@ try_read1msg( ber_len_t len; int foundit = 0; LDAPRequest *lr, *tmplr; + LDAPConn *lc; BerElement tmpber; int rc, refer_cnt, hadref, simple_request; ber_int_t lderr; @@ -411,7 +414,8 @@ try_read1msg( int v3ref; assert( ld != NULL ); - assert( lc != NULL ); + assert( lcp != NULL ); + assert( *lcp != NULL ); #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ARGS, "read1msg: msgid %d, all %d\n", msgid, all, 0 ); @@ -419,6 +423,8 @@ try_read1msg( Debug( LDAP_DEBUG_TRACE, "read1msg: msgid %d, all %d\n", msgid, all, 0 ); #endif + lc = *lcp; + retry: if ( lc->lconn_ber == NULL ) { lc->lconn_ber = ldap_alloc_ber_with_options(ld); @@ -798,6 +804,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); if ( lc != NULL ) { ldap_free_connection( ld, lc, 0, 1 ); + *lcp = NULL; } } }