X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Fopen.c;fp=ccan%2Ftdb%2Fopen.c;h=1d6b3ed75ab084033723122c71857a1f8d5e84d5;hp=77c6936fc2f5bac28b6c421f3d61f730cba71129;hb=4364f6a8e21a8f7c561f121af3a834cf7e0649ce;hpb=110b06ab28f2c40baf0f5014bd8d4e468bcba2ba diff --git a/ccan/tdb/open.c b/ccan/tdb/open.c index 77c6936f..1d6b3ed7 100644 --- a/ccan/tdb/open.c +++ b/ccan/tdb/open.c @@ -203,6 +203,23 @@ 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_ALLOW_NESTING is the default behavior. + * Note: this may change in future versions! + */ + if (!(tdb->flags & TDB_DISALLOW_NESTING)) { + tdb->flags |= TDB_ALLOW_NESTING; + } + /* internal databases don't mmap or lock, and start off cleared */ if (tdb->flags & TDB_INTERNAL) { tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);