]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Import multilevel referral chase bug fix from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 1 Oct 2001 18:53:26 +0000 (18:53 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 1 Oct 2001 18:53:26 +0000 (18:53 +0000)
libraries/libldap/ldap-int.h
libraries/libldap/request.c
libraries/libldap/result.c
libraries/libldap/unbind.c

index d5171055f4dca6757bd040f56faa171cbca2831a..0a2f553cf92f522a3c6a59d5f3d3ff389e1b7923 100644 (file)
@@ -205,6 +205,7 @@ typedef struct ldapreq {
        BerElement      *lr_ber;        /* ber encoded request contents */
        LDAPConn        *lr_conn;       /* connection used to send request */
        struct ldapreq  *lr_parent;     /* request that spawned this referral */
+       struct ldapreq  *lr_child;      /* first child request */
        struct ldapreq  *lr_refnext;    /* next referral spawned */
        struct ldapreq  *lr_prev;       /* previous request */
        struct ldapreq  *lr_next;       /* next request */
index 9d87cd21beb80dcb9e292eef22fa5631d9adaf1b..49f8cd8639f4bf2d5d4ef691400914bd615519f6 100644 (file)
@@ -187,8 +187,8 @@ ldap_send_server_request(
                lr->lr_origid = parentreq->lr_origid;
                lr->lr_parentcnt = parentreq->lr_parentcnt + 1;
                lr->lr_parent = parentreq;
-               lr->lr_refnext = parentreq->lr_refnext;
-               parentreq->lr_refnext = lr;
+               lr->lr_refnext = parentreq->lr_child;
+               parentreq->lr_child = lr;
        } else {                        /* original request */
                lr->lr_origid = lr->lr_msgid;
        }
@@ -523,25 +523,9 @@ ldap_dump_requests_and_responses( LDAP *ld )
 }
 #endif /* LDAP_DEBUG */
 
-
 void
-ldap_free_request( LDAP *ld, LDAPRequest *lr )
+ldap_free_request_int( LDAP *ld, LDAPRequest *lr )
 {
-       LDAPRequest     *tmplr, *nextlr;
-
-       Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n",
-               lr->lr_origid, lr->lr_msgid, 0 );
-
-       if ( lr->lr_parent != NULL ) {
-               --lr->lr_parent->lr_outrefcnt;
-       } else {
-               /* free all referrals (child requests) */
-               for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) {
-                       nextlr = tmplr->lr_refnext;
-                       ldap_free_request( ld, tmplr );
-               }
-       }
-
        if ( lr->lr_prev == NULL ) {
                ld->ld_requests = lr->lr_next;
        } else {
@@ -567,6 +551,29 @@ ldap_free_request( LDAP *ld, LDAPRequest *lr )
        LDAP_FREE( lr );
 }
 
+void
+ldap_free_request( LDAP *ld, LDAPRequest *lr )
+{
+       LDAPRequest     *tmplr, *nextlr;
+       LDAPRequest     **ttmplr;
+
+       Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n",
+               lr->lr_origid, lr->lr_msgid, 0 );
+
+       if ( lr->lr_parent != NULL ) {
+               --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;
+       } else {
+               /* free all referrals (child requests) */
+               while ( lr->lr_child )
+                       ldap_free_request( ld, lr->lr_child );
+       }
+       ldap_free_request_int( ld, lr );
+}
+
+
 /*
  * Chase v3 referrals
  *
index c8804e04e9e445c896db4c09195b417839e3689f..39b765e6f045a67ec8f6bec65b1554b83f9a5924 100644 (file)
@@ -598,9 +598,12 @@ Debug( LDAP_DEBUG_TRACE,
                        }
 
                        /* Check if all requests are finished, lr is now parent */
-                       for(tmplr=lr ; tmplr != NULL; tmplr=tmplr->lr_refnext) {
+                       tmplr = lr;
+                       if (tmplr->lr_status == LDAP_REQST_COMPLETED) {
+                               for(tmplr=lr->lr_child; tmplr != NULL; tmplr=tmplr->lr_refnext) {
                                if( tmplr->lr_status != LDAP_REQST_COMPLETED) {
                                        break;
+                                       }
                                }
                        }
 
index 0d5f3fe46ac3204488e8d7443cc2514fbb3e6a83..0699a4be0ba411ce7cd14706086167f232034328 100644 (file)
@@ -70,13 +70,11 @@ ldap_ld_free(
 {
        LDAPMessage     *lm, *next;
        int             err = LDAP_SUCCESS;
-       LDAPRequest     *lr, *nextlr;
 
-               /* free LDAP structure and outstanding requests/responses */
-               for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
-                       nextlr = lr->lr_next;
-                       ldap_free_request( ld, lr );
-               }
+       /* free LDAP structure and outstanding requests/responses */
+       while ( ld->ld_requests != NULL ) {
+               ldap_free_request( ld, ld->ld_requests );
+       }
 
                /* free and unbind from all open connections */
                while ( ld->ld_conns != NULL ) {