tdb: Make record deletion circular-chain safe
[samba.git] / lib / tdb / common / freelist.c
index 5221bf3679e6acf5fb02b25eabbeb9d79bd80529..90643862208875b55fdc9e0999c37ac14b597b49 100644 (file)
@@ -555,6 +555,17 @@ static bool tdb_alloc_dead(
        return (tdb_ofs_write(tdb, last_ptr, &rec->next) == 0);
 }
 
+static void tdb_purge_dead(struct tdb_context *tdb, uint32_t hash)
+{
+       uint32_t max_dead_records = tdb->max_dead_records;
+
+       tdb->max_dead_records = 0;
+
+       tdb_trim_dead(tdb, hash);
+
+       tdb->max_dead_records = max_dead_records;
+}
+
 /*
  * Chain "hash" is assumed to be locked
  */