From: Ian Jackson Date: Fri, 31 Jan 2014 15:07:55 +0000 (+0000) Subject: libxl: timeouts: Record deregistration when one occurs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5600 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=15347ebb357fe587c2f9e55bdeb5ef6af36b7958;p=xen.git libxl: timeouts: Record deregistration when one occurs When a timeout has occurred, it is deregistered. However, we failed to record this fact by updating etime->func. As a result, libxl__ev_time_isregistered would say `true' for a timeout which has already happened. It is necessary to clear etime->func before the callback, because the callback might want to reinstate the timeout, or might free the etime (or its containing struct) entirely. The results are that we might try to have the timeout occur again (causing problems for the call site), and/or corrupt the timeout list. This fixes the timedereg event system unit test. Signed-off-by: Ian Jackson Cc: Jim Fehlig Cc: Ian Campbell Acked-by: Ian Campbell --- diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5a99932d96..ea8c744461 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -387,7 +387,9 @@ static void time_occurs(libxl__egc *egc, libxl__ev_time *etime) etime, (unsigned long)etime->abs.tv_sec, (unsigned long)etime->abs.tv_usec); - etime->func(egc, etime, &etime->abs); + libxl__ev_time_callback *func = etime->func; + etime->func = 0; + func(egc, etime, &etime->abs); }