@@ -81,6 +81,34 @@ static int redirectionio_match_handler(request_rec *r) {
8181 return DECLINED ;
8282 }
8383
84+ // Do not match against internal redirect
85+ if (r -> prev ) {
86+ return DECLINED ;
87+ }
88+
89+ if (config -> connection_pool == NULL ) {
90+ if (apr_reslist_create (
91+ & config -> connection_pool ,
92+ RIO_MIN_CONNECTIONS ,
93+ RIO_KEEP_CONNECTIONS ,
94+ RIO_MAX_CONNECTIONS ,
95+ 0 ,
96+ redirectionio_pool_construct ,
97+ redirectionio_pool_destruct ,
98+ config ,
99+ config -> pool
100+ ) != APR_SUCCESS ) {
101+ ap_log_rerror (APLOG_MARK , APLOG_CRIT , 0 , r , "mod_redirectionio: Failed to initialize resource pool, disabling redirectionio." );
102+
103+ config -> enable = 0 ;
104+
105+ return DECLINED ;
106+ }
107+
108+ apr_reslist_timeout_set (config -> connection_pool , RIO_TIMEOUT );
109+ apr_pool_cleanup_register (config -> pool , config -> connection_pool , redirectionio_child_exit , redirectionio_child_exit );
110+ }
111+
84112 // Create context
85113 redirectionio_context * ctx = ap_get_module_config (r -> request_config , & redirectionio_module );
86114
@@ -96,6 +124,8 @@ static int redirectionio_match_handler(request_rec *r) {
96124 return DECLINED ;
97125 }
98126
127+ ctx -> matched_rule_id = NULL ;
128+ ctx -> target = NULL ;
99129 ctx -> status = 0 ;
100130 ctx -> match_on_response_status = 0 ;
101131 ctx -> is_redirected = 0 ;
@@ -446,6 +476,14 @@ static apr_status_t redirectionio_create_connection(redirectionio_connection *co
446476 return rv ;
447477 }
448478
479+ rv = apr_socket_opt_set (conn -> rio_sock , APR_SO_KEEPALIVE , 1 );
480+
481+ if (rv != APR_SUCCESS ) {
482+ ap_log_perror (APLOG_MARK , APLOG_ERR , 0 , pool , "mod_redirectionio: Error setting socket keepalive: %s" , apr_strerror (rv , errbuf , sizeof (errbuf )));
483+
484+ return rv ;
485+ }
486+
449487 rv = apr_socket_opt_set (conn -> rio_sock , APR_TCP_NODELAY , 1 );
450488
451489 if (rv != APR_SUCCESS ) {
@@ -554,26 +592,8 @@ static void *merge_redirectionio_dir_conf(apr_pool_t *pool, void *parent, void *
554592 conf -> pass_set = conf_current -> pass_set ;
555593 }
556594
557- if (apr_reslist_create (
558- & conf -> connection_pool ,
559- RIO_MIN_CONNECTIONS ,
560- RIO_KEEP_CONNECTIONS ,
561- RIO_MAX_CONNECTIONS ,
562- 0 ,
563- redirectionio_pool_construct ,
564- redirectionio_pool_destruct ,
565- conf ,
566- pool
567- ) != APR_SUCCESS ) {
568- ap_log_perror (APLOG_MARK , APLOG_CRIT , 0 , pool , "mod_redirectionio: Failed to initialize resource pool, disabling redirectionio." );
569-
570- conf -> enable = 0 ;
571-
572- return conf ;
573- }
574-
575- apr_reslist_timeout_set (conf -> connection_pool , RIO_TIMEOUT );
576- apr_pool_cleanup_register (pool , conf -> connection_pool , redirectionio_child_exit , redirectionio_child_exit );
595+ conf -> pool = pool ;
596+ conf -> connection_pool = NULL ;
577597
578598 return conf ;
579599}
0 commit comments