From 31735f8fe9b9508a8d414804e092d368c609573f Mon Sep 17 00:00:00 2001 From: Chris Darroch Date: Wed, 9 Apr 2008 18:01:53 +0000 Subject: [PATCH] Handle integer configuration directive parameters with a dedicated function, akin to dbd_param_flag(). Only needed when APR_HAS_THREADS. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@646453 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/database/mod_dbd.c | 43 +++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 28d019d931..6eb237ea53 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) mod_dbd: Handle integer configuration directive parameters with a + dedicated function. + *) Change the directives within the mod_session* modules to be valid both inside and outside the location/directory sections, as suggested by wrowe. [Graham Leggett] diff --git a/modules/database/mod_dbd.c b/modules/database/mod_dbd.c index 5679b6e003..f1adfd41a2 100644 --- a/modules/database/mod_dbd.c +++ b/modules/database/mod_dbd.c @@ -141,16 +141,6 @@ static void *merge_dbd_config(apr_pool_t *pool, void *basev, void *addv) return svr; } -#define ISINT(val) do { \ - const char *p; \ - \ - for (p = val; *p; ++p) { \ - if (!apr_isdigit(*p)) { \ - return "Argument must be numeric!"; \ - } \ - } \ - } while (0) - static const char *dbd_param(cmd_parms *cmd, void *dconf, const char *val) { const apr_dbd_driver_t *driver = NULL; @@ -185,32 +175,47 @@ static const char *dbd_param(cmd_parms *cmd, void *dconf, const char *val) case cmd_params: cfg->params = val; break; + } + + return NULL; +} + #if APR_HAS_THREADS +static const char *dbd_param_int(cmd_parms *cmd, void *dconf, const char *val) +{ + svr_cfg *svr = ap_get_module_config(cmd->server->module_config, + &dbd_module); + dbd_cfg_t *cfg = svr->cfg; + const char *p; + + for (p = val; *p; ++p) { + if (!apr_isdigit(*p)) { + return "Argument must be numeric!"; + } + } + + switch ((long) cmd->info) { case cmd_min: - ISINT(val); cfg->nmin = atoi(val); cfg->set |= NMIN_SET; break; case cmd_keep: - ISINT(val); cfg->nkeep = atoi(val); cfg->set |= NKEEP_SET; break; case cmd_max: - ISINT(val); cfg->nmax = atoi(val); cfg->set |= NMAX_SET; break; case cmd_exp: - ISINT(val); cfg->exptime = atoi(val); cfg->set |= EXPTIME_SET; break; -#endif } return NULL; } +#endif static const char *dbd_param_flag(cmd_parms *cmd, void *dconf, int flag) { @@ -250,15 +255,15 @@ static const command_rec dbd_cmds[] = { "SQL statement to prepare (or nothing, to override " "statement inherited from main server) and label"), #if APR_HAS_THREADS - AP_INIT_TAKE1("DBDMin", dbd_param, (void*)cmd_min, RSRC_CONF, + AP_INIT_TAKE1("DBDMin", dbd_param_int, (void*)cmd_min, RSRC_CONF, "Minimum number of connections"), /* XXX: note that mod_proxy calls this "smax" */ - AP_INIT_TAKE1("DBDKeep", dbd_param, (void*)cmd_keep, RSRC_CONF, + AP_INIT_TAKE1("DBDKeep", dbd_param_int, (void*)cmd_keep, RSRC_CONF, "Maximum number of sustained connections"), - AP_INIT_TAKE1("DBDMax", dbd_param, (void*)cmd_max, RSRC_CONF, + AP_INIT_TAKE1("DBDMax", dbd_param_int, (void*)cmd_max, RSRC_CONF, "Maximum number of connections"), /* XXX: note that mod_proxy calls this "ttl" (time to live) */ - AP_INIT_TAKE1("DBDExptime", dbd_param, (void*)cmd_exp, RSRC_CONF, + AP_INIT_TAKE1("DBDExptime", dbd_param_int, (void*)cmd_exp, RSRC_CONF, "Keepalive time for idle connections"), #endif {NULL} -- 2.40.0