]> git.sur5r.net Git - openldap/commitdiff
fix ITS#3464
authorPierangelo Masarati <ando@openldap.org>
Sat, 8 Jan 2005 10:59:32 +0000 (10:59 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 8 Jan 2005 10:59:32 +0000 (10:59 +0000)
servers/slapd/back-meta/add.c
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/compare.c
servers/slapd/back-meta/delete.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/modrdn.c
servers/slapd/back-meta/search.c

index ba5e2052cb1c28e66c95223f1e34b989eae7a008..17710ba235776112e367beaa4585f09f67d42769 100644 (file)
@@ -57,7 +57,7 @@ meta_back_add( Operation *op, SlapReply *rs )
 
        if ( !meta_back_dobind( lc, op )
                        || !meta_back_is_valid( lc, candidate ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }
index c377ffc25a150ecb59c12234cd228fc0bac8aaf4..cd82865fb9e23a52f94f5bde3d0ca9151545403a 100644 (file)
@@ -82,6 +82,9 @@ typedef struct dncookie {
 #endif
 } dncookie;
 
+#define META_BIND_NRETRIES     3
+#define META_BIND_TIMEOUT      1000
+
 int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
index 59987d77c0603e41d492ed754a6a6eee02ad4f29..36dc7af36cc465959eb005b8119ba4009d566f67 100644 (file)
@@ -118,6 +118,7 @@ meta_back_bind( Operation *op, SlapReply *rs )
                if ( lerr != LDAP_SUCCESS ) {
                        rs->sr_err = lerr;
                        ( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
+
                } else {
                        rc = LDAP_SUCCESS;
                }
@@ -210,6 +211,7 @@ meta_back_do_single_bind(
                LDAPMessage     *res;
                struct timeval  tv = { 0, 0 };
                int             rc;
+               int             nretries = 0;
 
                /*
                 * handle response!!!
@@ -217,10 +219,14 @@ meta_back_do_single_bind(
 retry:;
                switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
                case 0:
-                       ldap_pvt_thread_yield();
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 100000;    /* 0.1 s */
-                       goto retry;
+                       if ( ++nretries <= META_BIND_NRETRIES ) {
+                               ldap_pvt_thread_yield();
+                               tv.tv_sec = 0;
+                               tv.tv_usec = META_BIND_TIMEOUT;
+                               goto retry;
+                       }
+                       rs->sr_err = LDAP_BUSY;
+                       break;
 
                case -1:
                        ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
@@ -312,7 +318,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                                continue;
                        }
                }
-       
+
                /*
                 * If the target is already bound it is skipped
                 */
@@ -346,6 +352,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        LDAPMessage     *res;
                        struct timeval  tv = { 0, 0 };
                        int             err;
+                       int             nretries = 0;
 
                        /*
                         * handle response!!!
@@ -353,10 +360,15 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
 retry:;
                        switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
                        case 0:
-                               ldap_pvt_thread_yield();
-                               tv.tv_sec = 0;
-                               tv.tv_usec = 100000;    /* 0.1 s */
-                               goto retry;
+                               if ( ++nretries <= META_BIND_NRETRIES ) {
+                                       ldap_pvt_thread_yield();
+                                       tv.tv_sec = 0;
+                                       tv.tv_usec = META_BIND_TIMEOUT;
+                                       goto retry;
+                               }
+
+                               rc = LDAP_BUSY;
+                               break;
 
                        case -1:
                                ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
index e53b9a0bb18d3e919479f7bb67e02de39c9378a7..9a808a9581cf21fae120b4c5ceb66210e8daed5f 100644 (file)
@@ -58,7 +58,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
        }
        
        if ( !meta_back_dobind( lc, op ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }
index e0d51719252bffdee028d0ab31048be0d8c7aa59..13f8f527d982cf26f2365026d785872d4ee9fc1c 100644 (file)
@@ -47,9 +47,14 @@ meta_back_delete( Operation *op, SlapReply *rs )
                return -1;
        }
        
-       if ( !meta_back_dobind( lc, op )
-                       || !meta_back_is_valid( lc, candidate ) ) {
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                return -1;
        }
index 2f53b060767cbdfe6a822ff23842357263363f4c..de3ca1bd447465a71bef8d5b531cf74b2715056a 100644 (file)
@@ -52,10 +52,14 @@ meta_back_modify( Operation *op, SlapReply *rs )
                goto cleanup;
        }
        
-       if ( !meta_back_dobind( lc, op )
-                       || !meta_back_is_valid( lc, candidate ) )
-       {
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                rc = -1;
                goto cleanup;
        }
index 7f8b604bb50a1e6e133df3c97c7f9c8e76ed054c..d4ea67f895d2c9c950488f354fbfb1666df4cd2c 100644 (file)
@@ -51,10 +51,14 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
 
        assert( candidate != META_TARGET_NONE );
 
-       if ( !meta_back_dobind( lc, op ) 
-                       || !meta_back_is_valid( lc, candidate ) )
-       {
+       if ( !meta_back_dobind( lc, op ) ) {
+               rs->sr_err = LDAP_UNAVAILABLE;
+
+       } else if ( !meta_back_is_valid( lc, candidate ) ) {
                rs->sr_err = LDAP_OTHER;
+       }
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                rc = -1;
                goto cleanup;
        }
index 620e2be92e7f2254aaa750456c00057b5ac15a9f..0ef44b9a3850a3e56b033dfe43df586e23673149 100644 (file)
@@ -78,7 +78,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        }
 
        if ( !meta_back_dobind( lc, op ) ) {
-               rs->sr_err = LDAP_OTHER;
+               rs->sr_err = LDAP_UNAVAILABLE;
                send_ldap_result( op, rs );
                return -1;
        }