int oldstate;
bool timed = FALSE;
- DBG2(DBG_JOB, "waiting for next event...");
this->mutex->lock(this->mutex);
gettimeofday(&now, NULL);
if ((event = peek_event(this)) != NULL)
{
difference = time_difference(&now, &event->time);
- if (difference > 0)
+ if (difference >= 0)
{
remove_event(this);
this->mutex->unlock(this->mutex);
free(event);
return JOB_REQUEUE_DIRECT;
}
+ DBG2(DBG_JOB, "next event in %ldms, waiting", -difference);
timed = TRUE;
}
pthread_cleanup_push((void*)this->mutex->unlock, this->mutex);
}
else
{
+ DBG2(DBG_JOB, "no events, waiting");
this->condvar->wait(this->condvar, this->mutex);
}
pthread_setcancelstate(oldstate, NULL);