From c33cf24bcd165b23addb0a38f915a92f8256ce9c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 May 2002 01:32:12 +0000 Subject: auto-recover from the fairly common case of a non-clean tdb shutdown while deleting a record. This leaves us with a non-free record on the free list. (This used to be commit e99b6a2b91e4022ce0a9a14415df71314b5e013f) --- source3/tdb/tdb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/tdb') diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index c937090de4..14e1d4a24f 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -412,6 +412,16 @@ static int rec_free_read(TDB_CONTEXT *tdb, tdb_off off, struct list_struct *rec) { if (tdb_read(tdb, off, rec, sizeof(*rec),DOCONV()) == -1) return -1; + + if (rec->magic == TDB_MAGIC) { + /* this happens when a app is showdown while deleting a record - we should + not completely fail when this happens */ + TDB_LOG((tdb, 0,"rec_free_read non-free magic at offset=%d - fixing\n", + rec->magic, off)); + rec->magic = TDB_FREE_MAGIC; + tdb_write(tdb, off, rec, sizeof(*rec)); + } + if (rec->magic != TDB_FREE_MAGIC) { TDB_LOG((tdb, 0,"rec_free_read bad magic 0x%x at offset=%d\n", rec->magic, off)); -- cgit