| 919 | } |
| 920 | |
| 921 | static void * APR_THREAD_FUNC hc_check(apr_thread_t *thread, void *b) |
| 922 | { |
| 923 | baton_t *baton = (baton_t *)b; |
| 924 | server_rec *s = baton->ctx->s; |
| 925 | proxy_worker *worker = baton->worker; |
| 926 | proxy_worker *hc = baton->hc; |
| 927 | apr_time_t now; |
| 928 | apr_status_t rv; |
| 929 | |
| 930 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(03256) |
| 931 | "%sHealth checking %s", (thread ? "Threaded " : ""), |
| 932 | worker->s->name_ex); |
| 933 | |
| 934 | if (hc->s->method == TCP) { |
| 935 | rv = hc_check_tcp(baton); |
| 936 | } |
| 937 | else if (hc->s->method == CPING) { |
| 938 | rv = hc_check_cping(baton, thread); |
| 939 | } |
| 940 | else { |
| 941 | rv = hc_check_http(baton, thread); |
| 942 | } |
| 943 | |
| 944 | now = apr_time_now(); |
| 945 | if (rv == APR_ENOTIMPL) { |
| 946 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(03257) |
| 947 | "Somehow tried to use unimplemented hcheck method: %d", |
| 948 | (int)hc->s->method); |
| 949 | } |
| 950 | /* what state are we in ? */ |
| 951 | else if (PROXY_WORKER_IS_HCFAILED(worker) || PROXY_WORKER_IS_ERROR(worker)) { |
| 952 | if (rv == APR_SUCCESS) { |
| 953 | worker->s->pcount += 1; |
| 954 | if (worker->s->pcount >= worker->s->passes) { |
| 955 | ap_proxy_set_wstatus(PROXY_WORKER_HC_FAIL_FLAG, 0, worker); |
| 956 | ap_proxy_set_wstatus(PROXY_WORKER_IN_ERROR_FLAG, 0, worker); |
| 957 | worker->s->pcount = 0; |
| 958 | ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(03302) |
| 959 | "%sHealth check ENABLING %s", (thread ? "Threaded " : ""), |
| 960 | worker->s->name_ex); |
| 961 | |
| 962 | } |
| 963 | } |
| 964 | } |
| 965 | else { |
| 966 | if (rv != APR_SUCCESS) { |
| 967 | worker->s->error_time = now; |
| 968 | worker->s->fcount += 1; |
| 969 | if (worker->s->fcount >= worker->s->fails) { |
| 970 | ap_proxy_set_wstatus(PROXY_WORKER_HC_FAIL_FLAG, 1, worker); |
| 971 | worker->s->fcount = 0; |
| 972 | ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(03303) |
| 973 | "%sHealth check DISABLING %s", (thread ? "Threaded " : ""), |
| 974 | worker->s->name_ex); |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | if (baton->now) { |
no test coverage detected