| 370 | } |
| 371 | |
| 372 | static apr_status_t workers_pool_cleanup(void *data) |
| 373 | { |
| 374 | h2_workers *workers = data; |
| 375 | apr_time_t end, timeout = apr_time_from_sec(1); |
| 376 | apr_status_t rv; |
| 377 | int n = 0, wait_sec = 5; |
| 378 | |
| 379 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s, |
| 380 | "h2_workers: cleanup %d workers (%d idle)", |
| 381 | workers->active_slots, workers->idle_slots); |
| 382 | apr_thread_mutex_lock(workers->lock); |
| 383 | workers->shutdown = 1; |
| 384 | workers->aborted = 1; |
| 385 | wake_all_idles(workers); |
| 386 | apr_thread_mutex_unlock(workers->lock); |
| 387 | |
| 388 | /* wait for all the workers to become zombies and join them. |
| 389 | * this gets called after the mpm shuts down and all connections |
| 390 | * have either been handled (graceful) or we are forced exiting |
| 391 | * (ungrateful). Either way, we show limited patience. */ |
| 392 | end = apr_time_now() + apr_time_from_sec(wait_sec); |
| 393 | while (apr_time_now() < end) { |
| 394 | apr_thread_mutex_lock(workers->lock); |
| 395 | if (!(n = workers->active_slots)) { |
| 396 | apr_thread_mutex_unlock(workers->lock); |
| 397 | break; |
| 398 | } |
| 399 | wake_all_idles(workers); |
| 400 | rv = apr_thread_cond_timedwait(workers->all_done, workers->lock, timeout); |
| 401 | apr_thread_mutex_unlock(workers->lock); |
| 402 | |
| 403 | if (APR_TIMEUP == rv) { |
| 404 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s, |
| 405 | APLOGNO(10290) "h2_workers: waiting for workers to close, " |
| 406 | "still seeing %d workers (%d idle) living", |
| 407 | workers->active_slots, workers->idle_slots); |
| 408 | } |
| 409 | } |
| 410 | if (n) { |
| 411 | ap_log_error(APLOG_MARK, APLOG_WARNING, 0, workers->s, |
| 412 | APLOGNO(10291) "h2_workers: cleanup, %d workers (%d idle) " |
| 413 | "did not exit after %d seconds.", |
| 414 | n, workers->idle_slots, wait_sec); |
| 415 | } |
| 416 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s, |
| 417 | "h2_workers: cleanup all workers terminated"); |
| 418 | apr_thread_mutex_lock(workers->lock); |
| 419 | join_zombies(workers); |
| 420 | apr_thread_mutex_unlock(workers->lock); |
| 421 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s, |
| 422 | "h2_workers: cleanup zombie workers joined"); |
| 423 | |
| 424 | return APR_SUCCESS; |
| 425 | } |
| 426 | |
| 427 | h2_workers *h2_workers_create(server_rec *s, apr_pool_t *pchild, |
| 428 | int max_slots, int min_active, |
nothing calls this directly
no test coverage detected