[SCM] SAMBA-CTDB repository - branch v3-2-ctdb updated - build_3.2.7_ctdb.54-180-ga19b56d

Michael Adam obnox at samba.org
Thu Feb 26 12:29:38 GMT 2009


The branch, v3-2-ctdb has been updated
       via  a19b56ddc07866bbcbb92e9e79b23cc440ef49e2 (commit)
       via  dbf68cf481f32d4b58b438326179d4ceeb96c784 (commit)
       via  5951a13b24425ed1e6ed58228a74c317a665178e (commit)
       via  19bc272445780c131c8c48092f5f3984b4864839 (commit)
       via  91c84b8c2218d1d1ec435aae59e2320bffb6be9f (commit)
       via  b2005f1df0ea3212c8fef0d97a7f9d42d95651c5 (commit)
       via  2033484538b39246c7bb2c575fe768b113ee80b5 (commit)
       via  e8e1835175c37a982b6856611f17a3cf0daa8251 (commit)
       via  14c981580540fcb0029fc7b72bc0591e63418479 (commit)
       via  a97ff02ed0dc502c3ba1a800bffae0d2573171a8 (commit)
       via  1dbceb8e1c4f2c652bdfc15eee1e9b6b451eb2a8 (commit)
       via  41967398f76cd0eb4709b7b45419684665d1e7d2 (commit)
       via  7bed6fb33ea8c7fb88ae9482240199ceec8862b1 (commit)
       via  45f8e1872f18e7fe2a9c8c625c5d60afa77b5aee (commit)
       via  d80dad986128c8500fcdf683f2a3df330c0ca850 (commit)
       via  03b36942f8e27c847b1ea683e71612db6a2ef2b2 (commit)
       via  735b76032e43808a52744b83cea02582500e6acf (commit)
       via  de0ec0e244224b85f2d69ffe547186c0df87a654 (commit)
       via  b6d8239c188c360ba2431e577a8bf18e9d8d532d (commit)
       via  f8a30455a7f04133a759bc98a5598af70e508e4f (commit)
       via  dde3bc1a91b4d11f183ca45b38560efa0885535a (commit)
       via  4b34e32ea32a4bcdfc96b078dbb14b7a7b8e6c60 (commit)
       via  4933c8a8e1709fb932751ae9be2b45494be2c4cb (commit)
       via  685305a90b2734de2bf1093b41f4c279e36532bb (commit)
       via  ccb30aeec60c8aeb5ea2308500011109b19c0959 (commit)
       via  ba4a73fbc0d45dcf5cc2cba820bd45305f3c7be5 (commit)
       via  3b7313b819c55485b7435605f7306dfd5d499438 (commit)
       via  d30459df7f969c675c1f6b9d0abf2f44705db35f (commit)
       via  f88b0c4723dc59a3be74fc712f1a2b759d09690b (commit)
       via  f8adb760041bb4973da146e47de9de8eb53fab0e (commit)
       via  621f416588da2a09a929cbb1189c83750063c693 (commit)
       via  d1b8321ab0656150039cccbe545c0a5b33c39ecf (commit)
       via  1bea277b343a541e0c481f93e6200c00feff1d2c (commit)
       via  7f1357638fa7c85b5d0426d240b7130ea9eb181d (commit)
       via  7e26615f8d72e0c95630cdfb0f8ea57c0e729978 (commit)
       via  6e812af73cb125e810e825d213a24ab3ed50f42c (commit)
      from  01e96570df7dacc2384ae5e76276dd43baf0420d (commit)

http://gitweb.samba.org/?p=obnox/samba-ctdb.git;a=shortlog;h=v3-2-ctdb


- Log -----------------------------------------------------------------
commit a19b56ddc07866bbcbb92e9e79b23cc440ef49e2
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 02:59:07 2009 +0100

    s3:registry: tighten the subkey loop in reg_deletekey_recursive()
    
    and loop from the end to the beginning so that we don't need
    to rehash the subkeys...
    
    This gets "net conf drop" with 2000 shares down to 14 seconds
    on my box.
    
    Michael

commit dbf68cf481f32d4b58b438326179d4ceeb96c784
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 02:57:59 2009 +0100

    s3:registry: use delete_reg_subkey() in reg_deletekey()
    
    This further speeds up net conf drop.
    
    Michael

commit 5951a13b24425ed1e6ed58228a74c317a665178e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 02:56:50 2009 +0100

    s3:registry: implement delete_subkey in the smbconf backend
    
    delegating the call to the db backend
    
    Michael

commit 19bc272445780c131c8c48092f5f3984b4864839
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 02:56:00 2009 +0100

    s3:registry: implement delete_subkey in the db backend
    
    Michael

commit 91c84b8c2218d1d1ec435aae59e2320bffb6be9f
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 02:54:50 2009 +0100

    s3:registry: add a delete_subkey method to the backend ops.
    
    This is to provide a more atomic means of deleting a subkey of a key.
    
    Michael

commit b2005f1df0ea3212c8fef0d97a7f9d42d95651c5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 01:43:58 2009 +0100

    s3:registry: refactor deletion of various subkey lists out of regdb_store_keys()
    
    Micheal

commit 2033484538b39246c7bb2c575fe768b113ee80b5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 01:22:03 2009 +0100

    s3:registry: streamline and cleanup regdb_set_secdesc() somewhat.
    
    Michael

commit e8e1835175c37a982b6856611f17a3cf0daa8251
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 26 01:16:07 2009 +0100

    s3:registry: refactor deletion of value/secdesc/subkey list tdb records out
    
    of regdb_store_values().
    
    Michael

commit 14c981580540fcb0029fc7b72bc0591e63418479
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 23:13:07 2009 +0100

    s3:registry: streamline reg_deletekey() somewhat.
    
    use W_ERROR_... macros and separate assignments from checks
    
    Michael

commit a97ff02ed0dc502c3ba1a800bffae0d2573171a8
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 22:06:47 2009 +0100

    s3:registry: use create_reg_subkey() in reg_createkey().
    
    Instead of calling store_reg_keys()
    
    On my box, importing 2000 shares into an empty smbconf key
    now takes some 32 seconds.
    
    Michael

commit 1dbceb8e1c4f2c652bdfc15eee1e9b6b451eb2a8
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 22:04:58 2009 +0100

    s3:registry: implement create_subkey for the smbconf backend
    
    by delegating to the db backend
    
    Michael

commit 41967398f76cd0eb4709b7b45419684665d1e7d2
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 22:04:07 2009 +0100

    s3:registry: implement create_subkey for the db backend.
    
    Michael

commit 7bed6fb33ea8c7fb88ae9482240199ceec8862b1
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 21:59:54 2009 +0100

    s3:registry: add a create_subkey method to the backend ops.
    
    This is to provide a more atomic means of adding a subkey of a key.
    
    Michael

commit 45f8e1872f18e7fe2a9c8c625c5d60afa77b5aee
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 16:55:28 2009 +0100

    source/include/nt_status.h: add macro W_ERROR_NOT_OK_GOTO(x, y)
    
    a goto destination can be specified as a second parameter.
    
    Michael

commit d80dad986128c8500fcdf683f2a3df330c0ca850
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 16:53:05 2009 +0100

    s3: move definition of W_ERROR_NOT_OK_GOTO_DONE down to nt_status.h
    
    where all the other W_ERROR_xyz macros are found as well.
    
    Michael

commit 03b36942f8e27c847b1ea683e71612db6a2ef2b2
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 14:49:30 2009 +0100

    s3:net rpc registry: use regsubkey_ctr_init() instead of using talloc directly.
    
    Michael

commit 735b76032e43808a52744b83cea02582500e6acf
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 09:53:16 2009 +0100

    s3:registry: hash the list of subkeys in the regsubkey_ctr
    
    This removes many loops over all the arrays
    (from regsubkey_ctr_key_exists) and thus
    reduces "net conf drop" from 1m55 to 48seconds
    and "net conf import" from 1m55 to 58 seconds
    for 2000 shares on my box.
    
    Michael

commit de0ec0e244224b85f2d69ffe547186c0df87a654
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 00:33:24 2009 +0100

    s3:registry: remove definition of regsubkey_ctr from the surface.
    
    All access is now through accessor functions in reg_objects.c
    This allows for performance tuning under the hood in the next step.
    
    Michael

commit b6d8239c188c360ba2431e577a8bf18e9d8d532d
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 25 00:32:21 2009 +0100

    s3:profiles: use regsubkey_ctr_init() instead of using talloc directly.
    
    Michael

commit f8a30455a7f04133a759bc98a5598af70e508e4f
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:28:48 2009 +0100

    s3:registry: use regsubkey_ctr_init() in reg_eventlog.c
    
    Michael

commit dde3bc1a91b4d11f183ca45b38560efa0885535a
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:23:04 2009 +0100

    s3:services_db: use regsubkey_ctr_init() instead of using talloc directly
    
    Michael

commit 4b34e32ea32a4bcdfc96b078dbb14b7a7b8e6c60
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:19:35 2009 +0100

    s3:registry: use regsubkey_ctr_get_seqnum() in reg_backend_db.c
    
    Michael

commit 4933c8a8e1709fb932751ae9be2b45494be2c4cb
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:19:08 2009 +0100

    s3:registry: use regsubkey_ctr_set_seqnum() in reg_backend_db.c
    
    Michael

commit 685305a90b2734de2bf1093b41f4c279e36532bb
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:18:20 2009 +0100

    s3:registry: use regsubkey_ctr_init() in reg_backend_db.c
    
    instead of using talloc directly.
    
    Michael

commit ccb30aeec60c8aeb5ea2308500011109b19c0959
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:17:05 2009 +0100

    s3:registry: use regsubkey_ctr_init() in reg_api.c
    
    instead of using talloc on struct regsubkey_ctr.
    
    Michael

commit ba4a73fbc0d45dcf5cc2cba820bd45305f3c7be5
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:15:55 2009 +0100

    s3:registry: add regsubkey_ctr_get_seqnum() to hide implementation
    
    Michael

commit 3b7313b819c55485b7435605f7306dfd5d499438
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 23:10:35 2009 +0100

    s3:registry: add regsubkey_ctr_set_seqnum to hide implementation from caller.
    
    Michael

commit d30459df7f969c675c1f6b9d0abf2f44705db35f
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 22:43:47 2009 +0100

    s3:registry: add a regsubkey_ctr_init function for allocating a regsubkey_ctr
    
    Michael

commit f88b0c4723dc59a3be74fc712f1a2b759d09690b
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 22:41:40 2009 +0100

    s3:registry: fix a comment
    
    Michael

commit f8adb760041bb4973da146e47de9de8eb53fab0e
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 22:16:40 2009 +0100

    s3:registry: don't directly access key->subkeys->subkeys[] in reg_backend_db.c
    
    Use the reg_objects accessor regsubkey_ctr_specific_key() instead.
    
    Michael

commit 621f416588da2a09a929cbb1189c83750063c693
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 21:12:26 2009 +0100

    s3:registry: don't directly access key->subkeys->subkeys[] in reg_api.c
    
    Use the reg_objects accessor regsubkey_ctr_specific_key() instead.
    
    Michael

commit d1b8321ab0656150039cccbe545c0a5b33c39ecf
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 17:42:50 2009 +0100

    s3:registry: don't directly access key->subkeys->num_subkeys in reg_backend_db.
    
    Use the reg_objects api instead.
    
    Michael

commit 1bea277b343a541e0c481f93e6200c00feff1d2c
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 17:30:23 2009 +0100

    s3:registry: don't directly access key->subkeys->num_subkeys in reg_api.c
    
    Use the reg_objects api instead.
    
    Michael

commit 7f1357638fa7c85b5d0426d240b7130ea9eb181d
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 15:19:18 2009 +0100

    s3:registry: replace typedef "REGSUBKEY_CTR" by "struct regsubkey_ctr"
    
    This paves the way for hiding the typedef and the implementation from the
    surface.
    
    Michael

commit 7e26615f8d72e0c95630cdfb0f8ea57c0e729978
Author: Michael Adam <obnox at samba.org>
Date:   Tue Feb 24 17:51:09 2009 +0100

    Revert "Fix a O(n^2) algorithm in regdb_fetch_keys()"
    
    This reverts commit a13f065bad0f4d21a67e68b743f17f45bf0a4691.
    
    This fix is reverted, because the speedup is going to move
    further down into reg_objects.c. The unsorted list of subkey names
    is going to be indexed: This O(n^2) search bites us in more places.
    This re-establishes the abstraction of reg_objects.c.
    
    Michael

commit 6e812af73cb125e810e825d213a24ab3ed50f42c
Author: Günther Deschner <gd at samba.org>
Date:   Tue Apr 29 20:10:17 2008 +0200

    errors: add WERR_NOT_FOUND.
    
    Guenther
    (This used to be commit b9ac03bdfa5763c713674acd966ab5d4371992a5)
    (cherry picked from commit d0411c19dc847919b2a7941d91d2605c885e2b62)
    
    Signed-off-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source/include/doserr.h                       |    1 +
 source/include/nt_status.h                    |   12 +
 source/include/reg_objects.h                  |   16 +-
 source/include/regfio.h                       |    2 +-
 source/libnet/libnet_join.c                   |    6 -
 source/libsmb/doserr.c                        |    1 +
 source/registry/reg_api.c                     |  143 ++++-----
 source/registry/reg_backend_current_version.c |    2 +-
 source/registry/reg_backend_db.c              |  411 +++++++++++++++++--------
 source/registry/reg_backend_hkpt_params.c     |    2 +-
 source/registry/reg_backend_netlogon_params.c |    2 +-
 source/registry/reg_backend_perflib.c         |    2 +-
 source/registry/reg_backend_printing.c        |   20 +-
 source/registry/reg_backend_prod_options.c    |    2 +-
 source/registry/reg_backend_shares.c          |    4 +-
 source/registry/reg_backend_smbconf.c         |   16 +-
 source/registry/reg_backend_tcpip_params.c    |    2 +-
 source/registry/reg_dispatcher.c              |   24 ++-
 source/registry/reg_eventlog.c                |   18 +-
 source/registry/reg_objects.c                 |  175 +++++++++--
 source/registry/regfio.c                      |    2 +-
 source/services/services_db.c                 |   12 +-
 source/utils/net_rpc_registry.c               |   11 +-
 source/utils/profiles.c                       |    8 +-
 24 files changed, 592 insertions(+), 302 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/doserr.h b/source/include/doserr.h
index d4fefb2..44ce739 100644
--- a/source/include/doserr.h
+++ b/source/include/doserr.h
@@ -202,6 +202,7 @@
 #define WERR_SERVICE_ALREADY_RUNNING W_ERROR(1056)
 #define WERR_SERVICE_DISABLED W_ERROR(1058)
 #define WERR_SERVICE_NEVER_STARTED W_ERROR(1077)
+#define WERR_NOT_FOUND W_ERROR(1168)
 #define WERR_INVALID_COMPUTER_NAME W_ERROR(1210)
 #define WERR_INVALID_DOMAINNAME W_ERROR(1212)
 #define WERR_MACHINE_LOCKED W_ERROR(1271)
diff --git a/source/include/nt_status.h b/source/include/nt_status.h
index 30174e4..c96ed3c 100644
--- a/source/include/nt_status.h
+++ b/source/include/nt_status.h
@@ -83,6 +83,18 @@ typedef uint32 WERROR;
 	}\
 } while (0)
 
+#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \
+	if (!W_ERROR_IS_OK(x)) {\
+		goto done;\
+	}\
+} while (0)
+
+#define W_ERROR_NOT_OK_GOTO(x, y) do {\
+	if (!W_ERROR_IS_OK(x)) {\
+		goto y;\
+	}\
+} while(0)
+
 /* The top byte in an NTSTATUS code is used as a type field.
  * Windows only uses value 0xC0 as an indicator for an NT error
  * and 0x00 for success.
diff --git a/source/include/reg_objects.h b/source/include/reg_objects.h
index 5d6c5a1..f610a02 100644
--- a/source/include/reg_objects.h
+++ b/source/include/reg_objects.h
@@ -66,11 +66,7 @@ typedef struct {
 
 /* container for registry subkey names */
 
-typedef struct {
-	uint32          num_subkeys;
-	char            **subkeys;
-	int seqnum;
-} REGSUBKEY_CTR;
+struct regsubkey_ctr;
 
 /*
  *
@@ -125,9 +121,11 @@ typedef struct {
  
 typedef struct {
 	/* functions for enumerating subkeys and values */	
-	int 	(*fetch_subkeys)( const char *key, REGSUBKEY_CTR *subkeys);
+	int 	(*fetch_subkeys)( const char *key, struct regsubkey_ctr *subkeys);
 	int 	(*fetch_values) ( const char *key, REGVAL_CTR *val );
-	bool 	(*store_subkeys)( const char *key, REGSUBKEY_CTR *subkeys );
+	bool 	(*store_subkeys)( const char *key, struct regsubkey_ctr *subkeys );
+	WERROR	(*create_subkey)(const char *key, const char *subkey);
+	WERROR	(*delete_subkey)(const char *key, const char *subkey);
 	bool 	(*store_values)( const char *key, REGVAL_CTR *val );
 	bool	(*reg_access_check)( const char *keyname, uint32 requested,
 				     uint32 *granted,
@@ -136,7 +134,7 @@ typedef struct {
 			      struct security_descriptor **psecdesc);
 	WERROR (*set_secdesc)(const char *key,
 			      struct security_descriptor *sec_desc);
-	bool	(*subkeys_need_update)(REGSUBKEY_CTR *subkeys);
+	bool	(*subkeys_need_update)(struct regsubkey_ctr *subkeys);
 	bool	(*values_need_update)(REGVAL_CTR *values);
 } REGISTRY_OPS;
 
@@ -157,7 +155,7 @@ typedef struct _RegistryKey {
 
 struct registry_key {
 	REGISTRY_KEY *key;
-	REGSUBKEY_CTR *subkeys;
+	struct regsubkey_ctr *subkeys;
 	REGVAL_CTR *values;
 	struct nt_user_token *token;
 };
diff --git a/source/include/regfio.h b/source/include/regfio.h
index 63516a3..0e957d5 100644
--- a/source/include/regfio.h
+++ b/source/include/regfio.h
@@ -214,7 +214,7 @@ int           regfio_close( REGF_FILE *r );
 REGF_NK_REC*  regfio_rootkey( REGF_FILE *file );
 REGF_NK_REC*  regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk );
 REGF_NK_REC*  regfio_write_key ( REGF_FILE *file, const char *name,
-                                 REGVAL_CTR *values, REGSUBKEY_CTR *subkeys,
+                                 REGVAL_CTR *values, struct regsubkey_ctr *subkeys,
                                  SEC_DESC *sec_desc, REGF_NK_REC *parent );
 
 
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index 1f4d6a6..752c011 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -50,12 +50,6 @@
 #define LIBNET_UNJOIN_OUT_DUMP_CTX(ctx, r) \
 	LIBNET_UNJOIN_DUMP_CTX(ctx, r, NDR_OUT)
 
-#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \
-	if (!W_ERROR_IS_OK(x)) {\
-		goto done;\
-	}\
-} while (0)
-
 /****************************************************************
 ****************************************************************/
 
diff --git a/source/libsmb/doserr.c b/source/libsmb/doserr.c
index 7a7ccee..450d6ee 100644
--- a/source/libsmb/doserr.c
+++ b/source/libsmb/doserr.c
@@ -104,6 +104,7 @@ werror_code_struct dos_errs[] =
 	{ "WERR_NO_SUCH_SERVICE", WERR_NO_SUCH_SERVICE },
 	{ "WERR_SERVICE_DISABLED", WERR_SERVICE_DISABLED },
 	{ "WERR_SERVICE_NEVER_STARTED", WERR_SERVICE_NEVER_STARTED },
+	{ "WERR_NOT_FOUND", WERR_NOT_FOUND },
 	{ "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE},
 	{ "WERR_INVALID_FLAGS", WERR_INVALID_FLAGS},
 	{ "WERR_PASSWORD_MUST_CHANGE", WERR_PASSWORD_MUST_CHANGE },
diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c
index 4db4f3c..c49ee03 100644
--- a/source/registry/reg_api.c
+++ b/source/registry/reg_api.c
@@ -94,15 +94,16 @@ static WERROR fill_value_cache(struct registry_key *key)
 
 static WERROR fill_subkey_cache(struct registry_key *key)
 {
+	WERROR werr;
+
 	if (key->subkeys != NULL) {
 		if (!reg_subkeys_need_update(key->key, key->subkeys)) {
 			return WERR_OK;
 		}
 	}
 
-	if (!(key->subkeys = TALLOC_ZERO_P(key, REGSUBKEY_CTR))) {
-		return WERR_NOMEM;
-	}
+	werr = regsubkey_ctr_init(key, &(key->subkeys));
+	W_ERROR_NOT_OK_RETURN(werr);
 
 	if (fetch_reg_keys(key->key, key->subkeys) == -1) {
 		TALLOC_FREE(key->subkeys);
@@ -127,7 +128,7 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
 	WERROR     	result = WERR_OK;
 	struct registry_key *regkey;
 	REGISTRY_KEY *key;
-	REGSUBKEY_CTR	*subkeys = NULL;
+	struct regsubkey_ctr	*subkeys = NULL;
 
 	DEBUG(7,("regkey_open_onelevel: name = [%s]\n", name));
 
@@ -193,8 +194,8 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
 	/* check if the path really exists; failed is indicated by -1 */
 	/* if the subkey count failed, bail out */
 
-	if ( !(subkeys = TALLOC_ZERO_P( key, REGSUBKEY_CTR )) ) {
-		result = WERR_NOMEM;
+	result = regsubkey_ctr_init(key, &subkeys);
+	if (!W_ERROR_IS_OK(result)) {
 		goto done;
 	}
 
@@ -308,11 +309,13 @@ WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
 		return err;
 	}
 
-	if (idx >= key->subkeys->num_subkeys) {
+	if (idx >= regsubkey_ctr_numkeys(key->subkeys)) {
 		return WERR_NO_MORE_ITEMS;
 	}
 
-	if (!(*name = talloc_strdup(mem_ctx, key->subkeys->subkeys[idx]))) {
+	if (!(*name = talloc_strdup(mem_ctx,
+			regsubkey_ctr_specific_key(key->subkeys, idx))))
+	{
 		return WERR_NOMEM;
 	}
 
@@ -406,11 +409,12 @@ WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
 	}
 
 	max_len = 0;
-	for (i=0; i<key->subkeys->num_subkeys; i++) {
-		max_len = MAX(max_len, strlen(key->subkeys->subkeys[i]));
+	for (i=0; i< regsubkey_ctr_numkeys(key->subkeys); i++) {
+		max_len = MAX(max_len,
+			strlen(regsubkey_ctr_specific_key(key->subkeys, i)));
 	}
 
-	*num_subkeys = key->subkeys->num_subkeys;
+	*num_subkeys = regsubkey_ctr_numkeys(key->subkeys);
 	*max_subkeylen = max_len;
 	*max_subkeysize = 0;	/* Class length? */
 
@@ -520,14 +524,8 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
 	err = fill_subkey_cache(create_parent);
 	if (!W_ERROR_IS_OK(err)) goto done;
 
-	err = regsubkey_ctr_addkey(create_parent->subkeys, path);
-	if (!W_ERROR_IS_OK(err)) goto done;
-
-	if (!store_reg_keys(create_parent->key, create_parent->subkeys)) {
-		TALLOC_FREE(create_parent->subkeys);
-		err = WERR_REG_IO_FAILURE;
-		goto done;
-	}
+	err = create_reg_subkey(key->key, path);
+	W_ERROR_NOT_OK_GOTO_DONE(err);
 
 	/*
 	 * Now open the newly created key
@@ -546,40 +544,36 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
 WERROR reg_deletekey(struct registry_key *parent, const char *path)
 {
 	WERROR err;
-	TALLOC_CTX *mem_ctx;
 	char *name, *end;
-	int num_subkeys;
 	struct registry_key *tmp_key, *key;
+	TALLOC_CTX *mem_ctx = talloc_stackframe();
 
-	if (!(mem_ctx = talloc_init("reg_createkey"))) return WERR_NOMEM;
-
-	if (!(name = talloc_strdup(mem_ctx, path))) {
+	name = talloc_strdup(mem_ctx, path);
+	if (name == NULL) {
 		err = WERR_NOMEM;
-		goto error;
+		goto done;
 	}
 
 	/* check if the key has subkeys */
 	err = reg_openkey(mem_ctx, parent, name, REG_KEY_READ, &key);
-	if (!W_ERROR_IS_OK(err)) {
-		goto error;
-	}
-	if (!W_ERROR_IS_OK(err = fill_subkey_cache(key))) {
-		goto error;
-	}
-	if (key->subkeys->num_subkeys > 0) {
+	W_ERROR_NOT_OK_GOTO_DONE(err);
+
+	err = fill_subkey_cache(key);
+	W_ERROR_NOT_OK_GOTO_DONE(err);
+
+	if (regsubkey_ctr_numkeys(key->subkeys) > 0) {
 		err = WERR_ACCESS_DENIED;
-		goto error;
+		goto done;
 	}
 
 	/* no subkeys - proceed with delete */
-	if ((end = strrchr(name, '\\')) != NULL) {
+	end = strrchr(name, '\\');
+	if (end != NULL) {
 		*end = '\0';
 
 		err = reg_openkey(mem_ctx, parent, name,
 				  SEC_RIGHTS_CREATE_SUBKEY, &tmp_key);
-		if (!W_ERROR_IS_OK(err)) {
-			goto error;
-		}
+		W_ERROR_NOT_OK_GOTO_DONE(err);
 
 		parent = tmp_key;
 		name = end+1;
@@ -587,31 +581,12 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path)
 
 	if (name[0] == '\0') {
 		err = WERR_INVALID_PARAM;
-		goto error;
-	}
-
-	if (!W_ERROR_IS_OK(err = fill_subkey_cache(parent))) {
-		goto error;
-	}
-
-	num_subkeys = parent->subkeys->num_subkeys;
-
-	if (regsubkey_ctr_delkey(parent->subkeys, name) == num_subkeys) {
-		err = WERR_BADFILE;
-		goto error;
-	}
-
-	if (!store_reg_keys(parent->key, parent->subkeys)) {
-		TALLOC_FREE(parent->subkeys);
-		err = WERR_REG_IO_FAILURE;
-		goto error;
+		goto done;
 	}
 
-	regkey_set_secdesc(key->key, NULL);
-
-	err = WERR_OK;
+	err = delete_reg_subkey(parent->key, name);
 
- error:
+done:
 	TALLOC_FREE(mem_ctx);
 	return err;
 }
@@ -726,7 +701,7 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
 	REGF_NK_REC *subkey;
 	REGISTRY_KEY registry_key;
 	REGVAL_CTR *values;
-	REGSUBKEY_CTR *subkeys;
+	struct regsubkey_ctr *subkeys;
 	int i;
 	char *path = NULL;
 	WERROR result = WERR_OK;
@@ -748,10 +723,8 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
 
 	/* now start parsing the values and subkeys */
 
-	subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR);
-	if (subkeys == NULL) {
-		return WERR_NOMEM;
-	}
+	result = regsubkey_ctr_init(regfile->mem_ctx, &subkeys);
+	W_ERROR_NOT_OK_RETURN(result);
 
 	values = TALLOC_ZERO_P(subkeys, REGVAL_CTR);
 	if (values == NULL) {
@@ -767,7 +740,7 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
 				    (key->values[i].data_size & ~VK_DATA_IN_OFFSET));
 	}
 
-	/* copy subkeys into the REGSUBKEY_CTR */
+	/* copy subkeys into the struct regsubkey_ctr */
 
 	key->subkey_index = 0;
 	while ((subkey = regfio_fetch_subkey( regfile, key ))) {
@@ -861,7 +834,7 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath,
 {
 	REGF_NK_REC *key;
 	REGVAL_CTR *values;
-	REGSUBKEY_CTR *subkeys;
+	struct regsubkey_ctr *subkeys;
 	int i, num_subkeys;
 	char *key_tmp = NULL;
 	char *keyname, *parentpath;
@@ -909,10 +882,8 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath,
 
 	/* lookup the values and subkeys */
 
-	subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR);
-	if (subkeys == NULL) {
-		return WERR_NOMEM;
-	}
+	result = regsubkey_ctr_init(regfile->mem_ctx, &subkeys);
+	W_ERROR_NOT_OK_RETURN(result);
 
 	values = TALLOC_ZERO_P(subkeys, REGVAL_CTR);
 	if (values == NULL) {
@@ -1091,6 +1062,7 @@ static WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
 	WERROR werr = WERR_OK;
 	struct registry_key *key;
 	char *subkey_name = NULL;
+	uint32 i;
 
 	mem_ctx = talloc_new(ctx);
 	if (mem_ctx == NULL) {
@@ -1104,25 +1076,21 @@ static WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
 		goto done;
 	}
 
-	while (W_ERROR_IS_OK(werr = reg_enumkey(mem_ctx, key, 0,
-						&subkey_name, NULL)))
-	{
+	werr = fill_subkey_cache(key);
+	W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+	/*
+	 * loop from top to bottom for perfomance:
+	 * this way, we need to rehash the regsubkey containers less
+	 */
+	for (i = regsubkey_ctr_numkeys(key->subkeys) ; i > 0; i--) {
+		subkey_name = regsubkey_ctr_specific_key(key->subkeys, i-1);
 		werr = reg_deletekey_recursive_internal(mem_ctx, key,
-							subkey_name,
-							true);
-		if (!W_ERROR_IS_OK(werr)) {
-			goto done;
-		}
-	}
-	if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
-		DEBUG(1, ("reg_deletekey_recursive_internal: "
-			  "Error enumerating subkeys: %s\n",
-			  dos_errstr(werr)));
-		goto done;
+					subkey_name,
+					true);
+		W_ERROR_NOT_OK_GOTO_DONE(werr);
 	}
 
-	werr = WERR_OK;
-
 	if (del_key) {
 		/* now delete the actual key */
 		werr = reg_deletekey(parent, path);
@@ -1151,6 +1119,9 @@ static WERROR reg_deletekey_recursive_trans(TALLOC_CTX *ctx,
 	werr = reg_deletekey_recursive_internal(ctx, parent, path, del_key);
 
 	if (!W_ERROR_IS_OK(werr)) {
+		DEBUG(1, (__location__ " failed to delete key '%s' from key "
+			  "'%s': %s\n", path, parent->key->name,
+			  dos_errstr(werr)));
 		werr = regdb_transaction_cancel();
 		if (!W_ERROR_IS_OK(werr)) {
 			DEBUG(0, ("reg_deletekey_recursive_trans: "
diff --git a/source/registry/reg_backend_current_version.c b/source/registry/reg_backend_current_version.c
index 04cc0eb..f76840e 100644
--- a/source/registry/reg_backend_current_version.c
+++ b/source/registry/reg_backend_current_version.c
@@ -70,7 +70,7 @@ static int current_version_fetch_values(const char *key, REGVAL_CTR *values)
 }
 
 static int current_version_fetch_subkeys(const char *key,
-					 REGSUBKEY_CTR *subkey_ctr)
+					 struct regsubkey_ctr *subkey_ctr)
 {
 	return regdb_ops.fetch_subkeys(key, subkey_ctr);
 }
diff --git a/source/registry/reg_backend_db.c b/source/registry/reg_backend_db.c
index 6a00df7..40b1525 100644
--- a/source/registry/reg_backend_db.c
+++ b/source/registry/reg_backend_db.c
@@ -95,7 +95,7 @@ static WERROR init_registry_key_internal(const char *add_path)
 	char *remaining = NULL;
 	char *keyname;
 	char *subkeyname;
-	REGSUBKEY_CTR *subkeys;
+	struct regsubkey_ctr *subkeys;
 	const char *p, *p2;
 
 	DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path));
@@ -159,9 +159,9 @@ static WERROR init_registry_key_internal(const char *add_path)
 		 * since we are about to update the record.
 		 * We just want any subkeys already present */
 
-		if (!(subkeys = TALLOC_ZERO_P(frame, REGSUBKEY_CTR))) {
+		werr = regsubkey_ctr_init(frame, &subkeys);
+		if (!W_ERROR_IS_OK(werr)) {
 			DEBUG(0,("talloc() failure!\n"));
-			werr = WERR_NOMEM;
 			goto fail;
 		}
 
@@ -502,13 +502,97 @@ int regdb_get_seqnum(void)
 	return regdb->get_seqnum(regdb);
 }
 
+
+static WERROR regdb_delete_key_with_prefix(const char *keyname,
+					   const char *prefix)
+{
+	char *path;
+	WERROR werr = WERR_NOMEM;
+	TALLOC_CTX *mem_ctx = talloc_stackframe();
+
+	if (keyname == NULL) {
+		werr = WERR_INVALID_PARAM;
+		goto done;
+	}
+
+	if (prefix == NULL) {
+		path = discard_const_p(char, keyname);
+	} else {
+		path = talloc_asprintf(mem_ctx, "%s/%s", prefix, keyname);
+		if (path == NULL) {
+			goto done;
+		}
+	}
+
+	path = normalize_reg_path(mem_ctx, path);
+	if (path == NULL) {
+		goto done;
+	}
+
+	werr = ntstatus_to_werror(dbwrap_delete_bystring(regdb, path));
+
+	/* treat "not" found" as ok */
+	if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) {
+		werr = WERR_OK;
+	}
+
+done:
+	talloc_free(mem_ctx);
+	return werr;
+}
+
+


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list