* Solve a chicken and egg problem here:
We need to have sslconn->dc set correctly when we want to
init sslconn, but we need to allocate memory for it first.
@@ -490,10 +490,25 @@ static SSLConnRec *ssl_init_connection_ctx(conn_rec *c,
int new_proxy)
{
SSLConnRec *sslconn = myConnConfig(c);
+ int need_setup = 0;
if (!sslconn) {
sslconn = apr_pcalloc(c->pool, sizeof(*sslconn));
+ need_setup = 1;
+ }
+
+ /* Reinit dc in any case because it may be r->per_dir_config scoped
+ * and thus a caller like mod_proxy needs to update it per request.
+ */
+ if (per_dir_config) {
+ sslconn->dc = ap_get_module_config(per_dir_config, &ssl_module);
+ }
+ else {
+ sslconn->dc = ap_get_module_config(c->base_server->lookup_defaults,
+ &ssl_module);
+ }
+ if (need_setup) {
sslconn->server = c->base_server;
sslconn->verify_depth = UNSET;
if (new_proxy) {
@@ -508,17 +523,6 @@ static SSLConnRec *ssl_init_connection_ctx(conn_rec *c,
myConnConfigSet(c, sslconn);
}
- /* Reinit dc in any case because it may be r->per_dir_config scoped
- * and thus a caller like mod_proxy needs to update it per request.
- */
- if (per_dir_config) {
- sslconn->dc = ap_get_module_config(per_dir_config, &ssl_module);
- }
- else {
- sslconn->dc = ap_get_module_config(c->base_server->lookup_defaults,
- &ssl_module);
- }
-
return sslconn;
}
