MCPcopy Create free account
hub / github.com/apache/httpd / ap_proxy_connect_backend

Function ap_proxy_connect_backend

modules/proxy/proxy_util.c:3796–4070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3794}
3795
3796PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
3797 proxy_conn_rec *conn,
3798 proxy_worker *worker,
3799 server_rec *s)
3800{
3801 apr_status_t rv;
3802 int loglevel;
3803 remote_connect_info *connect_info = conn->forward;
3804 apr_sockaddr_t *backend_addr;
3805 /* the local address to use for the outgoing connection */
3806 apr_sockaddr_t *local_addr;
3807 apr_socket_t *newsock;
3808 void *sconf = s->module_config;
3809 int address_reusable = worker->s->is_address_reusable;
3810 int did_dns_lookup = 0;
3811 proxy_server_conf *conf =
3812 (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
3813
3814 rv = ap_proxy_check_connection(proxy_function, conn, s, 0, 0);
3815 if (rv == APR_EINVAL) {
3816 return DECLINED;
3817 }
3818
3819 /* We'll set conn->addr to the address actually connect()ed, so if the
3820 * network connection is not reused (per ap_proxy_check_connection()
3821 * above) we need to reset conn->addr to the first resolved address
3822 * and try to connect it first.
3823 */
3824 if (conn->address && rv != APR_SUCCESS) {
3825 conn->addr = conn->address->addr;
3826 }
3827 backend_addr = conn->addr;
3828
3829 while (rv != APR_SUCCESS && (backend_addr || conn->uds_path)) {
3830#if APR_HAVE_SYS_UN_H
3831 if (conn->uds_path)
3832 {
3833 rv = apr_socket_create(&newsock, AF_UNIX, SOCK_STREAM, 0,
3834 conn->scpool);
3835 if (rv != APR_SUCCESS) {
3836 loglevel = APLOG_ERR;
3837 ap_log_error(APLOG_MARK, loglevel, rv, s, APLOGNO(02453)
3838 "%s: error creating Unix domain socket "
3839 "%s (%s:%hu)",
3840 proxy_function,
3841 conn->uds_path,
3842 conn->hostname, conn->port);
3843 break;
3844 }
3845 conn->connection = NULL;
3846
3847 rv = ap_proxy_connect_uds(newsock, conn->uds_path, conn->scpool);
3848 if (rv != APR_SUCCESS) {
3849 apr_socket_close(newsock);
3850 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(02454)
3851 "%s: attempt to connect to Unix domain socket "
3852 "%s (%s:%hu) failed",
3853 proxy_function, conn->uds_path,

Callers 11

proxy_fcgi_handlerFunction · 0.85
proxy_http_handlerFunction · 0.85
uwsgi_handlerFunction · 0.85
hc_check_cpingFunction · 0.85
hc_check_tcpFunction · 0.85
hc_check_httpFunction · 0.85
proxy_wstunnel_handlerFunction · 0.85
proxy_ftp_handlerFunction · 0.85
proxy_ajp_handlerFunction · 0.85
scgi_handlerFunction · 0.85
proxy_http2_handlerFunction · 0.85

Calls 7

ap_get_module_configFunction · 0.85
ap_proxy_connect_udsFunction · 0.85
send_http_connectFunction · 0.85
socket_cleanupFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected