Commit 4120637f authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: lock can belong to child or parent

Locks created by flock() are associated with an open file description
This means that duplicate file descriptors (created by, for  example,
fork or  dup)  refer  to  the  same  lock.

Reported-by: Mr Jenkins
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 76b4bad1
...@@ -16,7 +16,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com>"; ...@@ -16,7 +16,7 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com>";
char *filename; char *filename;
TEST_OPTION(filename, string, "file name", 1); TEST_OPTION(filename, string, "file name", 1);
static int check_file_locks() static int check_file_locks(pid_t child)
{ {
FILE *fp_locks = NULL; FILE *fp_locks = NULL;
char buf[100], fl_flag[16], fl_type[16], fl_option[16]; char buf[100], fl_flag[16], fl_type[16], fl_option[16];
...@@ -44,7 +44,7 @@ static int check_file_locks() ...@@ -44,7 +44,7 @@ static int check_file_locks()
break; break;
} }
if (fl_owner != pid) if (fl_owner != pid && fl_owner != child)
continue; continue;
if (!strcmp(fl_flag, "FLOCK") && if (!strcmp(fl_flag, "FLOCK") &&
...@@ -90,7 +90,7 @@ int main(int argc, char **argv) ...@@ -90,7 +90,7 @@ int main(int argc, char **argv)
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
if (check_file_locks()) if (check_file_locks(pid))
pass(); pass();
else else
fail("Flock file locks check failed"); fail("Flock file locks check failed");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment