@@ -81,6 +81,34 @@ static int redirectionio_match_handler(request_rec *r) {
81
81
return DECLINED ;
82
82
}
83
83
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
+
84
112
// Create context
85
113
redirectionio_context * ctx = ap_get_module_config (r -> request_config , & redirectionio_module );
86
114
@@ -96,6 +124,8 @@ static int redirectionio_match_handler(request_rec *r) {
96
124
return DECLINED ;
97
125
}
98
126
127
+ ctx -> matched_rule_id = NULL ;
128
+ ctx -> target = NULL ;
99
129
ctx -> status = 0 ;
100
130
ctx -> match_on_response_status = 0 ;
101
131
ctx -> is_redirected = 0 ;
@@ -446,6 +476,14 @@ static apr_status_t redirectionio_create_connection(redirectionio_connection *co
446
476
return rv ;
447
477
}
448
478
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
+
449
487
rv = apr_socket_opt_set (conn -> rio_sock , APR_TCP_NODELAY , 1 );
450
488
451
489
if (rv != APR_SUCCESS ) {
@@ -554,26 +592,8 @@ static void *merge_redirectionio_dir_conf(apr_pool_t *pool, void *parent, void *
554
592
conf -> pass_set = conf_current -> pass_set ;
555
593
}
556
594
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 ;
577
597
578
598
return conf ;
579
599
}
0 commit comments