]> granicus.if.org Git - apache/commitdiff
Make size of threadpool adjustable, even to the extent of
authorJim Jagielski <jim@apache.org>
Sat, 23 Jan 2016 17:37:37 +0000 (17:37 +0000)
committerJim Jagielski <jim@apache.org>
Sat, 23 Jan 2016 17:37:37 +0000 (17:37 +0000)
disabling it.

doccos to come.

PS: ProxyHCTPsize only available if APR has threads

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726418 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_hcheck.c

index e61af4d9dd37525510685bc5f5b69fef22c071e4..b1bdc1c946cad8c466fb058eca0e9ccbae39eb4c 100644 (file)
@@ -57,6 +57,7 @@ typedef struct {
     ap_watchdog_t *watchdog;
     apr_hash_t *hcworkers;
     apr_thread_pool_t *hctp;
+    int tpsize;
     server_rec *s;
 } sctx_t;
 
@@ -82,6 +83,7 @@ static void *hc_create_config(apr_pool_t *p, server_rec *s)
     ctx->templates = apr_array_make(p, 10, sizeof(hc_template_t));
     ctx->conditions = apr_table_make(p, 10);
     ctx->hcworkers = apr_hash_make(p);
+    ctx->tpsize = HC_THREADPOOL_SIZE;
     ctx->s = s;
 
     return ctx;
@@ -305,6 +307,25 @@ static const char *set_hc_template(cmd_parms *cmd, void *dummy, const char *arg)
     return NULL;
 }
 
+#if HC_USE_THREADS
+static const char *set_hc_tpsize (cmd_parms *cmd, void *dummy, const char *arg)
+{
+    sctx_t *ctx;
+
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_HTACCESS);
+    if (err)
+        return err;
+    ctx = (sctx_t *) ap_get_module_config(cmd->server->module_config,
+                                          &proxy_hcheck_module);
+
+    ctx->tpsize = atoi(arg);
+    if (ctx->tpsize < 0)
+        return "Invalid ProxyHCTPsize parameter. Parameter must be "
+               ">= 0";
+    return NULL;
+}
+#endif
+
 /*
  * Create a dummy request rec, simply so we can use ap_expr.
  * Use our short-lived poll for bucket_alloc
@@ -843,15 +864,26 @@ static apr_status_t hc_watchdog_callback(int state, void *data,
                          "%s watchdog started.",
                          HCHECK_WATHCHDOG_NAME);
 #if HC_USE_THREADS
-            rv =  apr_thread_pool_create(&ctx->hctp, HC_THREADPOOL_SIZE,
-                                         HC_THREADPOOL_SIZE,ctx->p);
-            if (rv != APR_SUCCESS) {
-                ap_log_error(APLOG_MARK, APLOG_INFO, rv, s, APLOGNO()
-                             "apr_thread_pool_create() with %d threads failed",
-                             HC_THREADPOOL_SIZE);
-                /* we can continue on without the threadpools */
+            if (ctx->tpsize) {
+                rv =  apr_thread_pool_create(&ctx->hctp, ctx->tpsize,
+                                             ctx->tpsize, ctx->p);
+                if (rv != APR_SUCCESS) {
+                    ap_log_error(APLOG_MARK, APLOG_INFO, rv, s, APLOGNO()
+                                 "apr_thread_pool_create() with %d threads failed",
+                                 ctx->tpsize);
+                    /* we can continue on without the threadpools */
+                    ctx->hctp = NULL;
+                } else {
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO()
+                                 "apr_thread_pool_create() with %d threads succeeded",
+                                 ctx->tpsize);
+                }
+            } else {
+                ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO()
+                             "Skipping apr_thread_pool_create()");
                 ctx->hctp = NULL;
             }
+
 #endif
             break;
 
@@ -1070,6 +1102,10 @@ static const command_rec command_table[] = {
                      "Health check template"),
     AP_INIT_RAW_ARGS("ProxyHCExpr", set_hc_condition, NULL, OR_FILEINFO,
                      "Define a health check condition ruleset expression"),
+#if HC_USE_THREADS
+    AP_INIT_TAKE1("ProxyHCTPsize", set_hc_tpsize, NULL, OR_FILEINFO,
+                     "Set size of health check thread pool"),
+#endif
     { NULL }
 };