From 0ea5db4e0d81907ccdc25c79aa3b6f8074775426 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 08:07:13 +0930 Subject: tdb2: catch errors in tdb1_needs_recovery() The tdb1 backend simply returns "true" if there's an error determining if a tdb needs recovery. But this leads failtest down a rabbit hole; it's better to return the error at this case (and makes for better for diagnostics, since they will come from the first fault, not later in tdb1_transaction_recover(). Signed-off-by: Rusty Russell (Imported from CCAN commit 332d0c29baa6896e67c439aeb47f58a104fbc781) --- lib/tdb2/tdb1_transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/tdb2/tdb1_transaction.c') diff --git a/lib/tdb2/tdb1_transaction.c b/lib/tdb2/tdb1_transaction.c index 08eac1df34..ecd7d2628e 100644 --- a/lib/tdb2/tdb1_transaction.c +++ b/lib/tdb2/tdb1_transaction.c @@ -1289,14 +1289,14 @@ int tdb1_transaction_recover(struct tdb_context *tdb) } /* Any I/O failures we say "needs recovery". */ -bool tdb1_needs_recovery(struct tdb_context *tdb) +tdb_bool_err tdb1_needs_recovery(struct tdb_context *tdb) { tdb1_off_t recovery_head; struct tdb1_record rec; /* find the recovery area */ if (tdb1_ofs_read(tdb, TDB1_RECOVERY_HEAD, &recovery_head) == -1) { - return true; + return tdb->last_error; } if (recovery_head == 0) { @@ -1307,7 +1307,7 @@ bool tdb1_needs_recovery(struct tdb_context *tdb) /* read the recovery record */ if (tdb->tdb1.io->tdb1_read(tdb, recovery_head, &rec, sizeof(rec), TDB1_DOCONV()) == -1) { - return true; + return tdb->last_error; } return (rec.magic == TDB1_RECOVERY_MAGIC); -- cgit