fix race between timer firing vs. alarm_timer->pending = 0
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Mar 2010 10:30:35 +0000 (11:30 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 27 Mar 2010 13:05:07 +0000 (14:05 +0100)
The period for Win32 timers is very short and always the same
independent of dynticks, so it's possible that the timer fires
before qemu_run_all_timers has reset alarm_timer->pending to zero.
Reset alarm_timer->pending before rearming.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
qemu-timer.c

index 329d3a4e60f5912009d387427454a80ea7480a28..49eac86c58284bcde75615b9b17a975a5ef03604 100644 (file)
@@ -706,14 +706,14 @@ void configure_icount(const char *option)
 
 void qemu_run_all_timers(void)
 {
+    alarm_timer->pending = 0;
+
     /* rearm timer, if not periodic */
     if (alarm_timer->expired) {
         alarm_timer->expired = 0;
         qemu_rearm_alarm_timer(alarm_timer);
     }
 
-    alarm_timer->pending = 0;
-
     /* vm time timers */
     if (vm_running) {
         qemu_run_timers(vm_clock);