From: Pierangelo Masarati Date: Sun, 12 Nov 2006 14:22:24 +0000 (+0000) Subject: fix endless loop in canceling child requests; cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~480 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3c1df853e43af018383729a5963eabbe284dcd7c;p=openldap fix endless loop in canceling child requests; cleanup --- diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 2f83ae6766..cdb1808d7a 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -148,11 +148,13 @@ do_abandon( start_again:; lr = ld->ld_requests; while ( lr != NULL ) { - if ( lr->lr_msgid == msgid ) { /* this message */ + /* this message */ + if ( lr->lr_msgid == msgid ) { break; } - if ( lr->lr_origid == msgid ) {/* child: abandon it */ + /* child: abandon it */ + if ( lr->lr_origid == msgid ) { (void)do_abandon( ld, lr->lr_origid, lr->lr_msgid, sctrls, sendabandon ); @@ -291,7 +293,13 @@ start_again:; ldap_free_connection( ld, lr->lr_conn, 0, 1 ); } - if ( origid == msgid ) { +#if 0 + /* FIXME: this is needed so that restarting + * the initial search for lr doesn't result + * in an endless loop */ + if ( origid == msgid ) +#endif + { ldap_free_request( ld, lr ); } } diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 25cdee57b6..531ac0f4f1 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -725,9 +725,9 @@ ldap_dump_requests_and_responses( LDAP *ld ) for ( i = 0; lm != NULL; lm = lm->lm_next, i++ ) { Debug( LDAP_DEBUG_TRACE, " * msgid %d, type %lu\n", lm->lm_msgid, (unsigned long)lm->lm_msgtype, 0 ); - if ( ( l = lm->lm_chain ) != NULL ) { + if ( lm->lm_chain != NULL ) { Debug( LDAP_DEBUG_TRACE, " chained responses:\n", 0, 0, 0 ); - for ( ; l != NULL; l = l->lm_chain ) { + for ( l = lm->lm_chain; l != NULL; l = l->lm_chain ) { Debug( LDAP_DEBUG_TRACE, " * msgid %d, type %lu\n", l->lm_msgid, @@ -795,7 +795,6 @@ ldap_free_request_int( LDAP *ld, LDAPRequest *lr ) void ldap_free_request( LDAP *ld, LDAPRequest *lr ) { - LDAPRequest **ttmplr; #ifdef LDAP_R_COMPILE LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex ); #endif @@ -804,16 +803,21 @@ ldap_free_request( LDAP *ld, LDAPRequest *lr ) lr->lr_origid, lr->lr_msgid, 0 ); /* free all referrals (child requests) */ - while ( lr->lr_child ) + while ( lr->lr_child ) { ldap_free_request( ld, lr->lr_child ); + } if ( lr->lr_parent != NULL ) { + LDAPRequest **lrp; + --lr->lr_parent->lr_outrefcnt; - for ( ttmplr = &lr->lr_parent->lr_child; - *ttmplr && *ttmplr != lr; - ttmplr = &(*ttmplr)->lr_refnext ); - if ( *ttmplr == lr ) - *ttmplr = lr->lr_refnext; + for ( lrp = &lr->lr_parent->lr_child; + *lrp && *lrp != lr; + lrp = &(*lrp)->lr_refnext ); + + if ( *lrp == lr ) { + *lrp = lr->lr_refnext; + } } ldap_free_request_int( ld, lr ); } diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 5a089b9051..ebbb97c17e 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -1087,18 +1087,19 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) } -static void -merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) -{ /* * Merge error information in "lr" with "parentr" error code and string. */ +static void +merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) +{ if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { parentr->lr_res_errno = lr->lr_res_errno; if ( lr->lr_res_error != NULL ) { (void)ldap_append_referral( ld, &parentr->lr_res_error, lr->lr_res_error ); } + } else if ( lr->lr_res_errno != LDAP_SUCCESS && parentr->lr_res_errno == LDAP_SUCCESS ) { @@ -1118,11 +1119,11 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) } Debug( LDAP_DEBUG_TRACE, "merged parent (id %d) error info: ", - parentr->lr_msgid, 0, 0 ); + parentr->lr_msgid, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "result errno %d, error <%s>, matched <%s>\n", - parentr->lr_res_errno, parentr->lr_res_error ? - parentr->lr_res_error : "", parentr->lr_res_matched ? - parentr->lr_res_matched : "" ); + parentr->lr_res_errno, + parentr->lr_res_error ? parentr->lr_res_error : "", + parentr->lr_res_matched ? parentr->lr_res_matched : "" ); }