summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-02-17 23:41:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:03 -0500
commita2fd13e8aa25cd813a0c86ebbb94bc47a9a42823 (patch)
tree1fe2cc2f6d9815a20e90916df99dca8fe728c21c /source3
parentbadbfe0aaed065d627626a2305a1bde410d8c29e (diff)
downloadsamba-a2fd13e8aa25cd813a0c86ebbb94bc47a9a42823.tar.gz
samba-a2fd13e8aa25cd813a0c86ebbb94bc47a9a42823.tar.bz2
samba-a2fd13e8aa25cd813a0c86ebbb94bc47a9a42823.zip
r21412: The last patch also incremented the seqnum when tdb_store failed. Not as bad
as not doing it at all, but needs fixing. Also simplify the logic, I had missed the "goto out" at the end of the function. Volker (This used to be commit 101789946130d51f3092d19f081071bdb5e43c21)
Diffstat (limited to 'source3')
-rw-r--r--source3/tdb/common/tdb.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/source3/tdb/common/tdb.c b/source3/tdb/common/tdb.c
index 9760ceebf5..248acb7374 100644
--- a/source3/tdb/common/tdb.c
+++ b/source3/tdb/common/tdb.c
@@ -257,7 +257,7 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
u32 hash;
tdb_off_t rec_ptr;
char *p = NULL;
- int ret = 0;
+ int ret = -1;
if (tdb->read_only || tdb->traverse_read) {
tdb->ecode = TDB_ERR_RDONLY;
@@ -277,8 +277,10 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
}
} else {
/* first try in-place update, on modify or replace. */
- if (tdb_update_hash(tdb, key, hash, dbuf) == 0)
- goto out;
+ if (tdb_update_hash(tdb, key, hash, dbuf) == 0) {
+ ret = 0;
+ goto fail; /* Well, not really failed */
+ }
if (tdb->ecode == TDB_ERR_NOEXIST &&
flag == TDB_MODIFY) {
/* if the record doesn't exist and we are in TDB_MODIFY mode then
@@ -328,15 +330,15 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
goto fail;
}
- out:
- tdb_increment_seqnum(tdb);
+ ret = 0;
+ fail:
+ if (ret == 0) {
+ tdb_increment_seqnum(tdb);
+ }
SAFE_FREE(p);
tdb_unlock(tdb, BUCKET(hash), F_WRLCK);
return ret;
-fail:
- ret = -1;
- goto out;
}