s4-dsdb: added tagging of requests in dsdb modules
authorAndrew Tridgell <tridge@samba.org>
Fri, 24 Sep 2010 19:09:26 +0000 (12:09 -0700)
committerAndrew Tridgell <tridge@samba.org>
Sat, 25 Sep 2010 17:38:45 +0000 (10:38 -0700)
this allows you to call dsdb_req_chain_debug() in gdb or when writing
debug code to see the request chain

source4/dsdb/samdb/ldb_modules/acl.c
source4/dsdb/samdb/ldb_modules/anr.c
source4/dsdb/samdb/ldb_modules/descriptor.c
source4/dsdb/samdb/ldb_modules/extended_dn_in.c
source4/dsdb/samdb/ldb_modules/extended_dn_out.c
source4/dsdb/samdb/ldb_modules/lazy_commit.c
source4/dsdb/samdb/ldb_modules/local_password.c
source4/dsdb/samdb/ldb_modules/util.c

index 826884f8118420ebd5272a3da04620114e22d917..497e1add5c82d9b8c989ca3f0d6386f6b0dbc505 100644 (file)
@@ -1344,6 +1344,7 @@ static int acl_search(struct ldb_module *module, struct ldb_request *req)
                                      req->controls,
                                      ac, acl_search_callback,
                                      req);
+       LDB_REQ_SET_LOCATION(down_req);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
index 15a8a7aa483be56382d63a83439c35e672295a79..ebe9d6609706ccdccef26f7d35a649fbba6dbb4a 100644 (file)
@@ -32,6 +32,7 @@
 #include "includes.h"
 #include "ldb_module.h"
 #include "dsdb/samdb/samdb.h"
+#include "dsdb/samdb/ldb_modules/util.h"
 
 /**
  * Make a and 'and' or 'or' tree from the two supplied elements 
@@ -355,6 +356,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req)
                                        req->controls,
                                        ac, anr_search_callback,
                                        req);
+       LDB_REQ_SET_LOCATION(down_req);
        if (ret != LDB_SUCCESS) {
                return ldb_operr(ldb);
        }
index f32383ed72b62a827ac0cc915caac1691483ebbc..03e445e73ce2d238a720be026800c7953532c59a 100644 (file)
@@ -857,6 +857,7 @@ static int descriptor_search(struct ldb_module *module, struct ldb_request *req)
                                      req->controls,
                                      ac, descriptor_search_callback,
                                      ac->req);
+       LDB_REQ_SET_LOCATION(down_req);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
index c4d006fc4f15f1c4a7797c3f8ce9904033b3922b..3dec685678ebfca1dffabf884feb44cb6105111e 100644 (file)
@@ -173,6 +173,7 @@ static int extended_base_callback(struct ldb_request *req, struct ldb_reply *are
                                                      ac->req->controls,
                                                      ac, extended_final_callback, 
                                                      ac->req);
+                       LDB_REQ_SET_LOCATION(down_req);
                        break;
                case LDB_ADD:
                {
@@ -191,6 +192,7 @@ static int extended_base_callback(struct ldb_request *req, struct ldb_reply *are
                                                ac->req->controls,
                                                ac, extended_final_callback, 
                                                ac->req);
+                       LDB_REQ_SET_LOCATION(down_req);
                        break;
                }
                case LDB_MODIFY:
index fc0401369c0b40842f008eb6a5882b210a81b0a2..2daae253ef1b915abb6f61ffa7311c3261991fb0 100644 (file)
@@ -643,6 +643,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request
                                      req->controls,
                                      ac, callback,
                                      req);
+       LDB_REQ_SET_LOCATION(down_req);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
index 6a59a967aa5f8958a251c70ef52ef9feda5e679a..b46f88a5759dc6c5f38d6e9e1210f22ce0db24b4 100644 (file)
@@ -50,6 +50,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                              req->controls,
                                              req, dsdb_next_callback,
                                              req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        case LDB_ADD:
                ret = ldb_build_add_req(&new_req, ldb_module_get_ctx(module), req,
@@ -57,6 +58,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                        req->controls,
                                        req, dsdb_next_callback,
                                        req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        case LDB_MODIFY:
                ret = ldb_build_mod_req(&new_req, ldb_module_get_ctx(module), req,
@@ -64,6 +66,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                        req->controls,
                                        req, dsdb_next_callback,
                                        req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        case LDB_DELETE:
                ret = ldb_build_del_req(&new_req, ldb_module_get_ctx(module), req,
@@ -71,6 +74,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                        req->controls,
                                        req, dsdb_next_callback,
                                        req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        case LDB_RENAME:
                ret = ldb_build_rename_req(&new_req, ldb_module_get_ctx(module), req,
@@ -79,6 +83,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                           req->controls,
                                           req, dsdb_next_callback,
                                           req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        case LDB_EXTENDED:
                ret = ldb_build_extended_req(&new_req, ldb_module_get_ctx(module),
@@ -88,6 +93,7 @@ static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
                                             req->controls,
                                             req, dsdb_next_callback,
                                             req);
+               LDB_REQ_SET_LOCATION(new_req);
                break;
        default:
                ldb_set_errstring(ldb_module_get_ctx(module),
index 942b5a25435bcb7f697e4b0cd5fc4ac9ecdb5c93..022a6dc98dfe9f776262c3f993c0811234bd139b 100644 (file)
@@ -34,6 +34,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "librpc/ndr/libndr.h"
 #include "dsdb/samdb/ldb_modules/password_modules.h"
+#include "dsdb/samdb/ldb_modules/util.h"
 
 #define PASSWORD_GUID_ATTR "masterGUID"
 
@@ -1079,6 +1080,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request *
                                        req->controls,
                                        ac, lpdb_remote_search_callback,
                                        req);
+       LDB_REQ_SET_LOCATION(remote_req);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
index a78200133bebcb9eafe2bc5d933517ba5058b6bd..03c301898e615b3f2b2031c4d255f8c396cd61b8 100644 (file)
@@ -27,6 +27,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "util.h"
 #include "libcli/security/security.h"
+#include "lib/ldb/include/ldb_private.h"
 
 /*
   search for attrs on one DN, in the modules below
@@ -1198,3 +1199,17 @@ bool dsdb_block_anonymous_ops(struct ldb_module *module,
        talloc_free(tmp_ctx);
        return result;
 }
+
+/*
+  show the chain of requests, useful for debugging async requests
+ */
+void dsdb_req_chain_debug(struct ldb_request *req, int level)
+{
+       char *ret;
+       int i=0;
+
+       while (req && req->handle) {
+               DEBUG(level,("req[%u] %p  : %s\n", i++, req, ldb_req_location(req)));
+               req = req->handle->parent;
+       }
+}