diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-05-22 01:32:12 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-05-22 01:32:12 +0000 |
commit | e99b6a2b91e4022ce0a9a14415df71314b5e013f (patch) | |
tree | 9f0df17c091ebf5875348853d981556c41671e40 /source/tdb | |
parent | d4dbb9cb1338332bda3651dc4b86abcf47e9c2d2 (diff) | |
download | samba-e99b6a2b91e4022ce0a9a14415df71314b5e013f.tar.gz samba-e99b6a2b91e4022ce0a9a14415df71314b5e013f.tar.xz samba-e99b6a2b91e4022ce0a9a14415df71314b5e013f.zip |
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.
Diffstat (limited to 'source/tdb')
-rw-r--r-- | source/tdb/tdb.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/tdb/tdb.c b/source/tdb/tdb.c index c937090de4d..14e1d4a24f7 100644 --- a/source/tdb/tdb.c +++ b/source/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)); |