<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"></div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 14, 2019 at 9:59 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> I am not sure how we would manage actual "msec_timeout" in case we get<br>
> EINTR and need to retry again as we may need to take care of elapsed<br>
> time till we receive asynchronous signal.<br>
<br>
I would have just restarted the timeout after we got signal, the worst case<br>
that can happen is that in an unlikely case we will send a signals fast enough<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Maybe we can print something useful there at least for friendly debugging if that unlikely case happens.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
so that the checkpoint will never timeout. But even then the test library will<br>
timeout and would kill the process anyways.<br>
<br>
Another option is to switch checkpoints so that they use absolute timeout and<br>
pass clock_gettime() + msec_timeout as timeout.<br>
<br>
I would go for something as simple as:<br>
<br>
diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c<br>
index 5455d0378..5e5b11496 100644<br>
--- a/lib/tst_checkpoint.c<br>
+++ b/lib/tst_checkpoint.c<br>
@@ -85,6 +85,7 @@ void tst_checkpoint_init(const char *file, const int lineno,<br>
int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)<br>
{<br>
struct timespec timeout;<br>
+ int ret;<br>
<br>
if (id >= tst_max_futexes) {<br>
errno = EOVERFLOW;<br>
@@ -94,8 +95,12 @@ int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)<br>
timeout.tv_sec = msec_timeout/1000;<br>
timeout.tv_nsec = (msec_timeout%1000) * 1000000;<br>
<br>
- return syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT,<br>
- tst_futexes[id], &timeout);<br>
+ do {<br>
+ ret = <span class="gmail_default" style="font-size:small"></span>syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT,<br>
+ tst_futexes[id], &timeout);</blockquote><div><div class="gmail_default" style="font-size:small"></div></div><div class="gmail_default" style="font-size:small"> if (ret == -1 && errno == EINTR)</div><div><div class="gmail_default"> tst_res(TWARN | TERRNO, "FUTEX_WAIT operation was interrupted by a signal, retry again");</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ } while (ret == -1 && errno == EINTR);<br>
+<br>
+ return ret;<br>
}<br>
<br>
-- <br>
Cyril Hrubis<br>
<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div></div></div></div></div></div></div></div></div>