From b64231e7353a0b2b38cdbde2571d31de88cbcc31 Mon Sep 17 00:00:00 2001 From: caodongxia <315816521@qq.com> Date: Tue, 10 Aug 2021 11:31:30 +0800 Subject: [PATCH] use default stack size for threads Refer: https://bugzilla.redhat.com/show_bug.cgi?id=1984808 --- CHANGELOG | 1 + daemon/automount.c | 29 ----------------------------- daemon/state.c | 6 +----- lib/alarm.c | 6 +----- 4 files changed, 3 insertions(+), 39 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 63ff767..e83ced2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,6 +33,7 @@ xx/xx/2018 autofs-5.1.5 - fix update_negative_cache() map source usage. - fix program usage message. - fix use after free in parse_ldap_config(). +- use default stack size for threads 19/12/2017 autofs-5.1.4 - fix spec file url. diff --git a/daemon/automount.c b/daemon/automount.c index f0d1f08..b867b06 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -83,7 +83,6 @@ static size_t kpkt_len; /* Attributes for creating detached and joinable threads */ pthread_attr_t th_attr; pthread_attr_t th_attr_detached; -size_t detached_thread_stack_size = PTHREAD_STACK_MIN * 144; struct master_readmap_cond mrc = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0}; @@ -2491,34 +2490,6 @@ int main(int argc, char *argv[]) exit(1); } -#ifdef _POSIX_THREAD_ATTR_STACKSIZE - if (pthread_attr_setstacksize( - &th_attr_detached, detached_thread_stack_size)) { - logerr("%s: failed to set stack size thread attribute!", - program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } - release_flag_file(); - macro_free_global_table(); - exit(1); - } -#endif - - if (pthread_attr_getstacksize( - &th_attr_detached, &detached_thread_stack_size)) { - logerr("%s: failed to get detached thread stack size!", - program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } - release_flag_file(); - macro_free_global_table(); - exit(1); - } - info(logging, "Starting automounter version %s, master map %s", version, master_list->name); info(logging, "using kernel protocol version %d.%02d", diff --git a/daemon/state.c b/daemon/state.c index 3d91f5b..9db7bf4 100644 --- a/daemon/state.c +++ b/daemon/state.c @@ -1215,12 +1215,8 @@ int st_start_handler(void) status = pthread_attr_init(pattrs); if (status) pattrs = NULL; - else { + else pthread_attr_setdetachstate(pattrs, PTHREAD_CREATE_DETACHED); -#ifdef _POSIX_THREAD_ATTR_STACKSIZE - pthread_attr_setstacksize(pattrs, PTHREAD_STACK_MIN*4); -#endif - } status = pthread_create(&thid, pattrs, st_queue_handler, NULL); diff --git a/lib/alarm.c b/lib/alarm.c index e6a880b..a32dc73 100755 --- a/lib/alarm.c +++ b/lib/alarm.c @@ -219,12 +219,8 @@ int alarm_start_handler(void) status = pthread_attr_init(pattrs); if (status) pattrs = NULL; - else { + else pthread_attr_setdetachstate(pattrs, PTHREAD_CREATE_DETACHED); -#ifdef _POSIX_THREAD_ATTR_STACKSIZE - pthread_attr_setstacksize(pattrs, PTHREAD_STACK_MIN*4); -#endif - } status = pthread_condattr_init(&condattrs); if (status) -- 2.27.0