| 3700 | } |
| 3701 | |
| 3702 | PROXY_DECLARE(apr_status_t) ap_proxy_check_connection(const char *scheme, |
| 3703 | proxy_conn_rec *conn, |
| 3704 | server_rec *server, |
| 3705 | unsigned max_blank_lines, |
| 3706 | int flags) |
| 3707 | { |
| 3708 | apr_status_t rv = APR_SUCCESS; |
| 3709 | proxy_worker *worker = conn->worker; |
| 3710 | |
| 3711 | if (!PROXY_WORKER_IS_USABLE(worker)) { |
| 3712 | /* |
| 3713 | * The worker is in error likely done by a different thread / process |
| 3714 | * e.g. for a timeout or bad status. We should respect this and should |
| 3715 | * not continue with a connection via this worker even if we got one. |
| 3716 | */ |
| 3717 | rv = APR_EINVAL; |
| 3718 | } |
| 3719 | else if (conn->connection) { |
| 3720 | /* We have a conn_rec, check the full filter stack for things like |
| 3721 | * SSL alert/shutdown, filters aside data... |
| 3722 | */ |
| 3723 | rv = ap_check_pipeline(conn->connection, conn->tmp_bb, |
| 3724 | max_blank_lines); |
| 3725 | apr_brigade_cleanup(conn->tmp_bb); |
| 3726 | if (rv == APR_SUCCESS) { |
| 3727 | /* Some data available, the caller might not want them. */ |
| 3728 | if (flags & PROXY_CHECK_CONN_EMPTY) { |
| 3729 | rv = APR_ENOTEMPTY; |
| 3730 | } |
| 3731 | } |
| 3732 | else if (APR_STATUS_IS_EAGAIN(rv)) { |
| 3733 | /* Filter chain is OK and empty, yet we can't determine from |
| 3734 | * ap_check_pipeline (actually ap_core_input_filter) whether |
| 3735 | * an empty non-blocking read is EAGAIN or EOF on the socket |
| 3736 | * side (it's always SUCCESS), so check it explicitly here. |
| 3737 | */ |
| 3738 | if (ap_proxy_is_socket_connected(conn->sock)) { |
| 3739 | rv = APR_SUCCESS; |
| 3740 | } |
| 3741 | else { |
| 3742 | rv = APR_EPIPE; |
| 3743 | } |
| 3744 | } |
| 3745 | } |
| 3746 | else if (conn->sock) { |
| 3747 | /* For modules working with sockets directly, check it. */ |
| 3748 | if (!ap_proxy_is_socket_connected(conn->sock)) { |
| 3749 | rv = APR_EPIPE; |
| 3750 | } |
| 3751 | } |
| 3752 | else { |
| 3753 | rv = APR_ENOSOCKET; |
| 3754 | } |
| 3755 | |
| 3756 | if (rv == APR_SUCCESS) { |
| 3757 | if (APLOGtrace2(server)) { |
| 3758 | apr_sockaddr_t *local_addr = NULL; |
| 3759 | apr_socket_addr_get(&local_addr, APR_LOCAL, conn->sock); |
no test coverage detected