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 | c33cf24bcd165b23addb0a38f915a92f8256ce9c (patch) | |
tree | 60b3ee0baf09ad190e9ca32fb86a5ad05b5fef5a /source3/tdb | |
parent | 3c1ff07fa414636dee1f67832c943028223ff703 (diff) | |
download | samba-c33cf24bcd165b23addb0a38f915a92f8256ce9c.tar.gz samba-c33cf24bcd165b23addb0a38f915a92f8256ce9c.tar.bz2 samba-c33cf24bcd165b23addb0a38f915a92f8256ce9c.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.
(This used to be commit e99b6a2b91e4022ce0a9a14415df71314b5e013f)
Diffstat (limited to 'source3/tdb')
-rw-r--r-- | source3/tdb/tdb.c | 10 |
1 files changed, 10 insertions, 0 deletions
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)); |