| 5644 | } |
| 5645 | |
| 5646 | PROXY_DECLARE(int) ap_proxy_tunnel_run(proxy_tunnel_rec *tunnel) |
| 5647 | { |
| 5648 | int status = OK, rc; |
| 5649 | request_rec *r = tunnel->r; |
| 5650 | apr_pollset_t *pollset = tunnel->pollset; |
| 5651 | struct proxy_tunnel_conn *client = tunnel->client, |
| 5652 | *origin = tunnel->origin; |
| 5653 | apr_interval_time_t timeout = tunnel->timeout >= 0 ? tunnel->timeout : -1; |
| 5654 | const char *scheme = tunnel->scheme; |
| 5655 | apr_status_t rv; |
| 5656 | |
| 5657 | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(10212) |
| 5658 | "proxy: %s: tunnel running (timeout %lf)", |
| 5659 | scheme, timeout >= 0 ? (double)timeout / APR_USEC_PER_SEC |
| 5660 | : (double)-1.0); |
| 5661 | |
| 5662 | /* Loop until both directions of the connection are closed, |
| 5663 | * or a failure occurs. |
| 5664 | */ |
| 5665 | do { |
| 5666 | const apr_pollfd_t *results; |
| 5667 | apr_int32_t nresults, i; |
| 5668 | |
| 5669 | ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, |
| 5670 | "proxy: %s: polling (client=%hx, origin=%hx)", |
| 5671 | scheme, client->pfd->reqevents, origin->pfd->reqevents); |
| 5672 | do { |
| 5673 | rv = apr_pollset_poll(pollset, timeout, &nresults, &results); |
| 5674 | } while (APR_STATUS_IS_EINTR(rv)); |
| 5675 | |
| 5676 | if (rv != APR_SUCCESS) { |
| 5677 | if (APR_STATUS_IS_TIMEUP(rv)) { |
| 5678 | ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, APLOGNO(10213) |
| 5679 | "proxy: %s: polling timed out " |
| 5680 | "(client=%hx, origin=%hx)", |
| 5681 | scheme, client->pfd->reqevents, |
| 5682 | origin->pfd->reqevents); |
| 5683 | status = HTTP_GATEWAY_TIME_OUT; |
| 5684 | } |
| 5685 | else { |
| 5686 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10214) |
| 5687 | "proxy: %s: polling failed", scheme); |
| 5688 | status = HTTP_INTERNAL_SERVER_ERROR; |
| 5689 | } |
| 5690 | goto done; |
| 5691 | } |
| 5692 | |
| 5693 | ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, APLOGNO(10215) |
| 5694 | "proxy: %s: woken up, %i result(s)", scheme, nresults); |
| 5695 | |
| 5696 | for (i = 0; i < nresults; i++) { |
| 5697 | const apr_pollfd_t *pfd = &results[i]; |
| 5698 | struct proxy_tunnel_conn *tc = pfd->client_data; |
| 5699 | |
| 5700 | ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, |
| 5701 | "proxy: %s: #%i: %s: %hx/%hx", scheme, i, |
| 5702 | tc->name, pfd->rtnevents, tc->pfd->reqevents); |
| 5703 |
no test coverage detected