From 7afb66bdd6c90cf598503db0d2123d31ff89d292 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 10 Feb 2020 21:20:41 +0900 Subject: [PATCH] timer: user-instance: delegate decision of poll timeout into application As long as using the created Gsource with GMainContext, the call of poll(2) system call with infinite timeout surely returns when quit() method is called for the context. All of GMainContext implements GWakeup with eventfd and the call of quit() emits event via file descriptor of eventfd. This brings wakeup from blocking when poll(2) is called with inifinite timeout. This means that it's necessarily need to have explicit timeout internally. This commit removes implementation of GSourceFunc.prepare for the reason. Signed-off-by: Takashi Sakamoto --- src/timer/user-instance.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index d3b0c48..365956c 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -316,14 +316,6 @@ static void handle_timestamp_events(TimerUserInstanceSource *src, int len) } } -static gboolean timer_user_instance_prepare_src(GSource *src, gint *timeout) -{ - *timeout = 500; - - // This source is not ready, let's poll(2). - return FALSE; -} - static gboolean timer_user_instance_check_src(GSource *gsrc) { TimerUserInstanceSource *src = (TimerUserInstanceSource *)gsrc; @@ -395,7 +387,6 @@ void alsatimer_user_instance_create_source(ALSATimerUserInstance *self, GSource **gsrc, GError **error) { static GSourceFuncs funcs = { - .prepare = timer_user_instance_prepare_src, .check = timer_user_instance_check_src, .dispatch = timer_user_instance_dispatch_src, .finalize = timer_user_instance_finalize_src, -- 2.47.3