]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backover.c
Merge remote-tracking branch 'origin/mdb.RE/0.9'
[openldap] / servers / slapd / backover.c
index 02dc5125cbba412a0a532b6bbd6138b30a392d75..b7d22922f450fbfd99324c7da2c95db9d3ef7aad 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2013 The OpenLDAP Foundation.
+ * Copyright 2003-2015 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -669,26 +669,31 @@ int overlay_op_walk(
        slap_overinst *on
 )
 {
-       BI_op_bind **func;
+       BackendInfo *bi;
        int rc = SLAP_CB_CONTINUE;
 
        for (; on; on=on->on_next ) {
                if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
                        continue;
-               func = &on->on_bi.bi_op_bind;
-               if ( func[which] ) {
+               bi = &on->on_bi;
+               if ( (&bi->bi_op_bind)[ which ] ) {
                        op->o_bd->bd_info = (BackendInfo *)on;
-                       rc = func[which]( op, rs );
+                       rc = (&bi->bi_op_bind)[ which ]( op, rs );
                        if ( rc != SLAP_CB_CONTINUE ) break;
                }
        }
        if ( rc == SLAP_CB_BYPASS )
                rc = SLAP_CB_CONTINUE;
+       /* if an overlay halted processing, make sure
+        * any previously set cleanup handlers are run
+        */
+       if ( rc != SLAP_CB_CONTINUE )
+               goto cleanup;
 
-       func = &oi->oi_orig->bi_op_bind;
-       if ( func[which] && rc == SLAP_CB_CONTINUE ) {
-               op->o_bd->bd_info = oi->oi_orig;
-               rc = func[which]( op, rs );
+       bi = oi->oi_orig;
+       if ( (&bi->bi_op_bind)[ which ] ) {
+               op->o_bd->bd_info = bi;
+               rc = (&bi->bi_op_bind)[ which ]( op, rs );
        }
        /* should not fall thru this far without anything happening... */
        if ( rc == SLAP_CB_CONTINUE ) {
@@ -700,6 +705,7 @@ int overlay_op_walk(
         */
        if ( rc == LDAP_UNWILLING_TO_PERFORM ) {
                slap_callback *sc_next;
+cleanup:
                for ( ; op->o_callback && op->o_callback->sc_response !=
                        over_back_response; op->o_callback = sc_next ) {
                        sc_next = op->o_callback->sc_next;
@@ -1451,4 +1457,3 @@ overlay_config( BackendDB *be, const char *ov, int idx, BackendInfo **res, Confi
 
        return 0;
 }
-