]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/open.c
Import 898b5edfe757cb145960b8f3631029bfd5592119 from ctdb:
[ccan] / ccan / tdb / open.c
index 77c6936fc2f5bac28b6c421f3d61f730cba71129..ed32cf327f0dd8a21fe86a39ae380c5d5f0a6c99 100644 (file)
@@ -203,6 +203,22 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
                tdb->flags &= ~TDB_CLEAR_IF_FIRST;
        }
 
+       if ((tdb->flags & TDB_ALLOW_NESTING) &&
+           (tdb->flags & TDB_DISALLOW_NESTING)) {
+               tdb->ecode = TDB_ERR_NESTING;
+               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
+                       "allow_nesting and disallow_nesting are not allowed together!"));
+               errno = EINVAL;
+               goto fail;
+       }
+
+       /*
+        * TDB_DISALLOW_NESTING is the default behavior.
+        */
+       if (!(tdb->flags & TDB_ALLOW_NESTING)) {
+               tdb->flags |= TDB_DISALLOW_NESTING;
+       }
+
        /* internal databases don't mmap or lock, and start off cleared */
        if (tdb->flags & TDB_INTERNAL) {
                tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);