From 6ad04b02d95ba5897ae609b7030608a62cc7797b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 22 Feb 2010 22:49:57 +1030 Subject: [PATCH] tdb: fix tdbtorture seed printing, plus remove CLEAR_IF_FIRST With killing children, CLEAR_IF_FIRST can happen quite a bit. --- ccan/tdb/tools/tdbtorture.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccan/tdb/tools/tdbtorture.c b/ccan/tdb/tools/tdbtorture.c index 58bef81a..0d5bcd2b 100644 --- a/ccan/tdb/tools/tdbtorture.c +++ b/ccan/tdb/tools/tdbtorture.c @@ -252,16 +252,12 @@ static void send_count_and_suicide(int sig) static int run_child(int i, int seed, unsigned num_loops, unsigned start) { - db = tdb_open_ex("torture.tdb", hash_size, TDB_CLEAR_IF_FIRST, + db = tdb_open_ex("torture.tdb", hash_size, TDB_DEFAULT, O_RDWR | O_CREAT, 0600, &log_ctx, NULL); if (!db) { fatal("db open failed"); } - if (seed == -1) { - seed = (getpid() + time(NULL)) & 0x7FFFFFFF; - } - srand(seed + i); srandom(seed + i); @@ -336,6 +332,10 @@ int main(int argc, char * const *argv) unlink("torture.tdb"); + if (seed == -1) { + seed = (getpid() + time(NULL)) & 0x7FFFFFFF; + } + if (num_procs == 1 && !kill_random) { /* Don't fork for this case, makes debugging easier. */ error_count = run_child(0, seed, num_loops, 0); -- 2.39.2