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

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