| 985 | } |
| 986 | |
| 987 | static apr_status_t hc_watchdog_callback(int state, void *data, |
| 988 | apr_pool_t *pool) |
| 989 | { |
| 990 | apr_status_t rv = APR_SUCCESS; |
| 991 | proxy_balancer *balancer; |
| 992 | sctx_t *ctx = (sctx_t *)data; |
| 993 | server_rec *s = ctx->s; |
| 994 | proxy_server_conf *conf; |
| 995 | proxy_worker **workers; |
| 996 | proxy_worker *worker; |
| 997 | apr_time_t now; |
| 998 | int i, n; |
| 999 | |
| 1000 | conf = ap_get_module_config(s->module_config, &proxy_module); |
| 1001 | |
| 1002 | switch (state) { |
| 1003 | case AP_WATCHDOG_STATE_STARTING: |
| 1004 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(03258) |
| 1005 | "%s watchdog started.", |
| 1006 | HCHECK_WATHCHDOG_NAME); |
| 1007 | /* If a child exits while running an hcheck the ->updated time will |
| 1008 | * be zero, preventing further hcheck for the worker. |
| 1009 | */ |
| 1010 | now = apr_time_now(); |
| 1011 | balancer = (proxy_balancer *)conf->balancers->elts; |
| 1012 | for (i = 0; i < conf->balancers->nelts; i++, balancer++) { |
| 1013 | workers = (proxy_worker **)balancer->workers->elts; |
| 1014 | for (n = 0; n < balancer->workers->nelts; n++, workers++) { |
| 1015 | worker = *workers; |
| 1016 | if (worker->s->updated == 0) { |
| 1017 | worker->s->updated = now; |
| 1018 | } |
| 1019 | } |
| 1020 | } |
| 1021 | #if HC_USE_THREADS |
| 1022 | if (tpsize && hctp == NULL) { |
| 1023 | rv = apr_thread_pool_create(&hctp, tpsize, |
| 1024 | tpsize, ctx->p); |
| 1025 | if (rv != APR_SUCCESS) { |
| 1026 | ap_log_error(APLOG_MARK, APLOG_INFO, rv, s, APLOGNO(03312) |
| 1027 | "apr_thread_pool_create() with %d threads failed", |
| 1028 | tpsize); |
| 1029 | /* we can continue on without the threadpools */ |
| 1030 | hctp = NULL; |
| 1031 | } else { |
| 1032 | ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(03313) |
| 1033 | "apr_thread_pool_create() with %d threads succeeded", |
| 1034 | tpsize); |
| 1035 | } |
| 1036 | } else { |
| 1037 | ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(03314) |
| 1038 | "Skipping apr_thread_pool_create()"); |
| 1039 | hctp = NULL; |
| 1040 | } |
| 1041 | #endif |
| 1042 | break; |
| 1043 | |
| 1044 | case AP_WATCHDOG_STATE_RUNNING: |
nothing calls this directly
no test coverage detected