| 364 | } |
| 365 | |
| 366 | static void event_loop(ACL_EVENT *eventp) |
| 367 | { |
| 368 | const char *myname = "event_loop"; |
| 369 | EVENT_KERNEL_THR *event_thr = (EVENT_KERNEL_THR *) eventp; |
| 370 | int nready; |
| 371 | acl_int64 delay, when; |
| 372 | ACL_EVENT_FDTABLE *fdp; |
| 373 | EVENT_BUFFER *bp; |
| 374 | |
| 375 | delay = eventp->delay_sec * 1000000 + eventp->delay_usec; |
| 376 | if (delay <= DELAY_MIN) { |
| 377 | delay = DELAY_MIN; |
| 378 | } |
| 379 | |
| 380 | SET_TIME(eventp->present); |
| 381 | |
| 382 | THREAD_LOCK(&event_thr->event.tm_mutex); |
| 383 | |
| 384 | when = event_timer_when(eventp); |
| 385 | |
| 386 | /* |
| 387 | * Find out when the next timer would go off. Timer requests are sorted. |
| 388 | * If any timer is scheduled, adjust the delay appropriately. |
| 389 | */ |
| 390 | if (when >= 0) { |
| 391 | acl_int64 n = when - eventp->present; |
| 392 | if (n <= 0) { |
| 393 | delay = 0; |
| 394 | } else if (n < delay) { |
| 395 | delay = n; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | THREAD_UNLOCK(&event_thr->event.tm_mutex); |
| 400 | |
| 401 | eventp->ready_cnt = 0; |
| 402 | |
| 403 | if (eventp->present - eventp->last_check >= eventp->check_inter) { |
| 404 | eventp->last_check = eventp->present; |
| 405 | |
| 406 | THREAD_LOCK(&event_thr->event.tb_mutex); |
| 407 | |
| 408 | if (event_thr_prepare(eventp) == 0) { |
| 409 | THREAD_UNLOCK(&event_thr->event.tb_mutex); |
| 410 | |
| 411 | if (eventp->ready_cnt == 0) { |
| 412 | acl_doze(delay > DELAY_MIN ? (int) delay / 1000 : 1); |
| 413 | } |
| 414 | |
| 415 | nready = 0; |
| 416 | goto TAG_DONE; |
| 417 | } |
| 418 | |
| 419 | THREAD_UNLOCK(&event_thr->event.tb_mutex); |
| 420 | |
| 421 | if (eventp->ready_cnt > 0) { |
| 422 | delay = 0; |
| 423 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…