Blame SOURCES/autofs-5.1.2-increase-worker-thread-per-thread-stack-size.patch

306fa1
autofs-5.1.2 - increase worker thread per-thread stack size
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
automount(8) uses a worker thread per-thread stack size of 1M which is
306fa1
sufficient for its needs.
306fa1
306fa1
But some glibc functions (such as nscd_getgr_r()) use alloca() to allocate
306fa1
working storage that can have an arbitary size. Since alloca() never fails
306fa1
there is no way to check for stack overflow. This has been fixed in more
306fa1
recent versions of glibc.
306fa1
306fa1
But for older version of glibc all that can be done by automount to avoid
306fa1
this is to increase the stack size.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG          |    1 +
306fa1
 daemon/automount.c |   14 +++++++++++++-
306fa1
 2 files changed, 14 insertions(+), 1 deletion(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -247,6 +247,7 @@
306fa1
 - fix work around sss startup delay.
306fa1
 - improve scalability of direct mount path component.
306fa1
 - fix invalid reference in remount_active_mount().
306fa1
+- increase worker thread per-thread stack size.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/automount.c
306fa1
+++ autofs-5.0.7/daemon/automount.c
306fa1
@@ -81,6 +81,7 @@ static int cloexec_works = 0;
306fa1
 /* Attributes for creating detached and joinable threads */
306fa1
 pthread_attr_t th_attr;
306fa1
 pthread_attr_t th_attr_detached;
306fa1
+size_t detached_thread_stack_size = PTHREAD_STACK_MIN * 144;
306fa1
 
306fa1
 struct master_readmap_cond mrc = {
306fa1
 	PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0};
306fa1
@@ -2483,7 +2484,7 @@ int main(int argc, char *argv[])
306fa1
 
306fa1
 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
306fa1
 	if (pthread_attr_setstacksize(
306fa1
-			&th_attr_detached, PTHREAD_STACK_MIN*64)) {
306fa1
+			&th_attr_detached, detached_thread_stack_size)) {
306fa1
 		logerr("%s: failed to set stack size thread attribute!",
306fa1
 		       program);
306fa1
 		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
306fa1
@@ -2494,6 +2495,17 @@ int main(int argc, char *argv[])
306fa1
 	}
306fa1
 #endif
306fa1
 
306fa1
+	if (pthread_attr_getstacksize(
306fa1
+			&th_attr_detached, &detached_thread_stack_size)) {
306fa1
+		logerr("%s: failed to get detached thread stack size!",
306fa1
+		       program);
306fa1
+		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
306fa1
+		close(start_pipefd[1]);
306fa1
+		release_flag_file();
306fa1
+		macro_free_global_table();
306fa1
+		exit(1);
306fa1
+	}
306fa1
+
306fa1
 	info(logging, "Starting automounter version %s, master map %s",
306fa1
 		version, master_list->name);
306fa1
 	info(logging, "using kernel protocol version %d.%02d",