]> git.sur5r.net Git - openldap/commitdiff
fix response sending while rebinding (ITS#4597)
authorPierangelo Masarati <ando@openldap.org>
Sat, 24 Jun 2006 16:58:49 +0000 (16:58 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 24 Jun 2006 16:58:49 +0000 (16:58 +0000)
servers/slapd/back-ldap/add.c
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/bind.c
servers/slapd/back-ldap/compare.c
servers/slapd/back-ldap/delete.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/modrdn.c

index cb46b16f355bb85aec3e03634f3f7ab5c4c57e0a..e79f847bc64424390f40e508364cc0246c0126f7 100644 (file)
@@ -36,18 +36,18 @@ ldap_back_add(
        Operation       *op,
        SlapReply       *rs )
 {
-       ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
-
-       ldapconn_t      *lc;
-       int             i = 0,
-                       j = 0;
-       Attribute       *a;
-       LDAPMod         **attrs = NULL,
-                       *attrs2 = NULL;
-       ber_int_t       msgid;
-       int             isupdate;
-       int             do_retry = 1;
-       LDAPControl     **ctrls = NULL;
+       ldapinfo_t              *li = (ldapinfo_t *)op->o_bd->be_private;
+
+       ldapconn_t              *lc;
+       int                     i = 0,
+                               j = 0;
+       Attribute               *a;
+       LDAPMod                 **attrs = NULL,
+                               *attrs2 = NULL;
+       ber_int_t               msgid;
+       int                     isupdate;
+       ldap_back_send_t        retrying = LDAP_BACK_RETRYING;
+       LDAPControl             **ctrls = NULL;
 
        rs->sr_err = LDAP_SUCCESS;
        
@@ -104,9 +104,10 @@ retry:
        rs->sr_err = ldap_add_ext( lc->lc_ld, op->o_req_dn.bv_val, attrs,
                        ctrls, NULL, &msgid );
        rs->sr_err = ldap_back_op_result( lc, op, rs, msgid,
-               li->li_timeout[ LDAP_BACK_OP_ADD ], LDAP_BACK_SENDRESULT );
-       if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
-               do_retry = 0;
+               li->li_timeout[ LDAP_BACK_OP_ADD ],
+               ( LDAP_BACK_SENDRESULT | retrying ) );
+       if ( rs->sr_err == LDAP_UNAVAILABLE && retrying ) {
+               retrying &= ~LDAP_BACK_RETRYING;
                if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }
index 26528bcd6da64a9a3b4793643f565561b865d25f..a1fb091f311964d3cfc9077515d1c63ad77f50ca 100644 (file)
@@ -288,10 +288,17 @@ typedef enum ldap_back_send_t {
        LDAP_BACK_SENDERR               = 0x02,
        LDAP_BACK_SENDRESULT            = (LDAP_BACK_SENDOK|LDAP_BACK_SENDERR),
        LDAP_BACK_BINDING               = 0x04,
+
        LDAP_BACK_BIND_DONTSEND         = (LDAP_BACK_BINDING),
        LDAP_BACK_BIND_SOK              = (LDAP_BACK_BINDING|LDAP_BACK_SENDOK),
        LDAP_BACK_BIND_SERR             = (LDAP_BACK_BINDING|LDAP_BACK_SENDERR),
-       LDAP_BACK_BIND_SRES             = (LDAP_BACK_BINDING|LDAP_BACK_SENDRESULT)
+       LDAP_BACK_BIND_SRES             = (LDAP_BACK_BINDING|LDAP_BACK_SENDRESULT),
+
+       LDAP_BACK_RETRYING              = 0x08,
+       LDAP_BACK_RETRY_DONTSEND        = (LDAP_BACK_RETRYING),
+       LDAP_BACK_RETRY_SOK             = (LDAP_BACK_RETRYING|LDAP_BACK_SENDOK),
+       LDAP_BACK_RETRY_SERR            = (LDAP_BACK_RETRYING|LDAP_BACK_SENDERR),
+       LDAP_BACK_RETRY_SRES            = (LDAP_BACK_RETRYING|LDAP_BACK_SENDRESULT)
 } ldap_back_send_t;
 
 /* define to use asynchronous StartTLS */
index b70d34d60460f426d7307f2e55b1ea038ab58a52..b71c8599f9b1748418c969eebb1585a7bbe902ac 100644 (file)
@@ -1340,15 +1340,24 @@ retry:;
                        rs->sr_matched = match;
                }
        }
-       if ( LDAP_BACK_QUARANTINE( li ) ) {
-               ldap_back_quarantine( op, rs );
-       }
-       if ( op->o_conn &&
-               ( ( sendok & LDAP_BACK_SENDOK ) 
+
+       if ( rs->sr_err == LDAP_UNAVAILABLE ) {
+               if ( !( sendok & LDAP_BACK_RETRYING ) ) {
+                       if ( LDAP_BACK_QUARANTINE( li ) ) {
+                               ldap_back_quarantine( op, rs );
+                       }
+                       if ( op->o_conn && ( sendok & LDAP_BACK_SENDERR ) ) {
+                               send_ldap_result( op, rs );
+                       }
+               }
+
+       } else if ( op->o_conn &&
+               ( ( ( sendok & LDAP_BACK_SENDOK ) && ERR_OK( rs->sr_err ) )
                        || ( ( sendok & LDAP_BACK_SENDERR ) && rs->sr_err != LDAP_SUCCESS ) ) )
        {
                send_ldap_result( op, rs );
        }
+
        if ( match ) {
                if ( rs->sr_matched != match ) {
                        free( (char *)rs->sr_matched );
@@ -1356,21 +1365,25 @@ retry:;
                rs->sr_matched = NULL;
                ldap_memfree( match );
        }
+
        if ( text ) {
                ldap_memfree( text );
        }
        rs->sr_text = NULL;
+
        if ( rs->sr_ref ) {
                assert( refs != NULL );
                ber_memvfree( (void **)refs );
                op->o_tmpfree( rs->sr_ref, op->o_tmpmemctx );
                rs->sr_ref = NULL;
        }
+
        if ( ctrls ) {
                assert( rs->sr_ctrls != NULL );
                ldap_controls_free( ctrls );
                rs->sr_ctrls = NULL;
        }
+
        return( ERR_OK( rs->sr_err ) ? LDAP_SUCCESS : rs->sr_err );
 }
 
index b14de0d68def022aa59a8c375caa5548175f1803..11fd3eb9c30cbdb44bc461772fcb5db733f5471c 100644 (file)
@@ -36,13 +36,13 @@ ldap_back_compare(
                Operation       *op,
                SlapReply       *rs )
 {
-       ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
+       ldapinfo_t              *li = (ldapinfo_t *)op->o_bd->be_private;
 
-       ldapconn_t      *lc;
-       ber_int_t       msgid;
-       int             do_retry = 1;
-       LDAPControl     **ctrls = NULL;
-       int             rc = LDAP_SUCCESS;
+       ldapconn_t              *lc;
+       ber_int_t               msgid;
+       ldap_back_send_t        retrying = LDAP_BACK_RETRYING;
+       LDAPControl             **ctrls = NULL;
+       int                     rc = LDAP_SUCCESS;
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
@@ -63,9 +63,10 @@ retry:
                        op->orc_ava->aa_desc->ad_cname.bv_val,
                        &op->orc_ava->aa_value, 
                        ctrls, NULL, &msgid );
-       rc = ldap_back_op_result( lc, op, rs, msgid, 0, LDAP_BACK_SENDRESULT );
-       if ( rc == LDAP_UNAVAILABLE && do_retry ) {
-               do_retry = 0;
+       rc = ldap_back_op_result( lc, op, rs, msgid, 0,
+               ( LDAP_BACK_SENDRESULT | retrying ) );
+       if ( rc == LDAP_UNAVAILABLE && retrying ) {
+               retrying &= ~LDAP_BACK_RETRYING;
                if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }
index 43e88540b4b59b0a5bc31ef8209b0bc1144f1e70..f95660cace1fe32a9a93f5b2fec1b7140691e524 100644 (file)
@@ -38,11 +38,11 @@ ldap_back_delete(
 {
        ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
 
-       ldapconn_t      *lc;
-       ber_int_t       msgid;
-       LDAPControl     **ctrls = NULL;
-       int             do_retry = 1;
-       int             rc = LDAP_SUCCESS;
+       ldapconn_t              *lc;
+       ber_int_t               msgid;
+       LDAPControl             **ctrls = NULL;
+       ldap_back_send_t        retrying = LDAP_BACK_RETRYING;
+       int                     rc = LDAP_SUCCESS;
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        
@@ -63,9 +63,10 @@ retry:
        rs->sr_err = ldap_delete_ext( lc->lc_ld, op->o_req_dn.bv_val,
                        ctrls, NULL, &msgid );
        rc = ldap_back_op_result( lc, op, rs, msgid,
-               li->li_timeout[ LDAP_BACK_OP_DELETE], LDAP_BACK_SENDRESULT );
-       if ( rs->sr_err == LDAP_SERVER_DOWN && do_retry ) {
-               do_retry = 0;
+               li->li_timeout[ LDAP_BACK_OP_DELETE],
+               ( LDAP_BACK_SENDRESULT | retrying ) );
+       if ( rs->sr_err == LDAP_SERVER_DOWN && retrying ) {
+               retrying &= ~LDAP_BACK_RETRYING;
                if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }
index 60ccc5168738a29cc02c5805bd9775dc081bd387..7e6e7ecad5596d19888117f41e99370944583a27 100644 (file)
@@ -36,17 +36,17 @@ ldap_back_modify(
                Operation       *op,
                SlapReply       *rs )
 {
-       ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
-
-       ldapconn_t      *lc;
-       LDAPMod         **modv = NULL,
-                       *mods = NULL;
-       Modifications   *ml;
-       int             i, j, rc;
-       ber_int_t       msgid;
-       int             isupdate;
-       int             do_retry = 1;
-       LDAPControl     **ctrls = NULL;
+       ldapinfo_t              *li = (ldapinfo_t *)op->o_bd->be_private;
+
+       ldapconn_t              *lc;
+       LDAPMod                 **modv = NULL,
+                               *mods = NULL;
+       Modifications           *ml;
+       int                     i, j, rc;
+       ber_int_t               msgid;
+       int                     isupdate;
+       ldap_back_send_t        retrying = LDAP_BACK_RETRYING;
+       LDAPControl             **ctrls = NULL;
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
@@ -111,9 +111,10 @@ retry:
        rs->sr_err = ldap_modify_ext( lc->lc_ld, op->o_req_dn.bv_val, modv,
                        ctrls, NULL, &msgid );
        rc = ldap_back_op_result( lc, op, rs, msgid,
-               li->li_timeout[ LDAP_BACK_OP_MODIFY], LDAP_BACK_SENDRESULT );
-       if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
-               do_retry = 0;
+               li->li_timeout[ LDAP_BACK_OP_MODIFY],
+               ( LDAP_BACK_SENDRESULT | retrying ) );
+       if ( rs->sr_err == LDAP_UNAVAILABLE && retrying ) {
+               retrying &= ~LDAP_BACK_RETRYING;
                if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }
index 2f92a0003d061fc1691f44f14b3ec0f207c2a061..37e1afe7e86f91c000d0e0e859b4321b384d8feb 100644 (file)
@@ -36,14 +36,14 @@ ldap_back_modrdn(
                Operation       *op,
                SlapReply       *rs )
 {
-       ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
+       ldapinfo_t              *li = (ldapinfo_t *)op->o_bd->be_private;
 
-       ldapconn_t      *lc;
-       ber_int_t       msgid;
-       LDAPControl     **ctrls = NULL;
-       int             do_retry = 1;
-       int             rc = LDAP_SUCCESS;
-       char            *newSup = NULL;
+       ldapconn_t              *lc;
+       ber_int_t               msgid;
+       LDAPControl             **ctrls = NULL;
+       ldap_back_send_t        retrying = LDAP_BACK_RETRYING;
+       int                     rc = LDAP_SUCCESS;
+       char                    *newSup = NULL;
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
@@ -87,9 +87,10 @@ retry:
                        op->orr_newrdn.bv_val, newSup,
                        op->orr_deleteoldrdn, ctrls, NULL, &msgid );
        rc = ldap_back_op_result( lc, op, rs, msgid,
-               li->li_timeout[ LDAP_BACK_OP_MODRDN ], LDAP_BACK_SENDRESULT );
-       if ( rs->sr_err == LDAP_SERVER_DOWN && do_retry ) {
-               do_retry = 0;
+               li->li_timeout[ LDAP_BACK_OP_MODRDN ],
+               ( LDAP_BACK_SENDRESULT | retrying ) );
+       if ( rs->sr_err == LDAP_SERVER_DOWN && retrying ) {
+               retrying &= ~LDAP_BACK_RETRYING;
                if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }