summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch')
-rw-r--r--meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch72
1 files changed, 0 insertions, 72 deletions
diff --git a/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch b/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
deleted file mode 100644
index 6ca593be5..000000000
--- a/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 41b7f4814d39c1930b1fcf0be2e247a73546fb80 Mon Sep 17 00:00:00 2001
-From: Jeffrey Pautler <jeffrey.pautler@ni.com>
-Date: Tue, 31 Oct 2017 14:38:39 -0500
-Subject: [PATCH 1/7] utils.c: Prefer monotonic clock to calculate elapsed time
-
-The current implementation uses the system clock to calculate how long
-a ptest has been running with no output. If a ptest changes the system
-clock as part of the test, that can cause the current implementation
-to falsely trigger a timeout or miss an actual timeout. It is
-preferrable to use a monotonic clock for calculating elapsed time in
-order to avoid these issues.
-
-This change tries to use the monotonic clock first and falls back to
-the realtime clock if the monotonic clock is not supported.
-
-Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
----
- utils.c | 24 +++++++++++++++++-------
- 1 file changed, 17 insertions(+), 7 deletions(-)
-
-diff --git a/utils.c b/utils.c
-index 6d653887e9e4..933ecedf57e8 100644
---- a/utils.c
-+++ b/utils.c
-@@ -257,7 +257,8 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
- int timeout, int *fds, FILE **fps)
- {
- struct pollfd pfds[2];
-- time_t sentinel;
-+ struct timespec sentinel;
-+ clockid_t clock = CLOCK_MONOTONIC;
- int r;
-
- int timeouted = 0;
-@@ -269,7 +270,11 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
- pfds[1].fd = fds[1];
- pfds[1].events = POLLIN;
-
-- sentinel = time(NULL);
-+ if (clock_gettime(clock, &sentinel) == -1) {
-+ clock = CLOCK_REALTIME;
-+ clock_gettime(clock, &sentinel);
-+ }
-+
- while (1) {
- waitflags = WNOHANG;
-
-@@ -288,11 +293,16 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
- fwrite(buf, n, 1, fps[1]);
- }
-
-- sentinel = time(NULL);
-- } else if (timeout >= 0 && ((time(NULL) - sentinel) > timeout)) {
-- timeouted = 1;
-- kill(pid, SIGKILL);
-- waitflags = 0;
-+ clock_gettime(clock, &sentinel);
-+ } else if (timeout >= 0) {
-+ struct timespec time;
-+
-+ clock_gettime(clock, &time);
-+ if ((time.tv_sec - sentinel.tv_sec) > timeout) {
-+ timeouted = 1;
-+ kill(pid, SIGKILL);
-+ waitflags = 0;
-+ }
- }
-
- if (waitpid(pid, &status, waitflags) == pid)
---
-2.11.0
-