Skip to content

Commit b870b2d

Browse files
committed
2.4.18: cater ap_timeout_parameter_parse for Apache 2.2
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent e8081a8 commit b870b2d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cfg/parse.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,18 @@ const char *oidc_cfg_parse_timeout_min_max(apr_pool_t *pool, const char *arg, ap
204204
apr_interval_time_t min_value, apr_interval_time_t max_value) {
205205
apr_interval_time_t timeout;
206206

207+
#if AP_MODULE_MAGIC_AT_LEAST(20080920, 2)
207208
if (ap_timeout_parameter_parse(arg, &timeout, "s") != APR_SUCCESS) {
208209
return apr_psprintf(pool, "not a valid timeout parameter: %s", arg);
209210
}
211+
#else
212+
timeout = apr_strtoi64(arg, &endptr, 10);
213+
if (errno != 0 || *endptr != '\0') {
214+
return apr_psprintf(pool, "not a valid timeout parameter: %s", arg);
215+
}
216+
timeout = apr_time_from_sec(timeout);
217+
#endif
218+
210219
if (timeout < min_value) {
211220
return apr_psprintf(pool,
212221
"timeout value %" APR_TIME_T_FMT

test/test_cfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ START_TEST(test_cfg_cache_connections_ttl) {
108108
rv = oidc_cmd_cache_memcache_ttl_set(cmd, ptr, arg);
109109
ck_assert_msg(rv != NULL, "set to 4295 did not fail");
110110

111-
arg = "180s";
111+
arg = "180";
112112
rv = oidc_cmd_cache_memcache_ttl_set(cmd, ptr, arg);
113113
ck_assert_msg(rv == NULL, "set to 180s failed");
114114

115115
ttl = oidc_cfg_cache_memcache_ttl_get(cfg);
116-
ck_assert_msg(ttl == apr_time_from_sec(180), "get 180s failed: %d", (int)ttl);
116+
ck_assert_msg(ttl == apr_time_from_sec(180), "get 180 failed: %d", (int)ttl);
117117
}
118118
END_TEST
119119

0 commit comments

Comments
 (0)