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

Function proxy_connection_create

modules/proxy/proxy_util.c:4099–4200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4097
4098
4099static int proxy_connection_create(const char *proxy_function,
4100 proxy_conn_rec *conn,
4101 request_rec *r, server_rec *s)
4102{
4103 ap_conf_vector_t *per_dir_config = (r) ? r->per_dir_config
4104 : conn->worker->section_config;
4105 apr_sockaddr_t *backend_addr = conn->addr;
4106 apr_interval_time_t current_timeout;
4107 apr_bucket_alloc_t *bucket_alloc;
4108 int rc = OK;
4109
4110 if (conn->connection) {
4111 if (conn->is_ssl) {
4112 /* on reuse, reinit the SSL connection dir config with the current
4113 * r->per_dir_config, the previous one was reset on release.
4114 */
4115 ap_proxy_ssl_engine(conn->connection, per_dir_config, 1);
4116 }
4117 return OK;
4118 }
4119
4120 if (conn->sock) {
4121 bucket_alloc = apr_bucket_alloc_create(conn->scpool);
4122 conn->tmp_bb = apr_brigade_create(conn->scpool, bucket_alloc);
4123 /*
4124 * The socket is now open, create a new backend server connection
4125 */
4126 conn->connection = ap_run_create_connection(conn->scpool, s, conn->sock,
4127 0, NULL, bucket_alloc);
4128 }
4129 if (!conn->connection) {
4130 /*
4131 * the peer reset the connection already; ap_run_create_connection()
4132 * closed the socket
4133 */
4134 ap_log_error(APLOG_MARK, APLOG_ERR, 0,
4135 s, APLOGNO(00960) "%s: an error occurred creating a "
4136 "new connection to %pI (%s)%s",
4137 proxy_function, backend_addr, conn->hostname,
4138 conn->sock ? "" : " (not connected)");
4139 rc = HTTP_INTERNAL_SERVER_ERROR;
4140 goto cleanup;
4141 }
4142
4143 /* For ssl connection to backend */
4144 if (conn->is_ssl) {
4145 if (!ap_proxy_ssl_engine(conn->connection, per_dir_config, 1)) {
4146 ap_log_error(APLOG_MARK, APLOG_ERR, 0,
4147 s, APLOGNO(00961) "%s: failed to enable ssl support "
4148 "for %pI (%s)", proxy_function,
4149 backend_addr, conn->hostname);
4150 rc = HTTP_INTERNAL_SERVER_ERROR;
4151 goto cleanup;
4152 }
4153 if (conn->ssl_hostname) {
4154 /* Set a note on the connection about what CN is requested,
4155 * such that mod_ssl can check if it is requested to do so.
4156 */

Callers 2

Calls 3

ap_proxy_ssl_engineFunction · 0.85
socket_cleanupFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected