- /* no job, check events */
- thr = (struct thread*)me;
- events = NULL;
- while (thr && !(events = thr->events))
- thr = thr->upper;
- if (events && !events->runs) {
- /* run the events */
- events->runs = 1;
- events->timeout = evto;
- me->events = events;
- pthread_mutex_unlock(&mutex);
- sig_monitor(0, events_call, events);
- pthread_mutex_lock(&mutex);
- events->runs = 0;
- me->events = NULL;
- } else {
- /* no owned event, check events */
- events = events_get();
- if (events) {
- /* run the events */
- events->used = 1;
- events->runs = 1;
- events->timeout = evto;
- me->events = events;
- pthread_mutex_unlock(&mutex);
- sig_monitor(0, events_call, events);
- pthread_mutex_lock(&mutex);
- events->used = 0;
- events->runs = 0;
- me->events = NULL;
- } else {
- /* no job and not events */
- waiting++;
- me->waits = 1;
- pthread_cond_wait(&cond, &mutex);
- me->waits = 0;
- waiting--;
- }
- }
+ /* no job and no event loop */
+ running--;
+ if (!running)
+ ERROR("Entering job deep sleep! Check your bindings.");
+ me->waits = 1;
+ pthread_cond_wait(&cond, &mutex);
+ me->waits = 0;
+ running++;