svn commit: samba r21412 - in branches: SAMBA_3_0/source/tdb/common SAMBA_3_0_25/source/tdb/common SAMBA_4_0/source/lib/tdb/common

vlendec at samba.org vlendec at samba.org
Sat Feb 17 23:41:46 GMT 2007


Author: vlendec
Date: 2007-02-17 23:41:45 +0000 (Sat, 17 Feb 2007)
New Revision: 21412

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21412

Log:
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


Modified:
   branches/SAMBA_3_0/source/tdb/common/tdb.c
   branches/SAMBA_3_0_25/source/tdb/common/tdb.c
   branches/SAMBA_4_0/source/lib/tdb/common/tdb.c


Changeset:
Modified: branches/SAMBA_3_0/source/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_3_0/source/tdb/common/tdb.c	2007-02-17 23:38:57 UTC (rev 21411)
+++ branches/SAMBA_3_0/source/tdb/common/tdb.c	2007-02-17 23:41:45 UTC (rev 21412)
@@ -257,7 +257,7 @@
 	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 @@
 		}
 	} 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 @@
 		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;
 }
 
 

Modified: branches/SAMBA_3_0_25/source/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/common/tdb.c	2007-02-17 23:38:57 UTC (rev 21411)
+++ branches/SAMBA_3_0_25/source/tdb/common/tdb.c	2007-02-17 23:41:45 UTC (rev 21412)
@@ -257,7 +257,7 @@
 	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 @@
 		}
 	} 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 @@
 		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;
 }
 
 

Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2007-02-17 23:38:57 UTC (rev 21411)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2007-02-17 23:41:45 UTC (rev 21412)
@@ -257,7 +257,7 @@
 	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 @@
 		}
 	} 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 @@
 		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;
 }
 
 



More information about the samba-cvs mailing list