]> granicus.if.org Git - apache/commitdiff
Handle integer configuration directive parameters with a dedicated
authorChris Darroch <chrisd@apache.org>
Wed, 9 Apr 2008 18:01:53 +0000 (18:01 +0000)
committerChris Darroch <chrisd@apache.org>
Wed, 9 Apr 2008 18:01:53 +0000 (18:01 +0000)
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
modules/database/mod_dbd.c

diff --git a/CHANGES b/CHANGES
index 28d019d9318ccb69d2ffe2ab204d233e1a0a6ad9..6eb237ea53bf2c08ff0e952531d29811e5c69c3d 100644 (file)
--- 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]
index 5679b6e003d9bc22b109c50dd64103c973fc34c9..f1adfd41a28d7e20d570e485b788b9bdc94f2a42 100644 (file)
@@ -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}