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

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