os: Do timers under input lock, not blocked signals
Timer processing can happen on either the main thread or the input thread. As a result, it must be done under the input lock. Signals are unrelated to timers now that SIGIO isn't used for input processing, so stop blocking signals while processing timers. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
88e981e708
commit
8174daa6bd
28
os/WaitFor.c
28
os/WaitFor.c
|
@ -398,7 +398,7 @@ CheckAllTimers(void)
|
||||||
OsTimerPtr timer;
|
OsTimerPtr timer;
|
||||||
CARD32 now;
|
CARD32 now;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
start:
|
start:
|
||||||
now = GetTimeInMillis();
|
now = GetTimeInMillis();
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ CheckAllTimers(void)
|
||||||
goto start;
|
goto start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -416,10 +416,10 @@ DoTimer(OsTimerPtr timer, CARD32 now, volatile OsTimerPtr *prev)
|
||||||
{
|
{
|
||||||
CARD32 newTime;
|
CARD32 newTime;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
*prev = timer->next;
|
*prev = timer->next;
|
||||||
timer->next = NULL;
|
timer->next = NULL;
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
|
|
||||||
newTime = (*timer->callback) (timer, now, timer->arg);
|
newTime = (*timer->callback) (timer, now, timer->arg);
|
||||||
if (newTime)
|
if (newTime)
|
||||||
|
@ -439,7 +439,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
||||||
if (*prev == timer) {
|
if (*prev == timer) {
|
||||||
*prev = timer->next;
|
*prev = timer->next;
|
||||||
|
@ -448,7 +448,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
if (!millis)
|
if (!millis)
|
||||||
return timer;
|
return timer;
|
||||||
|
@ -468,13 +468,13 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
|
||||||
if (!millis)
|
if (!millis)
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
for (prev = &timers;
|
for (prev = &timers;
|
||||||
*prev && (int) ((*prev)->expires - millis) <= 0;
|
*prev && (int) ((*prev)->expires - millis) <= 0;
|
||||||
prev = &(*prev)->next);
|
prev = &(*prev)->next);
|
||||||
timer->next = *prev;
|
timer->next = *prev;
|
||||||
*prev = timer;
|
*prev = timer;
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ TimerForce(OsTimerPtr timer)
|
||||||
int rc = FALSE;
|
int rc = FALSE;
|
||||||
volatile OsTimerPtr *prev;
|
volatile OsTimerPtr *prev;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
||||||
if (*prev == timer) {
|
if (*prev == timer) {
|
||||||
DoTimer(timer, GetTimeInMillis(), prev);
|
DoTimer(timer, GetTimeInMillis(), prev);
|
||||||
|
@ -492,7 +492,7 @@ TimerForce(OsTimerPtr timer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,14 +503,14 @@ TimerCancel(OsTimerPtr timer)
|
||||||
|
|
||||||
if (!timer)
|
if (!timer)
|
||||||
return;
|
return;
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
for (prev = &timers; *prev; prev = &(*prev)->next) {
|
||||||
if (*prev == timer) {
|
if (*prev == timer) {
|
||||||
*prev = timer->next;
|
*prev = timer->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -528,10 +528,10 @@ TimerCheck(void)
|
||||||
CARD32 now = GetTimeInMillis();
|
CARD32 now = GetTimeInMillis();
|
||||||
|
|
||||||
if (timers && (int) (timers->expires - now) <= 0) {
|
if (timers && (int) (timers->expires - now) <= 0) {
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
while (timers && (int) (timers->expires - now) <= 0)
|
while (timers && (int) (timers->expires - now) <= 0)
|
||||||
DoTimer(timers, now, &timers);
|
DoTimer(timers, now, &timers);
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue