]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/bind.c
Read config tree from back-ldif
[openldap] / servers / slapd / back-meta / bind.c
index 59987d77c0603e41d492ed754a6a6eee02ad4f29..69fe2ea995ea527d5f127a425f0484a6123dad0f 100644 (file)
@@ -63,7 +63,7 @@ meta_back_bind( Operation *op, SlapReply *rs )
                op_type = META_OP_REQUIRE_ALL;
        }
        lc = meta_back_getconn( op, rs, op_type,
-                       &op->o_req_ndn, NULL );
+                       &op->o_req_ndn, NULL, LDAP_BACK_SENDERR );
        if ( !lc ) {
                Debug( LDAP_DEBUG_ANY,
                                "meta_back_bind: no target for dn %s.\n%s%s",
@@ -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;
                }
@@ -191,18 +192,11 @@ meta_back_do_single_bind(
                return -1;
        }
 
-       if ( op->o_ctrls ) {
-               rs->sr_err = ldap_set_option( lsc->msc_ld, 
-                               LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
-               if ( rs->sr_err != LDAP_SUCCESS ) {
-                       rs->sr_err = slap_map_api2result( rs );
-                       goto return_results;
-               }
-       }
-
        /* FIXME: this fixes the bind problem right now; we need
         * to use the asynchronous version to get the "matched"
         * and more in case of failure ... */
+       /* FIXME: should be check if at least some of the op->o_ctrls
+        * can/should be passed? */
        rs->sr_err = ldap_sasl_bind( lsc->msc_ld, mdn.bv_val,
                        LDAP_SASL_SIMPLE, &op->orb_cred,
                        op->o_ctrls, NULL, &msgid );
@@ -210,6 +204,7 @@ meta_back_do_single_bind(
                LDAPMessage     *res;
                struct timeval  tv = { 0, 0 };
                int             rc;
+               int             nretries = 0;
 
                /*
                 * handle response!!!
@@ -217,10 +212,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,
@@ -249,7 +248,7 @@ retry:;
        lsc->msc_bound = META_BOUND;
        lc->mc_bound_target = candidate;
 
-       if ( li->savecred ) {
+       if ( LDAP_BACK_SAVECRED( li ) ) {
                if ( !BER_BVISNULL( &lsc->msc_cred ) ) {
                        /* destroy sensitive data */
                        memset( lsc->msc_cred.bv_val, 0, lsc->msc_cred.bv_len );
@@ -278,7 +277,7 @@ return_results:;
  * meta_back_dobind
  */
 int
-meta_back_dobind( struct metaconn *lc, Operation *op )
+meta_back_dobind( struct metaconn *lc, Operation *op, ldap_back_send_t sendok )
 {
        struct metasingleconn   *lsc;
        int                     bound = 0, i;
@@ -302,17 +301,6 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        continue;
                }
 
-               /*
-                * If required, set controls
-                */
-               if ( op->o_ctrls ) {
-                       if ( ldap_set_option( lsc->msc_ld, LDAP_OPT_SERVER_CONTROLS,
-                                       op->o_ctrls ) != LDAP_SUCCESS ) {
-                               ( void )meta_clear_one_candidate( lsc, 1 );
-                               continue;
-                       }
-               }
-       
                /*
                 * If the target is already bound it is skipped
                 */
@@ -340,12 +328,15 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                        BER_BVZERO( &lsc->msc_cred );
                }
 
+               /* FIXME: should we check if at least some of the op->o_ctrls
+                * can/should be passed? */
                rc = ldap_sasl_bind( lsc->msc_ld, "", LDAP_SASL_SIMPLE, &cred,
-                               op->o_ctrls, NULL, &msgid );
+                               NULL, NULL, &msgid );
                if ( rc == LDAP_SUCCESS ) {
                        LDAPMessage     *res;
                        struct timeval  tv = { 0, 0 };
                        int             err;
+                       int             nretries = 0;
 
                        /*
                         * handle response!!!
@@ -353,10 +344,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,