mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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 cbc66cc3ca
)
This commit is contained in:
parent
a34c21f378
commit
77670a2ec3
@ -183,45 +183,45 @@ int main(int argc, char *argv[])
|
|||||||
int loops = NLOOPS;
|
int loops = NLOOPS;
|
||||||
pid_t pids[NPROC];
|
pid_t pids[NPROC];
|
||||||
|
|
||||||
pids[0] = getpid();
|
db = tdb_open("torture.tdb", 0, TDB_CLEAR_IF_FIRST,
|
||||||
|
|
||||||
for (i=0;i<NPROC-1;i++) {
|
|
||||||
if ((pids[i+1]=fork()) == 0) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
db = tdb_open("torture.tdb", 2, TDB_CLEAR_IF_FIRST,
|
|
||||||
O_RDWR | O_CREAT, 0600);
|
O_RDWR | O_CREAT, 0600);
|
||||||
if (!db) {
|
if (!db) {
|
||||||
fatal("db open failed");
|
fatal("db open failed");
|
||||||
}
|
}
|
||||||
tdb_logging_function(db, tdb_log);
|
|
||||||
|
|
||||||
srand(seed + getpid());
|
for (i=0;i<NPROC;i++) {
|
||||||
srandom(seed + getpid() + time(NULL));
|
pids[i] = fork();
|
||||||
for (i=0;i<loops;i++) addrec_db();
|
if (pids[i] == 0) {
|
||||||
|
tdb_reopen_all();
|
||||||
|
|
||||||
tdb_traverse(db, NULL, NULL);
|
tdb_logging_function(db, tdb_log);
|
||||||
tdb_traverse(db, traverse_fn, NULL);
|
|
||||||
tdb_traverse(db, traverse_fn, NULL);
|
|
||||||
|
|
||||||
tdb_close(db);
|
srand(seed + getpid());
|
||||||
|
srandom(seed + getpid() + time(NULL));
|
||||||
|
for (i=0;i<loops;i++) addrec_db();
|
||||||
|
|
||||||
if (getpid() == pids[0]) {
|
tdb_traverse(db, NULL, NULL);
|
||||||
for (i=0;i<NPROC-1;i++) {
|
tdb_traverse(db, traverse_fn, NULL);
|
||||||
int status;
|
tdb_traverse(db, traverse_fn, NULL);
|
||||||
if (waitpid(pids[i+1], &status, 0) != pids[i+1]) {
|
|
||||||
printf("failed to wait for %d\n",
|
tdb_close(db);
|
||||||
(int)pids[i+1]);
|
exit(0);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (WEXITSTATUS(status) != 0) {
|
|
||||||
printf("child %d exited with status %d\n",
|
|
||||||
(int)pids[i+1], WEXITSTATUS(status));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user