r4584 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Feb 22 22:32:33 CET 2010
Author: phk
Date: 2010-02-22 22:32:33 +0100 (Mon, 22 Feb 2010)
New Revision: 4584
Modified:
trunk/varnish-cache/bin/varnishd/mgt_pool.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Sigh, POSIXed again: The minimum thread stack size is not a
compile time constant on all systems.
Pick it up with sysconf() instead.
Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-22 21:12:53 UTC (rev 4583)
+++ trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-22 21:32:33 UTC (rev 4584)
@@ -44,7 +44,10 @@
#include "svnid.h"
SVNID("$Id: cache_pool.c 3429 2008-11-24 17:47:21Z phk $")
+#include <stdio.h>
+#include <string.h>
#include <limits.h>
+#include <unistd.h>
#include <sys/types.h>
#include "cli_priv.h"
@@ -64,6 +67,33 @@
(unsigned)par->min, master.wthread_max);
}
+/*--------------------------------------------------------------------
+ * This is utterly ridiculous: POSIX does not guarantee that the
+ * minimum thread stack size is a compile time constant.
+ * XXX: "32" is a magic marker for 32bit systems.
+ */
+
+static void
+tweak_stack_size(struct cli *cli, const struct parspec *par,
+ const char *arg)
+{
+ unsigned low, u;
+ char buf[12];
+
+ low = sysconf(_SC_THREAD_STACK_MIN);
+
+ if (arg != NULL && !strcmp(arg, "32")) {
+ u = 65536;
+ if (u < low)
+ u = low;
+ sprintf(buf, "%u", u);
+ arg = buf;
+ }
+
+ tweak_generic_uint(cli, &master.wthread_stacksize, arg,
+ low, (uint)par->max);
+}
+
/*--------------------------------------------------------------------*/
static void
@@ -191,8 +221,7 @@
EXPERIMENTAL,
"3", "requests per request" },
{ "thread_pool_stack",
- tweak_uint, &master.wthread_stacksize,
- PTHREAD_STACK_MIN, UINT_MAX,
+ tweak_stack_size, &master.wthread_stacksize, 0, UINT_MAX,
"Worker thread stack size.\n"
"On 32bit systems you may need to tweak this down to fit "
"many threads into the limited address space.\n",
@@ -200,4 +229,3 @@
"-1", "bytes" },
{ NULL, NULL, NULL }
};
-
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-22 21:12:53 UTC (rev 4583)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-22 21:32:33 UTC (rev 4584)
@@ -588,10 +588,7 @@
MCF_ParamSet(cli, "sess_workspace", "16384");
cli_check(cli);
- /* Set the stacksize to min(PTHREAD_STACK_MIN, 64k) */
- bprintf(dirname, "%d",
- PTHREAD_STACK_MIN > 65536 ? PTHREAD_STACK_MIN : 65536);
- MCF_ParamSet(cli, "thread_pool_stack", dirname);
+ MCF_ParamSet(cli, "thread_pool_stack", "32");
cli_check(cli);
}
More information about the varnish-commit
mailing list