Commit 3c1df853 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

fix endless loop in canceling child requests; cleanup

parent c6bf6672
......@@ -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 );
}
}
......
......@@ -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 );
}
......
......@@ -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 : "" );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment