aboutsummaryrefslogtreecommitdiff
path: root/backend/session
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-11-23 16:01:54 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-25 16:15:29 +0000
commit21254737bf97e5be44071063c14fce5a403a9a22 (patch)
tree84c077b5123c35fd5228935fc5728c827b56b5cf /backend/session
parent769cabbadf295fbe26cd2c3eb6efd5233c4d14e8 (diff)
backend: use time helpers to implement timeouts
Instead of hand-rolling get_current_time_msec(), let's just re-use the helper we already have in "util/time.h".
Diffstat (limited to 'backend/session')
-rw-r--r--backend/session/session.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/backend/session/session.c b/backend/session/session.c
index fcd25fec..7b8b0bc2 100644
--- a/backend/session/session.c
+++ b/backend/session/session.c
@@ -9,7 +9,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <time.h>
#include <wayland-server-core.h>
#include <wlr/backend/session.h>
#include <wlr/config.h>
@@ -17,6 +16,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "backend/session/session.h"
+#include "util/time.h"
#include <libseat.h>
@@ -436,12 +436,6 @@ static struct udev_enumerate *enumerate_drm_cards(struct udev *udev) {
return en;
}
-static uint64_t get_current_time_ms(void) {
- struct timespec ts = {0};
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
-}
-
struct find_gpus_add_handler {
bool added;
struct wl_listener listener;
@@ -476,8 +470,8 @@ ssize_t wlr_session_find_gpus(struct wlr_session *session,
handler.listener.notify = find_gpus_handle_add;
wl_signal_add(&session->events.add_drm_card, &handler.listener);
- uint64_t started_at = get_current_time_ms();
- uint64_t timeout = WAIT_GPU_TIMEOUT;
+ int64_t started_at = get_current_time_msec();
+ int64_t timeout = WAIT_GPU_TIMEOUT;
struct wl_event_loop *event_loop =
wl_display_get_event_loop(session->display);
while (!handler.added) {
@@ -489,7 +483,7 @@ ssize_t wlr_session_find_gpus(struct wlr_session *session,
return -1;
}
- uint64_t now = get_current_time_ms();
+ int64_t now = get_current_time_msec();
if (now >= started_at + WAIT_GPU_TIMEOUT) {
break;
}