diff options
author | Michael Adam <obnox@samba.org> | 2009-07-09 12:54:16 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-07-15 14:01:56 +0200 |
commit | 109ea29b2c1a3bc752f9afda2c0010b9e675aa83 (patch) | |
tree | 4289f05635c7d22bb957202b1d60e4705e572cf9 /source3/registry | |
parent | 2d6dbcd0b13da469f8b7dc6ed65e51d91ce1ab9c (diff) | |
download | samba-109ea29b2c1a3bc752f9afda2c0010b9e675aa83.tar.gz samba-109ea29b2c1a3bc752f9afda2c0010b9e675aa83.tar.bz2 samba-109ea29b2c1a3bc752f9afda2c0010b9e675aa83.zip |
s3:registry: restructure logic of create_sorted_subkes() slightly
This makes it clearer to me, and it also makes it easier to
use the transaction retry wrapper in the next step.
Michael
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_backend_db.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 095b0c5b22..e0e234f7c6 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -1195,18 +1195,18 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname) werr = regsubkey_ctr_init(talloc_tos(), &ctr); if (!W_ERROR_IS_OK(werr)) { - goto fail; + goto commit; } res = regdb_fetch_keys_internal(regdb, key, ctr); if (res == -1) { - goto fail; + goto commit; } num_subkeys = regsubkey_ctr_numkeys(ctr); sorted_subkeys = talloc_array(ctr, char *, num_subkeys); if (sorted_subkeys == NULL) { - goto fail; + goto commit; } len = 4 + 4*num_subkeys; @@ -1215,7 +1215,7 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname) sorted_subkeys[i] = talloc_strdup_upper(sorted_subkeys, regsubkey_ctr_specific_key(ctr, i)); if (sorted_subkeys[i] == NULL) { - goto fail; + goto commit; } len += strlen(sorted_subkeys[i])+1; } @@ -1224,7 +1224,7 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname) buf = talloc_array(ctr, char, len); if (buf == NULL) { - goto fail; + goto commit; } p = buf + 4 + 4*num_subkeys; @@ -1242,21 +1242,17 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname) TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { /* - * Don't use a "goto fail;" here, this would commit the broken + * Don't use a "goto commit;" here, this would commit the broken * transaction. See below for an explanation. */ - if (regdb->transaction_cancel(regdb) == -1) { - smb_panic("create_sorted_subkeys: transaction_cancel " - "failed\n"); - } - TALLOC_FREE(ctr); - return false; + goto cancel; } result = true; - fail: + +commit: /* - * We only get here via the "goto fail" when we did not write anything + * We only get here via the "goto commit" when we did not write anything * yet. Using transaction_commit even in a failure case is necessary * because this (disposable) call might be nested in other * transactions. Doing a cancel here would destroy the possibility of @@ -1267,7 +1263,16 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname) "failed\n")); result = false; } + goto done; + +cancel: + if (regdb->transaction_cancel(regdb) == -1) { + smb_panic("create_sorted_subkeys: transaction_cancel " + "failed\n"); + } + result = false; +done: TALLOC_FREE(ctr); return result; } |