From 4afc5509cdd7a91b391f83407860f5607c323600 Mon Sep 17 00:00:00 2001 From: Kailun Qin Date: Tue, 27 Feb 2024 09:08:41 +0800 Subject: [PATCH] [LibOS] Error and die on timer event re-registration failure in callback Signed-off-by: Kailun Qin --- libos/src/sys/libos_alarm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libos/src/sys/libos_alarm.c b/libos/src/sys/libos_alarm.c index 6825d3dc85..0ccecfce25 100644 --- a/libos/src/sys/libos_alarm.c +++ b/libos/src/sys/libos_alarm.c @@ -65,8 +65,16 @@ static void signal_itimer(IDTYPE caller, void* arg) { spinlock_unlock(&g_real_itimer_lock); - if (next_reset) - install_async_event(/*object=*/NULL, next_reset, &signal_itimer, /*arg=*/NULL); + if (next_reset) { + int64_t ret = install_async_event(/*object=*/NULL, next_reset, &signal_itimer, + /*arg=*/NULL); + if (ret < 0) { + log_error( + "failed to re-enqueue the next timer event initially set up by 'setitimer()': %s", + unix_strerror(ret)); + die_or_inf_loop(); + } + } signal_current_proc(SIGALRM); }