summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-04-09 12:40:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-04-09 13:20:42 +0100
commit4aca0b8da70326bb9db381748ed2f7e77c43af4f (patch)
treee6355333372902599e25aa5f01ce3648d6397bed /lib
parent13c0be2fe8669fef08c0d1c44b147c43d1f53d2b (diff)
lib: Set initial invalid timerfd to -1
Allow for a timerfd of 0, just in case some test closes stdin. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_dummyload.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 9221db51c..99ca84ad8 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -324,6 +324,7 @@ spin_create(int fd, const struct igt_spin_factory *opts)
spin = calloc(1, sizeof(struct igt_spin));
igt_assert(spin);
+ spin->timerfd = -1;
spin->out_fence = emit_recursive_batch(spin, fd, opts);
pthread_mutex_lock(&list_lock);
@@ -398,14 +399,12 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
static void *timer_thread(void *data)
{
igt_spin_t *spin = data;
- struct pollfd pfd;
- int ret;
+ struct pollfd pfd = {
+ .fd = spin->timerfd,
+ .events = POLLIN,
+ };
- pfd.fd = spin->timerfd;
- pfd.events = POLLIN;
-
- ret = poll(&pfd, 1, -1);
- if (ret >= 0)
+ if (poll(&pfd, 1, -1) >= 0)
igt_spin_end(spin);
return NULL;
@@ -431,7 +430,7 @@ void igt_spin_set_timeout(igt_spin_t *spin, int64_t ns)
if (!spin)
return;
- igt_assert(!spin->timerfd);
+ igt_assert(spin->timerfd == -1);
timerfd = timerfd_create(CLOCK_MONOTONIC, 0);
igt_assert(timerfd >= 0);
spin->timerfd = timerfd;
@@ -501,7 +500,7 @@ void igt_spin_free(int fd, igt_spin_t *spin)
igt_list_del(&spin->link);
pthread_mutex_unlock(&list_lock);
- if (spin->timerfd) {
+ if (spin->timerfd >= 0) {
pthread_cancel(spin->timer_thread);
igt_assert(pthread_join(spin->timer_thread, NULL) == 0);
close(spin->timerfd);