s4-dsdb: it is a better pattern to mark a control as done than remove it
authorAndrew Tridgell <tridge@samba.org>
Wed, 16 Dec 2009 09:45:02 +0000 (20:45 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 16 Dec 2009 09:56:24 +0000 (20:56 +1100)
removing a control means it can't be seen by any other modules, which
is usually not what is wanted. Better to just mark it non-critical,
which means anyone else who wants to look at it can, but if nobody
does its not an error.

source4/dsdb/samdb/ldb_modules/extended_dn_out.c
source4/dsdb/samdb/ldb_modules/lazy_commit.c
source4/dsdb/samdb/ldb_modules/show_deleted.c

index bd57913ea6ebdca4ff67bfaa17b2a65d750d162f..2d0ee6a4aa22a4c8075720624e5d441ecc6d61d8 100644 (file)
@@ -553,7 +553,6 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request
        struct ldb_control *control;
        struct ldb_control *storage_format_control;
        struct ldb_extended_dn_control *extended_ctrl = NULL;
        struct ldb_control *control;
        struct ldb_control *storage_format_control;
        struct ldb_extended_dn_control *extended_ctrl = NULL;
-       struct ldb_control **saved_controls;
        struct extended_search_context *ac;
        struct ldb_request *down_req;
        char **new_attrs;
        struct extended_search_context *ac;
        struct ldb_request *down_req;
        char **new_attrs;
@@ -652,24 +651,13 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request
                return ret;
        }
 
                return ret;
        }
 
-       /* Remove extended DN and storage format controls */
-
+       /* mark extended DN and storage format controls as done */
        if (control) {
        if (control) {
-               /* save it locally and remove it from the list */
-               /* we do not need to replace them later as we
-                * are keeping the original req intact */
-               if (!save_controls(control, down_req, &saved_controls)) {
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
+               control->critical = 0;
        }
 
        if (storage_format_control) {
        }
 
        if (storage_format_control) {
-               /* save it locally and remove it from the list */
-               /* we do not need to replace them later as we
-                * are keeping the original req intact */
-               if (!save_controls(storage_format_control, down_req, &saved_controls)) {
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
+               storage_format_control->critical = 0;
        }
 
        /* Add in dereference control, if we were asked to, we are
        }
 
        /* Add in dereference control, if we were asked to, we are
index 69ac99e24612006267339212e9e7f970d4dc38d6..0502b2efa14573cdb778677c85adad57deb9f7d3 100644 (file)
@@ -33,7 +33,6 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
 {
        int ret;
        struct ldb_request *new_req;
 {
        int ret;
        struct ldb_request *new_req;
-       struct ldb_control **saved_controls;
        struct ldb_control *control = ldb_request_get_control(req, LDB_CONTROL_SERVER_LAZY_COMMIT);
        if (!control) {
                return ldb_next_request(module, req);
        struct ldb_control *control = ldb_request_get_control(req, LDB_CONTROL_SERVER_LAZY_COMMIT);
        if (!control) {
                return ldb_next_request(module, req);
@@ -99,7 +98,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                return ret;
        }
 
                return ret;
        }
 
-       save_controls(control, req, &saved_controls);
+       control->critical = 0;
        return ldb_next_request(module, new_req);
 }
 
        return ldb_next_request(module, new_req);
 }
 
index 11503e6d3bb6e0f0567ffe50a0aba759de0a8344..666d28053c236fbfd35711c8e25bef61c9b73d65 100644 (file)
@@ -38,7 +38,6 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re
 {
        struct ldb_context *ldb;
        struct ldb_control *control;
 {
        struct ldb_context *ldb;
        struct ldb_control *control;
-       struct ldb_control **saved_controls;
        struct ldb_request *down_req;
        struct ldb_parse_tree *new_tree = req->op.search.tree;
        int ret;
        struct ldb_request *down_req;
        struct ldb_parse_tree *new_tree = req->op.search.tree;
        int ret;
@@ -90,9 +89,9 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re
                return ret;
        }
 
                return ret;
        }
 
-       /* if a control is there remove if from the modified request */
-       if (control && !save_controls(control, down_req, &saved_controls)) {
-               return LDB_ERR_OPERATIONS_ERROR;
+       /* mark the control as done */
+       if (control) {
+               control->critical = 0;
        }
 
        /* perform the search */
        }
 
        /* perform the search */