[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/5] qemu-timer: reinitialize timers after fork
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 3/5] qemu-timer: reinitialize timers after fork |
Date: |
Fri, 2 Nov 2012 15:43:22 +0100 |
Timers are not inherited by the child of a fork(2), so just use
pthread_atfork to reinstate them after daemonize.
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-timer.c | 14 ++++++++++++++
1 file modificato, 14 inserzioni(+)
diff --git a/qemu-timer.c b/qemu-timer.c
index f3426c9..7b2217a 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -742,6 +742,17 @@ static void quit_timers(void)
t->stop(t);
}
+static void reinit_timers(void)
+{
+ struct qemu_alarm_timer *t = alarm_timer;
+ t->stop(t);
+ if (t->start(t)) {
+ fprintf(stderr, "Internal timer error: aborting\n");
+ exit(1);
+ }
+ qemu_rearm_alarm_timer(t);
+}
+
int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
@@ -765,6 +776,9 @@ int init_timer_alarm(void)
}
atexit(quit_timers);
+#ifdef CONFIG_POSIX
+ pthread_atfork(NULL, NULL, reinit_timers);
+#endif
alarm_timer = t;
return 0;
--
1.7.12.1
- [Qemu-devel] [PATCH v2 0/5] Fixes for thread pool patches., Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH v2 1/5] compiler: support Darwin weak references, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH v2 2/5] semaphore: implement fallback counting semaphores with mutex+condvar, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH v2 5/5] vl: delay thread initialization after daemonization, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH v2 3/5] qemu-timer: reinitialize timers after fork,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v2 4/5] vl: unify calls to init_timer_alarm, Paolo Bonzini, 2012/11/02
- Re: [Qemu-devel] [PATCH v2 0/5] Fixes for thread pool patches., Peter Maydell, 2012/11/02