From eea860a177a0e773d2478a9afcee09c6d1262867 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 8 Jun 2004 18:37:10 +0000 Subject: [PATCH] Convert pthread_attr_init() calls to slurm_attr_init() so as to set appropriate pthread stack size (required by AIX). --- src/srun/io.c | 2 +- src/srun/launch.c | 13 +++---------- src/srun/msg.c | 3 ++- src/srun/reattach.c | 31 +++++-------------------------- src/srun/signals.c | 12 +++--------- 5 files changed, 14 insertions(+), 47 deletions(-) diff --git a/src/srun/io.c b/src/srun/io.c index d0e000b4778..40cdf1a1ddf 100644 --- a/src/srun/io.c +++ b/src/srun/io.c @@ -538,7 +538,7 @@ io_thr_create(job_t *job) xsignal(SIGTTIN, SIG_IGN); - pthread_attr_init(&attr); + slurm_attr_init(&attr); if ((errno = pthread_create(&job->ioid, &attr, &io_thr, (void *) job))) return SLURM_ERROR; diff --git a/src/srun/launch.c b/src/srun/launch.c index 43c60e89913..8ed4f6ad9ea 100644 --- a/src/srun/launch.c +++ b/src/srun/launch.c @@ -36,6 +36,7 @@ #include <sys/param.h> #include "src/common/log.h" +#include "src/common/macros.h" #include "src/common/slurm_protocol_api.h" #include "src/common/xmalloc.h" #include "src/common/xsignal.h" @@ -81,7 +82,7 @@ launch_thr_create(job_t *job) int e; pthread_attr_t attr; - pthread_attr_init(&attr); + slurm_attr_init(&attr); if ((e = pthread_create(&job->lid, &attr, &launch, (void *) job))) slurm_seterrno_ret(e); @@ -210,19 +211,11 @@ static void _spawn_launch_thr(thd_t *th) pthread_attr_t attr; int err = 0; - if ((err = pthread_attr_init (&attr))) - fatal ("pthread_attr_init: %s", slurm_strerror(err)); - - + slurm_attr_init (&attr); err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (err) error ("pthread_attr_setdetachstate: %s", slurm_strerror(err)); -#ifdef PTHREAD_SCOPE_SYSTEM - if ((err = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM))) - error ("pthread_attr_setscope: %s", slurm_strerror(err)); -#endif - err = pthread_create(&th->thread, &attr, _p_launch_task, (void *)th); if (err) { error ("pthread_create: %s", slurm_strerror(err)); diff --git a/src/srun/msg.c b/src/srun/msg.c index 2c3691ef9d6..b755e892055 100644 --- a/src/srun/msg.c +++ b/src/srun/msg.c @@ -46,6 +46,7 @@ #include "src/common/fd.h" #include "src/common/hostlist.h" #include "src/common/log.h" +#include "src/common/macros.h" #include "src/common/read_config.h" #include "src/common/slurm_auth.h" #include "src/common/slurm_protocol_api.h" @@ -763,7 +764,7 @@ msg_thr_create(job_t *job) ntohs(((struct sockaddr_in)job->jaddr[i]).sin_port)); } - pthread_attr_init(&attr); + slurm_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if ((errno = pthread_create(&job->jtid, &attr, &msg_thr, (void *)job))) diff --git a/src/srun/reattach.c b/src/srun/reattach.c index fc06f867a56..ee0f11e45d6 100644 --- a/src/srun/reattach.c +++ b/src/srun/reattach.c @@ -41,6 +41,7 @@ #include "src/common/xsignal.h" #include "src/common/log.h" #include "src/common/list.h" +#include "src/common/macros.h" #include "src/common/hostlist.h" #include "src/common/slurm_protocol_api.h" @@ -328,30 +329,6 @@ _attach_to_job(job_t *job) return SLURM_SUCCESS; } -static int -_attr_init(pthread_attr_t *attr) -{ - int detached = PTHREAD_CREATE_DETACHED; - if ((errno = pthread_attr_init(attr)) < 0) { - error("pthread_attr_init: %m"); - return SLURM_ERROR; - } - - if ((errno = pthread_attr_setdetachstate(attr, detached)) < 0) { - error("pthread_attr_setdetachstate: %m"); - return SLURM_ERROR; - } - -#ifdef PTHREAD_SCOPE_SYSTEM - if (pthread_attr_setscope(attr, PTHREAD_SCOPE_SYSTEM) < 0) { - error("pthread_attr_setscope: %m"); - return SLURM_ERROR; - } -#endif - - return SLURM_SUCCESS; -} - static void _p_reattach(slurm_msg_t *msg, job_t *job) { @@ -370,8 +347,10 @@ _p_reattach(slurm_msg_t *msg, job_t *job) thd[i].msg = &msg[i]; thd[i].job = job; - if (_attr_init(&thd[i].attr) < 0) - exit(1); + slurm_attr_init(&thd[i].attr); + if (pthread_attr_setdetachstate(&thd[i].attr, + PTHREAD_CREATE_DETACHED ) < 0) + fatal("pthread_attr_setdetachstate: %m"); if (pthread_create( &thd[i].thread, &thd[i].attr, _p_reattach_task, (void *) &thd[i])) { diff --git a/src/srun/signals.c b/src/srun/signals.c index 959a852aefd..20035699a9f 100644 --- a/src/srun/signals.c +++ b/src/srun/signals.c @@ -39,6 +39,7 @@ #include <slurm/slurm_errno.h> #include "src/common/log.h" +#include "src/common/macros.h" #include "src/common/slurm_protocol_api.h" #include "src/common/slurm_protocol_defs.h" #include "src/common/xmalloc.h" @@ -119,7 +120,7 @@ sig_thr_create(job_t *job) int e; pthread_attr_t attr; - pthread_attr_init(&attr); + slurm_attr_init(&attr); if ((e = pthread_create(&job->sigid, &attr, &_sig_thr, job)) != 0) slurm_seterrno_ret(e); @@ -283,17 +284,10 @@ static void _p_fwd_signal(slurm_msg_t *req, job_t *job) tinfo->job_ptr = job; tinfo->host_inx = i; - if ((errno = pthread_attr_init(&thd[i].attr))) - error("pthread_attr_init failed"); - + slurm_attr_init(&thd[i].attr); if (pthread_attr_setdetachstate(&thd[i].attr, PTHREAD_CREATE_DETACHED)) error ("pthread_attr_setdetachstate failed"); - -#ifdef PTHREAD_SCOPE_SYSTEM - if (pthread_attr_setscope(&thd[i].attr, PTHREAD_SCOPE_SYSTEM)) - error ("pthread_attr_setscope failed"); -#endif if (pthread_create( &thd[i].thread, &thd[i].attr, _p_signal_task, (void *) tinfo )) { error ("pthread_create failed"); -- GitLab