From 2d10f3a84197a20fa7a6ff8305a69ac57ddd44e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Jan 2010 18:38:16 +1100 Subject: s4-dsdb: poke the RID Manager when completely out of RIDs too --- source4/dsdb/samdb/ldb_modules/ridalloc.c | 79 ++++++++++++++++--------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/ridalloc.c b/source4/dsdb/samdb/ldb_modules/ridalloc.c index 07b3739f8e..a64062fcdc 100644 --- a/source4/dsdb/samdb/ldb_modules/ridalloc.c +++ b/source4/dsdb/samdb/ldb_modules/ridalloc.c @@ -55,6 +55,45 @@ */ +/* + make a IRPC call to the drepl task to ask it to get the RID + Manager to give us another RID pool. + + This function just sends the message to the drepl task then + returns immediately. It should be called well before we + completely run out of RIDs + */ +static void ridalloc_poke_rid_manager(struct ldb_module *module) +{ + struct messaging_context *msg; + struct server_id *server; + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct loadparm_context *lp_ctx = ldb_get_opaque(ldb, "loadparm"); + TALLOC_CTX *tmp_ctx = talloc_new(module); + + msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, lp_ctx), + lp_iconv_convenience(lp_ctx), + ldb_get_event_context(ldb)); + if (!msg) { + DEBUG(3,(__location__ ": Failed to create messaging context\n")); + talloc_free(tmp_ctx); + return; + } + + server = irpc_servers_byname(msg, msg, "dreplsrv"); + if (!server) { + /* this means the drepl service is not running */ + talloc_free(tmp_ctx); + return; + } + + messaging_send(msg, server[0], MSG_DREPL_ALLOCATE_RID, NULL); + + /* we don't care if the message got through */ + talloc_free(tmp_ctx); +} + + /* allocate a new range of RIDs in the RID Manager object */ @@ -272,6 +311,7 @@ static int ridalloc_create_own_rid_set(struct ldb_module *module, TALLOC_CTX *me } if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), fsmo_role_dn) != 0) { + ridalloc_poke_rid_manager(module); ldb_asprintf_errstring(ldb, "Remote RID Set allocation needs refresh"); talloc_free(tmp_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -338,44 +378,6 @@ static int ridalloc_refresh_rid_set_ntds(struct ldb_module *module, } -/* - make a IRPC call to the drepl task to ask it to get the RID - Manager to give us another RID pool. - - This function just sends the message to the drepl task then - returns immediately. It should be called well before we - completely run out of RIDs - */ -static void ridalloc_poke_rid_manager(struct ldb_module *module) -{ - struct messaging_context *msg; - struct server_id *server; - struct ldb_context *ldb = ldb_module_get_ctx(module); - struct loadparm_context *lp_ctx = ldb_get_opaque(ldb, "loadparm"); - TALLOC_CTX *tmp_ctx = talloc_new(module); - - msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, lp_ctx), - lp_iconv_convenience(lp_ctx), - ldb_get_event_context(ldb)); - if (!msg) { - DEBUG(3,(__location__ ": Failed to create messaging context\n")); - talloc_free(tmp_ctx); - return; - } - - server = irpc_servers_byname(msg, msg, "dreplsrv"); - if (!server) { - /* this means the drepl service is not running */ - talloc_free(tmp_ctx); - return; - } - - messaging_send(msg, server[0], MSG_DREPL_ALLOCATE_RID, NULL); - - /* we don't care if the message got through */ - talloc_free(tmp_ctx); -} - /* get a new RID pool for ourselves also returns the first rid for the new pool @@ -406,6 +408,7 @@ static int ridalloc_refresh_own_pool(struct ldb_module *module, uint64_t *new_po } if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), fsmo_role_dn) != 0) { + ridalloc_poke_rid_manager(module); ldb_asprintf_errstring(ldb, "Remote RID Set allocation needs refresh"); talloc_free(tmp_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; -- cgit