]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backover.c
Tweaks for OpenSSL 1.1 API deprecations
[openldap] / servers / slapd / backover.c
index 02dc5125cbba412a0a532b6bbd6138b30a392d75..8914920998c2e5da01f061804a42d8899be77474 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-2017 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;
@@ -721,7 +727,8 @@ over_op_func(
        slap_overinfo *oi;
        slap_overinst *on;
        BackendDB *be = op->o_bd, db;
-       slap_callback cb = {NULL, over_back_response, NULL, NULL}, **sc;
+       slap_callback **sc;
+       slap_callback *cb = (slap_callback *) ch_malloc( sizeof( slap_callback ));
        int rc = SLAP_CB_CONTINUE;
 
        /* FIXME: used to happen for instance during abandon
@@ -736,14 +743,18 @@ over_op_func(
                db.be_flags |= SLAP_DBFLAG_OVERLAY;
                op->o_bd = &db;
        }
-       cb.sc_next = op->o_callback;
-       cb.sc_private = oi;
-       op->o_callback = &cb;
+       cb->sc_cleanup = NULL;
+       cb->sc_response = over_back_response;
+       cb->sc_writewait = NULL;
+       cb->sc_next = op->o_callback;
+       cb->sc_private = oi;
+       op->o_callback = cb;
 
        rc = overlay_op_walk( op, rs, which, oi, on );
        for ( sc = &op->o_callback; *sc; sc = &(*sc)->sc_next ) {
-               if ( *sc == &cb ) {
-                       *sc = cb.sc_next;
+               if ( *sc == cb ) {
+                       *sc = cb->sc_next;
+                       ch_free( cb );
                        break;
                }
        }
@@ -1234,6 +1245,7 @@ overlay_remove( BackendDB *be, slap_overinst *on, Operation *op )
        rm_cb->sc_cleanup = overlay_remove_cb;
        rm_cb->sc_response = NULL;
        rm_cb->sc_private = (void*) rm_ctx;
+       rm_cb->sc_writewait = NULL;
 
        /* Append callback to the end of the list */
        if ( !op->o_callback ) {
@@ -1451,4 +1463,3 @@ overlay_config( BackendDB *be, const char *ov, int idx, BackendInfo **res, Confi
 
        return 0;
 }
-