X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ffree.c;h=8f81f9d99aae0a378db0163e6cd389bda336d060;hb=554f38560bfd9a603b5d95fb1a656f080617534b;hp=ac637ce1c8650caab593036c143bce5b1b65bc47;hpb=6520c8318b9b8f2d92ae4b9f062788b7e4035aac;p=ccan-lca-2011.git diff --git a/ccan/tdb2/free.c b/ccan/tdb2/free.c index ac637ce..8f81f9d 100644 --- a/ccan/tdb2/free.c +++ b/ccan/tdb2/free.c @@ -530,6 +530,14 @@ static int tdb_expand(struct tdb_context *tdb, tdb_len_t size) /* We need room for the record header too. */ wanted = sizeof(struct tdb_used_record) + size; + /* Need to hold a hash lock to expand DB: transactions rely on it. */ + if (!(tdb->flags & TDB_NOLOCK) + && !tdb->allrecord_lock.count && !tdb_has_hash_locks(tdb)) { + tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv, + "tdb_expand: must hold lock during expand\n"); + return -1; + } + /* Only one person can expand file at a time. */ if (tdb_lock_expand(tdb, F_WRLCK) != 0) return -1;