Skip to content

Commit

Permalink
zdtm: Fix race in locks08 test
Browse files Browse the repository at this point in the history
The sub-process should wait for the parent task signal before
checking the locks status

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Dec 30, 2016
1 parent 02a1a79 commit 7d38db5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/zdtm/static/file_locks08.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ int main(int argc, char **argv)
int pid;
int status;
int ret = 0;
task_waiter_t tw;
struct flock lck;

test_init(argc, argv);
if (init_file_lock(&fd, &lck))
return -1;

task_waiter_init(&tw);

pid = fork();
if (pid == 0) {
task_waiter_wait4(&tw, getppid());
if (check_file_lock_restored(getpid(), fd, &lck) ||
check_lock_exists(filename, &lck) < 0)
ret = -1;
Expand All @@ -69,6 +73,8 @@ int main(int argc, char **argv)
test_daemon();
test_waitsig();

task_waiter_complete_current(&tw);

if (check_file_lock_restored(getpid(), fd, &lck) ||
check_lock_exists(filename, &lck) < 0)
fail("OFD file locks check failed\n");
Expand Down

0 comments on commit 7d38db5

Please sign in to comment.