Browse Source

tdb2: remove nesting support.

We don't actually support it, so take it away for the moment.  If you
try to nmest you get a TDB_LOG_USE_ERROR message.
Rusty Russell 15 years ago
parent
commit
02d83e6adf
4 changed files with 5 additions and 14 deletions
  1. 1 5
      ccan/tdb2/tdb.c
  2. 1 2
      ccan/tdb2/tdb2.h
  3. 2 6
      ccan/tdb2/test/run-tdb_errorstr.c
  4. 1 1
      ccan/tdb2/transaction.c

+ 1 - 5
ccan/tdb2/tdb.c

@@ -324,7 +324,7 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
 	/* Is it already in the open list?  If so, fail. */
 	if (tdb_already_open(st.st_dev, st.st_ino)) {
 		/* FIXME */
-		tdb_logerr(tdb, TDB_ERR_NESTING, TDB_LOG_USE_ERROR,
+		tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_USE_ERROR,
 			   "tdb_open: %s (%d,%d) is already open in this"
 			   " process",
 			   name, (int)st.st_dev, (int)st.st_ino);
@@ -374,9 +374,6 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
 		case TDB_ERR_EINVAL:
 			saved_errno = EINVAL;
 			break;
-		case TDB_ERR_NESTING:
-			saved_errno = EBUSY;
-			break;
 		default:
 			saved_errno = EINVAL;
 			break;
@@ -702,7 +699,6 @@ const char *tdb_errorstr(const struct tdb_context *tdb)
 	case TDB_ERR_LOCK: return "Locking error";
 	case TDB_ERR_OOM: return "Out of memory";
 	case TDB_ERR_EXISTS: return "Record exists";
-	case TDB_ERR_NESTING: return "Transaction already started";
 	case TDB_ERR_EINVAL: return "Invalid parameter";
 	case TDB_ERR_NOEXIST: return "Record does not exist";
 	case TDB_ERR_RDONLY: return "write not permitted";

+ 1 - 2
ccan/tdb2/tdb2.h

@@ -57,12 +57,11 @@ extern "C" {
 #define TDB_NOSYNC   64 /* don't use synchronous transactions */
 #define TDB_SEQNUM   128 /* maintain a sequence number */
 #define TDB_VOLATILE   256 /* Activate the per-hashchain freelist, default 5 */
-#define TDB_ALLOW_NESTING 512 /* Allow transactions to nest */
 
 /* error codes */
 enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
 		TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOEXIST,
-		TDB_ERR_EINVAL, TDB_ERR_RDONLY, TDB_ERR_NESTING };
+		TDB_ERR_EINVAL, TDB_ERR_RDONLY };
 
 /* flags for tdb_summary. Logical or to combine. */
 enum tdb_summary_flags { TDB_SUMMARY_HISTOGRAMS = 1 };

+ 2 - 6
ccan/tdb2/test/run-tdb_errorstr.c

@@ -11,23 +11,19 @@ int main(int argc, char *argv[])
 {
 	struct tdb_context *tdb;
 
-	plan_tests(1 + TDB_ERR_NESTING + 2);
+	plan_tests(1 + TDB_ERR_RDONLY + 2);
 	tdb = tdb_open("run-tdb_errorstr.tdb", TDB_DEFAULT,
 		       O_RDWR|O_CREAT|O_TRUNC, 0600, NULL);
 	ok1(tdb);
 	if (tdb) {
 		enum TDB_ERROR err;
-		for (err = TDB_SUCCESS; err <= TDB_ERR_NESTING; err++) {
+		for (err = TDB_SUCCESS; err <= TDB_ERR_RDONLY; err++) {
 			tdb->ecode = err;
 			switch (err) {
 			case TDB_SUCCESS:
 				ok1(!strcmp(tdb_errorstr(tdb),
 					    "Success"));
 				break;
-			case TDB_ERR_NESTING:
-				ok1(!strcmp(tdb_errorstr(tdb),
-					    "Transaction already started"));
-				break;
 			case TDB_ERR_IO:
 				ok1(!strcmp(tdb_errorstr(tdb),
 					    "IO Error"));

+ 1 - 1
ccan/tdb2/transaction.c

@@ -509,7 +509,7 @@ int tdb_transaction_start(struct tdb_context *tdb)
 
 	/* cope with nested tdb_transaction_start() calls */
 	if (tdb->transaction != NULL) {
-		tdb_logerr(tdb, TDB_ERR_NESTING, TDB_LOG_USE_ERROR,
+		tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_USE_ERROR,
 			   "tdb_transaction_start:"
 			   " already inside transaction");
 		return -1;