diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-08-29 13:45:13 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:03:25 -0500 |
commit | 77670a2ec33275ae08a37606ee15bf0170b7fcb3 (patch) | |
tree | 04304f6c4ad0860f5485eed3f7192ebdb95eb869 /source3 | |
parent | a34c21f3783c9d8e18fa1a4a5cd1e734f80b7a91 (diff) | |
download | samba-77670a2ec33275ae08a37606ee15bf0170b7fcb3.tar.gz samba-77670a2ec33275ae08a37606ee15bf0170b7fcb3.tar.bz2 samba-77670a2ec33275ae08a37606ee15bf0170b7fcb3.zip |
r9738: Adapt tdb_torture to the new CLEAR_IF_FIRST semantics. We need one parent
process holding the active if two cluster nodes access the same tdb.
Volker
(This used to be commit cbc66cc3cab0e1db31402505214c83e1be92663b)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/tdb/tdbtorture.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/source3/tdb/tdbtorture.c b/source3/tdb/tdbtorture.c index 3f704e537e..d03cc2a610 100644 --- a/source3/tdb/tdbtorture.c +++ b/source3/tdb/tdbtorture.c @@ -183,45 +183,45 @@ int main(int argc, char *argv[]) int loops = NLOOPS; pid_t pids[NPROC]; - pids[0] = getpid(); - - for (i=0;i<NPROC-1;i++) { - if ((pids[i+1]=fork()) == 0) break; - } - - db = tdb_open("torture.tdb", 2, TDB_CLEAR_IF_FIRST, + db = tdb_open("torture.tdb", 0, TDB_CLEAR_IF_FIRST, O_RDWR | O_CREAT, 0600); if (!db) { fatal("db open failed"); } - tdb_logging_function(db, tdb_log); - - srand(seed + getpid()); - srandom(seed + getpid() + time(NULL)); - for (i=0;i<loops;i++) addrec_db(); - - tdb_traverse(db, NULL, NULL); - tdb_traverse(db, traverse_fn, NULL); - tdb_traverse(db, traverse_fn, NULL); - - tdb_close(db); - - if (getpid() == pids[0]) { - for (i=0;i<NPROC-1;i++) { - int status; - if (waitpid(pids[i+1], &status, 0) != pids[i+1]) { - printf("failed to wait for %d\n", - (int)pids[i+1]); - exit(1); - } - if (WEXITSTATUS(status) != 0) { - printf("child %d exited with status %d\n", - (int)pids[i+1], WEXITSTATUS(status)); - exit(1); - } + + for (i=0;i<NPROC;i++) { + pids[i] = fork(); + if (pids[i] == 0) { + tdb_reopen_all(); + + tdb_logging_function(db, tdb_log); + + srand(seed + getpid()); + srandom(seed + getpid() + time(NULL)); + for (i=0;i<loops;i++) addrec_db(); + + tdb_traverse(db, NULL, NULL); + tdb_traverse(db, traverse_fn, NULL); + tdb_traverse(db, traverse_fn, NULL); + + tdb_close(db); + exit(0); } - printf("OK\n"); } + for (i=0;i<NPROC;i++) { + int status; + if (waitpid(pids[i], &status, 0) != pids[i]) { + printf("failed to wait for %d\n", + (int)pids[i]); + exit(1); + } + if (WEXITSTATUS(status) != 0) { + printf("child %d exited with status %d\n", + (int)pids[i], WEXITSTATUS(status)); + exit(1); + } + } + printf("OK\n"); return 0; } |