| 594 | } |
| 595 | |
| 596 | static apr_status_t dispatch(proxy_conn_rec *conn, proxy_dir_conf *conf, |
| 597 | request_rec *r, apr_pool_t *setaside_pool, |
| 598 | apr_uint16_t request_id, const char **err, |
| 599 | int *bad_request, int *has_responded, |
| 600 | apr_bucket_brigade *input_brigade) |
| 601 | { |
| 602 | apr_bucket_brigade *ib, *ob; |
| 603 | int seen_end_of_headers = 0, done = 0, ignore_body = 0; |
| 604 | apr_status_t rv = APR_SUCCESS; |
| 605 | int script_error_status = HTTP_OK; |
| 606 | conn_rec *c = r->connection; |
| 607 | struct iovec vec[2]; |
| 608 | ap_fcgi_header header; |
| 609 | unsigned char farray[AP_FCGI_HEADER_LEN]; |
| 610 | apr_pollfd_t pfd; |
| 611 | apr_pollfd_t *flushpoll = NULL; |
| 612 | apr_int32_t flushpoll_fd; |
| 613 | int header_state = HDR_STATE_READING_HEADERS; |
| 614 | char stack_iobuf[AP_IOBUFSIZE]; |
| 615 | apr_size_t iobuf_size = AP_IOBUFSIZE; |
| 616 | char *iobuf = stack_iobuf; |
| 617 | |
| 618 | *err = NULL; |
| 619 | if (conn->worker->s->io_buffer_size_set) { |
| 620 | iobuf_size = conn->worker->s->io_buffer_size; |
| 621 | iobuf = apr_palloc(r->pool, iobuf_size); |
| 622 | } |
| 623 | |
| 624 | pfd.desc_type = APR_POLL_SOCKET; |
| 625 | pfd.desc.s = conn->sock; |
| 626 | pfd.p = r->pool; |
| 627 | pfd.reqevents = APR_POLLIN | APR_POLLOUT; |
| 628 | |
| 629 | if (conn->worker->s->flush_packets == flush_auto) { |
| 630 | flushpoll = apr_pcalloc(r->pool, sizeof(apr_pollfd_t)); |
| 631 | flushpoll->reqevents = APR_POLLIN; |
| 632 | flushpoll->desc_type = APR_POLL_SOCKET; |
| 633 | flushpoll->desc.s = conn->sock; |
| 634 | } |
| 635 | |
| 636 | ib = apr_brigade_create(r->pool, c->bucket_alloc); |
| 637 | ob = apr_brigade_create(r->pool, c->bucket_alloc); |
| 638 | |
| 639 | while (! done) { |
| 640 | apr_interval_time_t timeout; |
| 641 | apr_size_t len; |
| 642 | int n; |
| 643 | |
| 644 | /* We need SOME kind of timeout here, or virtually anything will |
| 645 | * cause timeout errors. */ |
| 646 | apr_socket_timeout_get(conn->sock, &timeout); |
| 647 | |
| 648 | rv = apr_poll(&pfd, 1, &n, timeout); |
| 649 | if (rv != APR_SUCCESS) { |
| 650 | if (APR_STATUS_IS_EINTR(rv)) { |
| 651 | continue; |
| 652 | } |
| 653 | *err = "polling"; |
no test coverage detected