merged tdb from ctdb bzr tree
[ira/wip.git] / source / lib / tdb / common / lock.c
index e3fe888c465f357adb436b7230d8e3070f073a63..f156c0fa7b2e548640d47db23df71c9427ec73ce 100644 (file)
@@ -505,6 +505,9 @@ int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key)
 /* record lock stops delete underneath */
 int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off)
 {
 /* record lock stops delete underneath */
 int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off)
 {
+       if (tdb->global_lock.count) {
+               return 0;
+       }
        return off ? tdb->methods->tdb_brlock(tdb, off, F_RDLCK, F_SETLKW, 0, 1) : 0;
 }
 
        return off ? tdb->methods->tdb_brlock(tdb, off, F_RDLCK, F_SETLKW, 0, 1) : 0;
 }
 
@@ -537,6 +540,10 @@ int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off)
        struct tdb_traverse_lock *i;
        uint32_t count = 0;
 
        struct tdb_traverse_lock *i;
        uint32_t count = 0;
 
+       if (tdb->global_lock.count) {
+               return 0;
+       }
+
        if (off == 0)
                return 0;
        for (i = &tdb->travlocks; i; i = i->next)
        if (off == 0)
                return 0;
        for (i = &tdb->travlocks; i; i = i->next)