kvm: Add handling of EAGAIN when creating timers
authorAndreas Sandberg <andreas@sandberg.pp.se>
Mon, 3 Jun 2013 11:38:59 +0000 (13:38 +0200)
committerAndreas Sandberg <andreas@sandberg.pp.se>
Mon, 3 Jun 2013 11:38:59 +0000 (13:38 +0200)
timer_create can apparently return -1 and set errno to EAGAIN if the
kernel suffered a temporary failure when allocating a timer. This
happens from time to time, so we need to handle it.

src/cpu/kvm/timer.cc

index e1f74a552e2eddcc50d672931961c3ffb0241633..03cdea6fb7f8984fd9bfb6ed57fe5085b419618a 100644 (file)
@@ -59,8 +59,11 @@ PosixKvmTimer::PosixKvmTimer(int signo, clockid_t clockID,
     sev.sigev_notify = SIGEV_SIGNAL;
     sev.sigev_signo = signo;
     sev.sigev_value.sival_ptr = NULL;
-    if (timer_create(clockID, &sev, &timer) == -1)
-        panic("timer_create");
+
+    while (timer_create(clockID, &sev, &timer) == -1) {
+        if (errno != EAGAIN)
+            panic("timer_create: %i", errno);
+    }
 }
 
 PosixKvmTimer::~PosixKvmTimer()