]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/glue.c
ITS#3671 make sure to flush queue when able
[openldap] / servers / slapd / overlays / glue.c
index 03c7a306c61a27045909cd02f370897f269e88b3..957a45655d62a70e82f1d9413728c3d3cd6724e6 100644 (file)
@@ -40,7 +40,6 @@
 
 typedef struct gluenode {
        BackendDB *gn_be;
-       int     gn_bx;
        struct berval gn_pdn;
        int gn_async;
 } gluenode;
@@ -271,7 +270,11 @@ glue_op_search ( Operation *op, SlapReply *rs )
 
        switch (op->ors_scope) {
        case LDAP_SCOPE_BASE:
-               return SLAP_CB_CONTINUE;
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               if (op->o_bd && op->o_bd->be_search) {
+                       rs->sr_err = op->o_bd->be_search( op, rs );
+               }
+               return rs->sr_err;
 
        case LDAP_SCOPE_ONELEVEL:
        case LDAP_SCOPE_SUBTREE:
@@ -378,6 +381,9 @@ glue_op_search ( Operation *op, SlapReply *rs )
                        case LDAP_TIMELIMIT_EXCEEDED:
                        case LDAP_ADMINLIMIT_EXCEEDED:
                        case LDAP_NO_SUCH_OBJECT:
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+                       case LDAP_CANNOT_CHAIN:
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
                                goto end_of_loop;
                        
                        default:
@@ -393,7 +399,9 @@ end_of_loop:;
 
                break;
        }
-       if ( !op->o_abandon ) {
+       if ( op->o_abandon ) {
+               rs->sr_err = SLAPD_ABANDON;
+       } else {
                op->o_callback = cb.sc_next;
                rs->sr_err = gs.err;
                rs->sr_matched = gs.matched;
@@ -721,23 +729,6 @@ glue_db_destroy (
        return SLAP_CB_CONTINUE;
 }
 
-static int
-glue_db_open (
-       BackendDB *be
-)
-{
-       slap_overinst   *on = (slap_overinst *)be->bd_info;
-       glueinfo                *gi = (glueinfo *)on->on_bi.bi_private;
-       int i;
-
-       for ( i=0; i<gi->gi_nodes; i++ ) {
-               int j;
-
-               gi->gi_n[i].gn_be = backendDB + gi->gi_n[i].gn_bx;
-       }
-       return 0;
-}
-
 static int
 glue_db_close( 
        BackendDB *be
@@ -761,23 +752,30 @@ glue_db_config(
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        glueinfo                *gi = (glueinfo *)on->on_bi.bi_private;
 
+       /* redundant; could be applied just once */
+       SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
+
        if ( strcasecmp( argv[0], "glue-sub" ) == 0 ) {
-               int async = 0;
+               int i, async = 0, advertise = 0;
                BackendDB *b2;
                struct berval bv, dn;
                gluenode *gn;
 
                if ( argc < 2 ) {
                        fprintf( stderr, "%s: line %d: too few arguments in "
-                               "\"glue-sub <suffixDN> [async]\"\n", fname, lineno );
+                               "\"glue-sub <suffixDN> [async] [advertise]\"\n", fname, lineno );
                        return -1;
                }
-               if ( argc == 3 ) {
-                       if ( strcasecmp( argv[2], "async" )) {
-                               fprintf( stderr, "%s: line %d: unrecognized option "
-                                       "\"%s\" ignored.\n", fname, lineno, argv[2] );
-                       } else {
+               for ( i = 2; i < argc; i++ ) {
+                       if ( strcasecmp( argv[i], "async" ) == 0 ) {
                                async = 1;
+
+                       } else if ( strcasecmp( argv[i], "advertise" ) == 0 ) {
+                               advertise = 1;
+
+                       } else {
+                               fprintf( stderr, "%s: line %d: unrecognized option "
+                                       "\"%s\" ignored.\n", fname, lineno, argv[i] );
                        }
                }
                ber_str2bv( argv[1], 0, 0, &bv );
@@ -792,9 +790,12 @@ glue_db_config(
                        return -1;
                }
                SLAP_DBFLAGS(b2) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
+               if ( advertise ) {
+                       SLAP_DBFLAGS(b2) |= SLAP_DBFLAG_GLUE_ADVERTISE;
+               }
                gi = (glueinfo *)ch_realloc( gi, sizeof(glueinfo) +
                        gi->gi_nodes * sizeof(gluenode));
-               gi->gi_n[gi->gi_nodes].gn_bx = b2 - backendDB;
+               gi->gi_n[gi->gi_nodes].gn_be = b2;
                dnParent( &b2->be_nsuffix[0], &gi->gi_n[gi->gi_nodes].gn_pdn );
                gi->gi_n[gi->gi_nodes].gn_async = async;
                gi->gi_nodes++;
@@ -811,7 +812,6 @@ glue_init()
 
        glue.on_bi.bi_db_init = glue_db_init;
        glue.on_bi.bi_db_config = glue_db_config;
-       glue.on_bi.bi_db_open = glue_db_open;
        glue.on_bi.bi_db_close = glue_db_close;
        glue.on_bi.bi_db_destroy = glue_db_destroy;