]> git.sur5r.net Git - openldap/commitdiff
fix endless loop in canceling child requests; cleanup
authorPierangelo Masarati <ando@openldap.org>
Sun, 12 Nov 2006 14:22:24 +0000 (14:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 12 Nov 2006 14:22:24 +0000 (14:22 +0000)
libraries/libldap/abandon.c
libraries/libldap/request.c
libraries/libldap/result.c

index 2f83ae6766e7aa70f0061a6bd8afd1e37030608d..cdb1808d7a08669c0b09b715e92de98feb2b5b20 100644 (file)
@@ -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 );
                }
        }
index 25cdee57b66d7bad5ae07745c2b7538cf824d5a6..531ac0f4f11be92e7774be833901cebde2699935 100644 (file)
@@ -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 );
 }
index 5a089b90514653905ceebd3cd6f83a88dcb9cd77..ebbb97c17ee0b29b12ba13fdd8223bb3416fabe6 100644 (file)
@@ -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 : "" );
 }