]> git.ozlabs.org Git - ccan/commitdiff
tdb2: remove nesting support.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 12:49:19 +0000 (23:19 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 12:49:19 +0000 (23:19 +1030)
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.

ccan/tdb2/tdb.c
ccan/tdb2/tdb2.h
ccan/tdb2/test/run-tdb_errorstr.c
ccan/tdb2/transaction.c

index 58a62cb400da905dba1fbae3845ed4a0d1f47dbe..38124582d125625766922e4dab802ca22de2ce82 100644 (file)
@@ -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";
index 3577cc3500702f21891df64095bbc883a1648f17..b482d2d636ebcf2247d88868feaa1d6fee28dff0 100644 (file)
@@ -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 };
index ad2df9142cbd5e0616d47aa79cb14e992f212a3f..15e3b184d01de01fe39d9912757968cccccd90af 100644 (file)
@@ -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"));
index 5772fb44028cb832c041b233b24548e7f352f644..4a26f4e605b9e4563378564fb0594714681c81c6 100644 (file)
@@ -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;