From 9f97674ef759c65b874028b7af01fcc65f8dac23 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 24 Feb 2009 15:40:05 +0100 Subject: s3:registry: wrap deletekey_recursive in one big transaction. This speeds up "net conf drop" with 2000 shares on my box from 4m40s to 1m50s, leaving virtually only cpu load. Michael --- source3/registry/reg_api.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index a5f3935821..4dde493a49 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -1133,18 +1133,54 @@ done: return werr; } +static WERROR reg_deletekey_recursive_trans(TALLOC_CTX *ctx, + struct registry_key *parent, + const char *path, + bool del_key) +{ + WERROR werr; + + werr = regdb_transaction_start(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, ("reg_deletekey_recursive_trans: " + "error starting transaction: %s\n", + win_errstr(werr))); + return werr; + } + + werr = reg_deletekey_recursive_internal(ctx, parent, path, del_key); + + if (!W_ERROR_IS_OK(werr)) { + werr = regdb_transaction_cancel(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, ("reg_deletekey_recursive_trans: " + "error cancelling transaction: %s\n", + win_errstr(werr))); + } + } else { + werr = regdb_transaction_commit(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, ("reg_deletekey_recursive_trans: " + "error committing transaction: %s\n", + win_errstr(werr))); + } + } + + return werr; +} + WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, struct registry_key *parent, const char *path) { - return reg_deletekey_recursive_internal(ctx, parent, path, true); + return reg_deletekey_recursive_trans(ctx, parent, path, true); } WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx, struct registry_key *parent, const char *path) { - return reg_deletekey_recursive_internal(ctx, parent, path, false); + return reg_deletekey_recursive_trans(ctx, parent, path, false); } #if 0 -- cgit