Avoid race to wake up napping processes

This commit is contained in:
Tony Garnock-Jones 2011-01-10 14:44:47 -05:00
parent e0ca281c32
commit fa222940fc
1 changed files with 4 additions and 3 deletions

View File

@ -125,9 +125,10 @@ typedef struct nap_context_t_ {
void nap_isr(int fd, short what, void *arg) {
nap_context_t *context = arg;
//info("nap_isr %p\n", p);
assert((context->p->state == PROCESS_WAITING) && (context->p->wait_flags & EV_TIMEOUT));
context->timeout_fired = 1;
enqueue_runlist(context->p);
if ((context->p->state == PROCESS_WAITING) && (context->p->wait_flags & EV_TIMEOUT)) {
context->timeout_fired = 1;
enqueue_runlist(context->p);
}
}
int nap(long millis) {