tdb: add TDB_MUTEX_LOCKING support
[samba.git] / lib / tdb / common / tdb.c
index ebd4ffe3e013f4229ff544c9bd151ecf64b39b96..ae98c9619d1c1b6f70c799b083acf72278abb57b 100644 (file)
@@ -723,6 +723,15 @@ _PUBLIC_ void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
                return;
        }
 
+       if ((flags & TDB_NOLOCK) &&
+           (tdb->feature_flags & TDB_FEATURE_FLAG_MUTEX) &&
+           (tdb->mutexes == NULL)) {
+               tdb->ecode = TDB_ERR_LOCK;
+               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_remove_flags: "
+                        "Can not remove NOLOCK flag on mutexed databases"));
+               return;
+       }
+
        if (flags & TDB_ALLOW_NESTING) {
                tdb->flags |= TDB_DISALLOW_NESTING;
        }