From: Xiong Zhou <xzhou@redhat.com>
To: fstests@vger.kernel.org
Cc: Xiong Zhou <xzhou@redhat.com>
Subject: [PATCH] generic/478: fix potential test blocking
Date: Fri, 23 Mar 2018 10:49:37 +0800 [thread overview]
Message-ID: <1521773377-19814-1-git-send-email-xzhou@redhat.com> (raw)
Reduce semtimedop timeout to 5s, 15s is too long if something
get tangled up. Add retry counting to getlk routine, infinite
loop is dangerous. If something goes wrong unexpextedly, test
is blocked wasting time.
Signed-off-by: Xiong Zhou <xzhou@redhat.com>
---
We are hitting this when testing on cifs samba 2.0.
src/t_ofd_locks.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/t_ofd_locks.c b/src/t_ofd_locks.c
index d578cd7..454b2ce 100644
--- a/src/t_ofd_locks.c
+++ b/src/t_ofd_locks.c
@@ -317,14 +317,14 @@ int main(int argc, char **argv)
sop.sem_num = 0;
sop.sem_op = 1;
sop.sem_flg = 0;
- ts.tv_sec = 15;
+ ts.tv_sec = 5;
ts.tv_nsec = 0;
if (semtimedop(semid, &sop, 1, &ts) == -1)
err_exit("inc sem0 2", errno);
sop.sem_num = 1;
sop.sem_op = 1;
sop.sem_flg = 0;
- ts.tv_sec = 15;
+ ts.tv_sec = 5;
ts.tv_nsec = 0;
if (semtimedop(semid, &sop, 1, &ts) == -1)
err_exit("inc sem1 2", errno);
@@ -376,7 +376,7 @@ int main(int argc, char **argv)
sop.sem_num = 1;
sop.sem_op = 0;
sop.sem_flg = 0;
- ts.tv_sec = 15;
+ ts.tv_sec = 5;
ts.tv_nsec = 0;
if (semtimedop(semid, &sop, 1, &ts) == -1)
err_exit("wait sem1 0", errno);
@@ -391,13 +391,16 @@ int main(int argc, char **argv)
/* getlck */
if (lock_cmd == 0) {
/* wait sem created and initialized */
+ retry = 5;
do {
semid = semget(semkey, 2, 0);
if (semid != -1)
break;
- if (errno == ENOENT)
+ if (errno == ENOENT && retry) {
+ sleep(1);
+ retry--;
continue;
- else
+ } else
err_exit("getlk_semget", errno);
} while (1);
do {
@@ -410,7 +413,7 @@ int main(int argc, char **argv)
sop.sem_num = 0;
sop.sem_op = 0;
sop.sem_flg = 0;
- ts.tv_sec = 15;
+ ts.tv_sec = 5;
ts.tv_nsec = 0;
if (semtimedop(semid, &sop, 1, &ts) == -1)
err_exit("wait sem0 0", errno);
--
1.8.3.1
reply other threads:[~2018-03-23 2:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521773377-19814-1-git-send-email-xzhou@redhat.com \
--to=xzhou@redhat.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox