Commit edd1a409 authored by Christophe Fergeau's avatar Christophe Fergeau

xspice: Don't create Xorg time in timer_add

SpiceCoreInterface::timer_add() is used by spice-server for integration
with external mainloops. timer_add() is only meant to create a disabled
timer, this timer will then be started with a call to timer_start().

The current implementation in Xspice creates a timer which will trigger
in a very long time, assuming this will never happen. This 'forever' is
1,000,000 seconds, which amounts to 11 days. After that time, some
timers which are meant to be disabled (eg migration related timers in
spice-server) fire, then causing a crash with some failed assertions.

Instead of creating the X timer right away in timer_add(), we can wait
until timer_start() is called before starting it, which avoids this
issue.
parent 76fd0a37
......@@ -171,7 +171,6 @@ static SpiceTimer* timer_add(SpiceTimerFunc func, void *opaque)
{
SpiceTimer *timer = calloc(sizeof(SpiceTimer), 1);
timer->xorg_timer = TimerSet(NULL, 0, 1e9 /* TODO: infinity? */, xorg_timer_callback, timer);
timer->func = func;
timer->opaque = opaque;
return timer;
......@@ -179,7 +178,8 @@ static SpiceTimer* timer_add(SpiceTimerFunc func, void *opaque)
static void timer_start(SpiceTimer *timer, uint32_t ms)
{
TimerSet(timer->xorg_timer, 0 /* flags */, ms, xorg_timer_callback, timer);
timer->xorg_timer = TimerSet(timer->xorg_timer, 0 /* flags */,
ms, xorg_timer_callback, timer);
}
static void timer_cancel(SpiceTimer *timer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment