diff --git a/auxdir/x_ac_debug.m4 b/auxdir/x_ac_debug.m4 index 755174fac1117cff94f564dd66a3b041eb59da7c..534353663fd7607d1fac59beae0d31e82fd7be08 100644 --- a/auxdir/x_ac_debug.m4 +++ b/auxdir/x_ac_debug.m4 @@ -5,53 +5,37 @@ # Chris Dunlap <cdunlap@llnl.gov> # # SYNOPSIS: -# AC_DEBUG +# X_AC_DEBUG # # DESCRIPTION: -# Adds support for the "--enable-debug" configure script option. -# If CFLAGS are not passed to configure, they will be set based -# on whether debugging has been enabled. Also, the NDEBUG macro -# (used by assert) will be set accordingly. +# Add support for the "--enable-debug" configure script option. +# If debugging is enabled, CFLAGS will be prepended with the debug flags. +# The NDEBUG macro (used by assert) will also be set accordingly. # # WARNINGS: # This macro must be placed after AC_PROG_CC or equivalent. ##***************************************************************************** -AC_DEFUN([X_AC_DEBUG], -[ +AC_DEFUN([X_AC_DEBUG], [ AC_MSG_CHECKING([whether debugging is enabled]) - AC_ARG_ENABLE([debug], - AC_HELP_STRING([--enable-debug], [enable debugging code for development]), + AC_ARG_ENABLE( + [debug], + AS_HELP_STRING([--enable-debug], [enable debugging code for development]), [ case "$enableval" in - yes) ac_debug=yes ;; - no) ac_debug=no ;; - *) AC_MSG_RESULT([doh!]) + yes) x_ac_debug=yes ;; + no) x_ac_debug=no ;; + *) AC_MSG_RESULT([doh!]) AC_MSG_ERROR([bad value "$enableval" for --enable-debug]) ;; esac ] ) -# -# if test -z "$ac_save_CFLAGS"; then -# test "$ac_cv_prog_cc_g" = yes && CFLAGS="-g $CFLAGS" -# fi -# - if test "$ac_debug" = yes; then - if test -z "$ac_save_CFLAGS"; then - test "$GCC" = yes && - CFLAGS="-g -Wall -fno-strict-aliasing $CFLAGS" - AC_DEFINE(DEBUG_SYSTEM, 1, [Define for extra debug messages.]) - fi + if test "$x_ac_debug" = yes; then + test "$GCC" = yes && CFLAGS="$CFLAGS -Wall -fno-strict-aliasing" else - if test -z "$ac_save_CFLAGS"; then - test "$GCC" = yes && - CFLAGS="-O2 -Wall -fno-strict-aliasing $CFLAGS" || - CFLAGS="-O3 $CFLAGS" - fi AC_DEFINE([NDEBUG], [1], - [Define to 1 if you are building a production release.]) + [Define to 1 if you are building a production release.] + ) fi - AC_MSG_RESULT([${ac_debug=no}]) -]) - - - + AC_MSG_RESULT([${x_ac_debug=no}]) + ] +) diff --git a/src/api/allocate.c b/src/api/allocate.c index 3c6c31816569aef3136503ce7c2d4cc4e9bcddbe..1ab7155ccc165cbb559d5b21b42ec541df7b0487 100644 --- a/src/api/allocate.c +++ b/src/api/allocate.c @@ -45,6 +45,7 @@ extern pid_t getsid(pid_t pid); /* missing from <unistd.h> */ #include "src/common/slurm_protocol_api.h" #include "src/common/hostlist.h" #include "src/common/xmalloc.h" +#include "src/common/forward.h" #define BUFFER_SIZE 1024 @@ -358,20 +359,16 @@ _handle_rc_msg(slurm_msg_t *msg) static int _nodelist_from_hostfile(job_step_create_request_msg_t *req) { char *hostfile = NULL; - char *hostname = NULL; FILE *hostfilep = NULL; char in_line[BUFFER_SIZE]; /* input line */ int i, j; int line_size; hostlist_t hostlist = NULL; - int count; - int len = 0; - int ret = 0; + int count = 0; int line_num = 0; char *nodelist = NULL; - int rc; - if (hostfile = getenv("SLURM_HOSTFILE")) { + if ((hostfile = getenv("SLURM_HOSTFILE"))) { if(strlen(hostfile)<1 || !strcmp(hostfile,"NULL")) goto no_hostfile; if((hostfilep = fopen(hostfile, "r")) == NULL) { diff --git a/src/api/job_info.c b/src/api/job_info.c index ec1591fff57deac8bd6dd92bba99fef793807e56..7395dd66d17d9c2f276d1d1748bcc0008853bb83 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -46,6 +46,7 @@ #include "src/common/slurm_protocol_api.h" #include "src/common/uid.h" #include "src/common/xstring.h" +#include "src/common/forward.h" /* * slurm_print_job_info_msg - output information about all Slurm diff --git a/src/api/partition_info.c b/src/api/partition_info.c index 65914678fecd5e230a6196d50453473822bc1a1b..526295c181af7becb174efd235fdab5cf3f1cf31 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -73,7 +73,7 @@ void slurm_print_partition_info ( FILE* out, partition_info_t * part_ptr, int one_liner ) { int j; - char tmp1[7], tmp2[7]; + char tmp1[7]; /****** Line 1 ******/ fprintf ( out, "PartitionName=%s ", part_ptr->name); diff --git a/src/api/pmi.c b/src/api/pmi.c index 065cc620c3f16405812271296e31bde75a9fd68a..b64d81af2710cc85f0012e25c3f6bac3c3b9cc28 100644 --- a/src/api/pmi.c +++ b/src/api/pmi.c @@ -1069,7 +1069,6 @@ int PMI_KVS_Commit( const char kvsname[] ) { struct kvs_comm_set kvs_set; int i, rc; - Buf buffer; if (pmi_debug) fprintf(stderr, "In: PMI_KVS_Commit\n"); diff --git a/src/api/reconfigure.c b/src/api/reconfigure.c index 503ad8e83ad600573f9cb9dac92a02bb8bac30ff..9f2f0381d8bc46995a17edbf064c1c0714e7aa04 100644 --- a/src/api/reconfigure.c +++ b/src/api/reconfigure.c @@ -38,6 +38,7 @@ #include <slurm/slurm.h> #include "src/common/slurm_protocol_api.h" +#include "src/common/forward.h" static int _send_message_controller ( enum controller_id dest, slurm_msg_t *request_msg ); diff --git a/src/api/signal.c b/src/api/signal.c index b12b91834fa5ce70f8b5e4c837fc6dc8fc324bad..2ad7c9854fa360e1ded1467246aa326da6595b7c 100644 --- a/src/api/signal.c +++ b/src/api/signal.c @@ -137,7 +137,7 @@ slurm_signal_job_step (uint32_t job_id, uint32_t step_id, uint16_t signal) job_step_info_response_msg_t *step_info; int rc; int i; - int save_errno; + int save_errno = 0; if (slurm_allocation_lookup(job_id, &alloc_info)) { return -1; @@ -203,7 +203,7 @@ _get_step_addresses(const job_step_info_t *step, num_nodes = hostset_count(step_nodes); addrs = xmalloc(sizeof(slurm_addr) * num_nodes); - while (hostname = hostlist_next(step_nodes_it)) { + while ((hostname = hostlist_next(step_nodes_it))) { i = hostset_index(alloc_nodes, hostname, 0); addrs[i] = allocation->node_addr[i]; free(hostname); @@ -267,9 +267,7 @@ static int _signal_batch_script_step( { slurm_msg_t msg; kill_tasks_msg_t rpc; - int num_nodes; int rc = SLURM_SUCCESS; - int i; rpc.job_id = allocation->job_id; rpc.job_step_id = SLURM_BATCH_SCRIPT; @@ -343,6 +341,8 @@ _p_send_recv_rc_msg(int messages, slurm_msg_t msg[], pthread_cond_destroy(&active_cond); pthread_mutex_destroy(&active_mutex); + + return (0); } static void * @@ -361,6 +361,8 @@ _thr_send_recv_rc_msg(void *args) (*active)--; pthread_cond_signal(cond); slurm_mutex_unlock(lock); + + return (NULL); } /* @@ -438,7 +440,7 @@ slurm_terminate_job_step (uint32_t job_id, uint32_t step_id) job_step_info_response_msg_t *step_info; int rc = 0; int i; - int save_errno; + int save_errno = 0; if (slurm_allocation_lookup(job_id, &alloc_info)) { return -1; @@ -611,7 +613,6 @@ static int _terminate_batch_script_step( { slurm_msg_t msg; kill_tasks_msg_t rpc; - int num_nodes; int rc = SLURM_SUCCESS; int i; diff --git a/src/api/slurm_pmi.c b/src/api/slurm_pmi.c index d00d4c7e194be53b30041a651ef9d203d2e10c5b..b57b7e8bd33edb3056f54ca60e89e1cc537ffce0 100644 --- a/src/api/slurm_pmi.c +++ b/src/api/slurm_pmi.c @@ -31,7 +31,10 @@ #include "src/api/slurm_pmi.h" #include "src/common/slurm_protocol_defs.h" #include "src/common/slurm_protocol_api.h" +#include "src/common/forward.h" +#include "src/common/read_config.h" #include "src/common/xmalloc.h" +#include "src/common/fd.h" int pmi_fd = -1; uint16_t srun_port = 0; @@ -105,7 +108,6 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr, char hostname[64]; uint16_t port; kvs_get_msg_t data; - List ret_list; if (kvs_set_ptr == NULL) return EINVAL; diff --git a/src/api/spawn.c b/src/api/spawn.c index b9d94a13aaf7c65553d7c78625cc97d645edf5cd..a72002d019513dc2b8fb9dbcbbc4ccb8c5dcfda2 100644 --- a/src/api/spawn.c +++ b/src/api/spawn.c @@ -94,7 +94,6 @@ static uint32_t threads_active = 0; /* currently active threads */ static void _dump_ctx(slurm_step_ctx ctx); #endif static int _envcount(char **env); -static void _free_char_array(char ***argv_p, int cnt); static int _p_launch(slurm_msg_t *req, slurm_step_ctx ctx); static int _sock_bind_wild(int sockfd); static void * _thread_per_node_rpc(void *args); @@ -421,7 +420,7 @@ extern int slurm_spawn (slurm_step_ctx ctx, int *fd_array) m->data = r; j=0; - while(host = hostlist_next(itr)) { + while((host = hostlist_next(itr))) { if(!strcmp(host,ctx->step_layout->host[i])) { free(host); break; @@ -766,19 +765,6 @@ static void _xfree_char_array(char ***argv_p, int cnt) xfree(*argv_p); } - -/* free an array of character strings as created by hostlist_shift */ -static void _free_char_array(char ***argv_p, int cnt) -{ - char **argv = *argv_p; - int i; - - for (i=0; i<cnt; i++) - free(argv[i]); - xfree(*argv_p); -} - - /* copy a character array, free with _xfree_char_array */ static void _xcopy_char_array(char ***argv_p, char **argv, int cnt) { diff --git a/src/common/dist_tasks.c b/src/common/dist_tasks.c index 74039bbfb50033364a91d5de0e83cbede4f98945..e58c17bec92bba2f5a9cace77c4507e407049f02 100644 --- a/src/common/dist_tasks.c +++ b/src/common/dist_tasks.c @@ -167,7 +167,6 @@ extern slurm_step_layout_t *step_layout_create( { slurm_step_layout_t *step_layout = NULL; char *temp = NULL; - hostlist_t hl; if(step_req && step_resp) { temp = step_req->node_list; @@ -292,11 +291,11 @@ extern int task_layout(slurm_step_layout_t *step_layout) /* use specific set run tasks on each host listed in hostfile + * XXX: Need to handle over-subscribe. */ static int _task_layout_hostfile(slurm_step_layout_t *step_layout) { int i=0, j, taskid = 0; - bool over_subscribe = false; hostlist_iterator_t itr = NULL, itr_task = NULL; char *host = NULL; char *host_task = NULL; @@ -307,9 +306,9 @@ static int _task_layout_hostfile(slurm_step_layout_t *step_layout) itr = hostlist_iterator_create(job_alloc_hosts); step_alloc_hosts = hostlist_create(step_layout->step_nodes); itr_task = hostlist_iterator_create(step_alloc_hosts); - while(host = hostlist_next(itr)) { + while((host = hostlist_next(itr))) { step_layout->tasks[i] = 0; - while(host_task = hostlist_next(itr_task)) { + while((host_task = hostlist_next(itr_task))) { if(!strcmp(host, host_task)) step_layout->tasks[i]++; free(host_task); @@ -324,7 +323,7 @@ static int _task_layout_hostfile(slurm_step_layout_t *step_layout) taskid = 0; j = 0; hostlist_iterator_reset(itr_task); - while(host_task = hostlist_next(itr_task)) { + while((host_task = hostlist_next(itr_task))) { if(!strcmp(host, host_task)) { step_layout->tids[i][j] = taskid; j++; diff --git a/src/common/eio.c b/src/common/eio.c index 671f34f39f81767e45cef3bea23767f01dda80a9..3a128466f521392564059e7d8825c553e46e9095 100644 --- a/src/common/eio.c +++ b/src/common/eio.c @@ -117,7 +117,7 @@ static void _mark_shutdown_true(List obj_list) eio_obj_t *obj; objs = list_iterator_create(obj_list); - while (obj = list_next(objs)) { + while ((obj = list_next(objs))) { obj->shutdown = true; } list_iterator_destroy(objs); @@ -135,7 +135,7 @@ static int _eio_wakeup_handler(eio_handle_t *eio) } /* move new eio objects from the new_objs to the obj_list */ - while (obj = list_dequeue(eio->new_objs)) { + while ((obj = list_dequeue(eio->new_objs))) { list_enqueue(eio->obj_list, obj); } diff --git a/src/common/env.c b/src/common/env.c index f20570931dfb909070421be1f76b87613001e75a..6e14704c7385e179cbc0f60ee13de1594800be7a 100644 --- a/src/common/env.c +++ b/src/common/env.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> #include <string.h> #include "slurm/slurm.h" @@ -40,6 +41,8 @@ #include "src/common/xassert.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" +#include "src/common/node_select.h" +#include "src/common/slurm_protocol_api.h" /* * Define slurm-specific aliases for use by plugins, see slurm_xlator.h diff --git a/src/common/forward.c b/src/common/forward.c index 09d05b62f6fc5bdc3e60c3acd063083ef5458f65..7deaa1b386e9de4e003472a2859f34afb640d7a5 100644 --- a/src/common/forward.c +++ b/src/common/forward.c @@ -32,6 +32,7 @@ #include <errno.h> #include <stdio.h> #include <unistd.h> +#include <stdlib.h> #include <sys/types.h> #include <slurm/slurm.h> @@ -39,6 +40,7 @@ #include "src/common/forward.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" +#include "src/common/slurm_protocol_interface.h" #ifdef WITH_PTHREADS # include <pthread.h> @@ -50,9 +52,7 @@ void *_forward_thread(void *arg) { forward_msg_t *fwd_msg = (forward_msg_t *)arg; Buf buffer = init_buf(0); - int retry = 0; int i=0; - int rc = SLURM_SUCCESS; List ret_list = NULL; ret_types_t *type = NULL; ret_types_t *returned_type = NULL; @@ -151,8 +151,8 @@ nothing_sent: itr = list_iterator_create(fwd_msg->ret_list); while((type = (ret_types_t *) list_next(itr)) != NULL) { if(type->msg_rc == returned_type->msg_rc) { - while(ret_data_info = - list_pop(returned_type->ret_data_list)) { + while((ret_data_info = + list_pop(returned_type->ret_data_list))) { list_push(type->ret_data_list, ret_data_info); } @@ -168,8 +168,8 @@ nothing_sent: type->msg_rc = returned_type->msg_rc; type->err = returned_type->err; type->ret_data_list = list_create(destroy_data_info); - while(ret_data_info = - list_pop(returned_type->ret_data_list)) { + while((ret_data_info = + list_pop(returned_type->ret_data_list))) { list_push(type->ret_data_list, ret_data_info); } } @@ -183,6 +183,8 @@ cleanup: free_buf(buffer); pthread_cond_signal(fwd_msg->notify); slurm_mutex_unlock(fwd_msg->forward_mutex); + + return (NULL); } /* @@ -391,7 +393,7 @@ extern int forward_set_launch(forward_t *forward, while(j<span && ((*pos+j) < total)) { i=0; - while(host = hostlist_next(itr)) { + while((host = hostlist_next(itr))) { if(!strcmp(host, step_layout->host[*pos+j])) { free(host); diff --git a/src/common/global_srun.c b/src/common/global_srun.c index dd7aefbd26154db920470321baebddc1d461406d..8de6f82a4a3f0de511ed01b3f3b98985c686c60a 100644 --- a/src/common/global_srun.c +++ b/src/common/global_srun.c @@ -44,6 +44,7 @@ #include "src/common/slurm_protocol_defs.h" #include "src/common/xmalloc.h" #include "src/common/xsignal.h" +#include "src/common/forward.h" #include "src/common/global_srun.h" /* number of active threads */ @@ -223,8 +224,8 @@ static void * _p_signal_task(void *args) if ((rc != 0) && (rc != ESLURM_INVALID_JOB_ID) && (rc != ESLURMD_JOB_NOTRUNNING) && (rc != ESRCH)) { if(!host) { - while(ret_data_info - = list_pop(ret_type->ret_data_list)) { + while((ret_data_info + = list_pop(ret_type->ret_data_list))) { error("%s: signal: %s", ret_data_info->node_name, slurm_strerror(rc)); diff --git a/src/common/io_hdr.c b/src/common/io_hdr.c index 835a17870606d2a2518f9ac921aec401367a4e16..56f19daec142fcd4defb79fef99e550cad9a71bd 100644 --- a/src/common/io_hdr.c +++ b/src/common/io_hdr.c @@ -61,8 +61,6 @@ io_hdr_pack(io_hdr_t *hdr, Buf buffer) int io_hdr_unpack(io_hdr_t *hdr, Buf buffer) { - uint16_t val; - safe_unpack16(&hdr->type, buffer); safe_unpack16(&hdr->gtaskid, buffer); safe_unpack16(&hdr->ltaskid, buffer); @@ -119,7 +117,6 @@ int io_hdr_read_fd(int fd, io_hdr_t *hdr) { Buf buffer; int n = 0; - int rc; debug3("Entering io_hdr_read_fd"); buffer = init_buf(io_hdr_packed_size()); diff --git a/src/common/macros.h b/src/common/macros.h index e1a5dad0e944471603dbda41f400e8aa18feca93..733a2ac5bb4938f1c9ee87ffd3c2aaaa731b528a 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -42,6 +42,10 @@ typedef enum {false, true} bool; #endif /* !HAVE_STDBOOL_H */ +#if HAVE_PTHREAD_H +# include <pthread.h> +#endif + #include <errno.h> /* for errno */ #include "src/common/log.h" /* for error() */ diff --git a/src/common/mpi.c b/src/common/mpi.c index 6e56ec19887453a1764896ee8f3d91ee27f83aac..ba668b3d4fd7db2cd24f736097151bc6d43508ec 100644 --- a/src/common/mpi.c +++ b/src/common/mpi.c @@ -197,7 +197,7 @@ int _mpi_init (char *mpi_type) setenvf (NULL, "SLURM_MPI_TYPE", "%s", mpi_type); full_type = xmalloc(sizeof(char) * (strlen(mpi_type)+5)); - sprintf(full_type,"mpi/%s\0",mpi_type); + sprintf(full_type,"mpi/%s",mpi_type); g_context = _slurm_mpi_context_create(full_type); xfree(full_type); diff --git a/src/common/node_select.h b/src/common/node_select.h index a32a71318a9eee8dc44efadf7b36fab4f84cdf96..e8b91cf0b11776f57c8d9d65056b1098c9decf98 100644 --- a/src/common/node_select.h +++ b/src/common/node_select.h @@ -119,6 +119,9 @@ extern int select_g_block_init(List part_list); */ extern int select_g_job_init(List job_list); + +extern int select_g_block_init(List part_list); + /******************************************************\ * JOB-SPECIFIC SELECT CREDENTIAL MANAGEMENT FUNCIONS * \******************************************************/ diff --git a/src/common/pack.h b/src/common/pack.h index 72f917bfe2fa98e4abedf875d305a0fd77404278..588bca7133e2f525dfd8aab90df4c7f123e1e036 100644 --- a/src/common/pack.h +++ b/src/common/pack.h @@ -242,6 +242,12 @@ int unpackmem_array(char *valp, uint32_t size_valp, Buf buffer); packmem(str,(uint16_t)_size,buf); \ } while (0) +#define packnull(buf) do { \ + assert(buf != NULL); \ + assert(buf->magic == BUF_MAGIC); \ + packmem(NULL, 0, buf); \ +} while (0) + #define pack_bit_fmt(bitmap,buf) do { \ assert(buf->magic == BUF_MAGIC); \ if (bitmap) { \ diff --git a/src/common/parse_config.c b/src/common/parse_config.c index 1a8050daec3f53b322eb19a5b7c690cd1efb1b68..f8dd0f2848164b040b39fe16cbd5b476acf98844 100644 --- a/src/common/parse_config.c +++ b/src/common/parse_config.c @@ -36,6 +36,7 @@ #include <sys/types.h> #include <regex.h> #include <stdint.h> +#include <stdlib.h> #include <ctype.h> /* #include "src/common/slurm_protocol_defs.h" */ @@ -207,8 +208,8 @@ static void _keyvalue_regex_init(void) /* * IN line - string to be search for a key=value pair - * OUT key - pointer to the key string (caller must free with free()) - * OUT value - pointer to the value string (caller must free with free()) + * OUT key - pointer to the key string (caller must free with xfree()) + * OUT value - pointer to the value string (caller must free with xfree()) * OUT remaining - pointer into the "line" string denoting the start * of the unsearched portion of the string * Return 0 when a key-value pair is found, and -1 otherwise. @@ -216,11 +217,8 @@ static void _keyvalue_regex_init(void) static int _keyvalue_regex(const char *line, char **key, char **value, char **remaining) { - size_t nmatch = 8; - regmatch_t pmatch[8]; - char *start; - size_t len; - char *match; + size_t nmatch = 8; + regmatch_t pmatch[8]; *key = NULL; *value = NULL; @@ -667,7 +665,7 @@ int s_p_parse_line(s_p_hashtbl_t *hashtbl, const char *line) _keyvalue_regex_init(); while (_keyvalue_regex(ptr, &key, &value, &leftover) == 0) { - if (p = _conf_hashtbl_lookup(hashtbl, key)) { + if ((p = _conf_hashtbl_lookup(hashtbl, key))) { _handle_keyvalue_match(p, value, line); ptr = leftover; } else { @@ -695,7 +693,6 @@ void s_p_parse_file(s_p_hashtbl_t *hashtbl, char *filename) { FILE *f; char line[BUFFER_SIZE]; - char *key, *value, *leftover; _keyvalue_regex_init(); @@ -1009,7 +1006,7 @@ void s_p_dump_values(const s_p_hashtbl_t *hashtbl, void *ptr; void **ptr_array; int count; - int i; + bool flag; for (op = options; op->key != NULL; op++) { switch(op->type) { @@ -1053,6 +1050,16 @@ void s_p_dump_values(const s_p_hashtbl_t *hashtbl, verbose("%s", op->key); } break; + case S_P_BOOLEAN: + if (s_p_get_boolean(&flag, op->key, hashtbl)) { + verbose("%s = %s", op->key, + flag ? "TRUE" : "FALSE"); + } else { + verbose("%s", op->key); + } + break; + case S_P_IGNORE: + break; } } } diff --git a/src/common/parse_time.c b/src/common/parse_time.c index 0cce3bc0a85c56b6f042290ad42483dc307a8dda..df12b3385e5fe136327b04d9d3b7b6f8db44c61a 100644 --- a/src/common/parse_time.c +++ b/src/common/parse_time.c @@ -28,6 +28,8 @@ #include <stdio.h> #include <time.h> #include <strings.h> +#define __USE_ISOC99 /* isblank() */ +#include <ctype.h> #define _RUN_STAND_ALONE 0 @@ -42,7 +44,7 @@ struct tm *time_now_tm; */ static int _get_delta(char *time_str, int *pos, long *delta) { - int i, offset, rc = 0; + int offset; long cnt = 0; offset = (*pos) + 1; @@ -215,10 +217,9 @@ static int _get_date(char *time_str, int *pos, int *month, int *mday, int *year) */ extern time_t parse_time(char *time_str) { - time_t delta = (time_t) 0; int hour = -1, minute = -1, second = 0; int month = -1, mday = -1, year = -1; - int num = 0, pos = 0; + int pos = 0; struct tm res_tm; time_now = time(NULL); diff --git a/src/common/read_config.c b/src/common/read_config.c index d7d4a63453dc28c7f02b0fec45f2f8c647270363..02fbc4600d23abd2f761d60ae3bb97f2dfb6e337 100644 --- a/src/common/read_config.c +++ b/src/common/read_config.c @@ -46,6 +46,7 @@ #include "src/common/hostlist.h" #include "src/common/slurm_protocol_defs.h" +#include "src/common/slurm_protocol_api.h" #include "src/common/log.h" #include "src/common/macros.h" #include "src/common/parse_spec.h" @@ -85,8 +86,12 @@ struct slurmd_port { hostset_t aliases; /* NodeName */ uint16_t port; }; + +/* Not used now static struct slurmd_port *slurmd_port_array; static int slurmd_port_array_count; +*/ + #define NAME_HASH_LEN 512 typedef struct names_ll_s { @@ -858,6 +863,7 @@ extern slurm_addr slurm_conf_get_addr(const char *node_name) { int idx; names_ll_t *p; + slurm_addr unknown; _init_slurmd_nodehash(); @@ -876,6 +882,8 @@ extern slurm_addr slurm_conf_get_addr(const char *node_name) /* FIXME - needs to return a success/fail flag, and set address through a parameter */ + memset(&unknown, 0, sizeof(slurm_addr)); + return unknown; } diff --git a/src/common/slurm_cred.c b/src/common/slurm_cred.c index 8b2962c735044cc9402c0016448bebda0a689073..2e2aa8acf5dd533fe5de9b0725cdb7a2fd544141 100644 --- a/src/common/slurm_cred.c +++ b/src/common/slurm_cred.c @@ -408,13 +408,13 @@ slurm_cred_copy(slurm_cred_t cred) rcred->stepid = cred->stepid; rcred->uid = cred->uid; rcred->nodes = xstrdup(cred->nodes); - rcred->ntask_cnt = cred->ntask_cnt; - rcred->ntask = NULL; - if (rcred->ntask_cnt > 0) { - rcred->ntask = xmalloc(rcred->ntask_cnt * sizeof(int)); - memcpy(rcred->ntask, cred->ntask, - rcred->ntask_cnt * sizeof(int)); - } + rcred->ntask_cnt = cred->ntask_cnt; + rcred->ntask = NULL; + if (rcred->ntask_cnt > 0) { + rcred->ntask = xmalloc(rcred->ntask_cnt * sizeof(int)); + memcpy(rcred->ntask, cred->ntask, + rcred->ntask_cnt * sizeof(int)); + } rcred->ctime = cred->ctime; rcred->signature = (unsigned char *)xstrdup((char *)cred->signature); @@ -422,12 +422,6 @@ slurm_cred_copy(slurm_cred_t cred) slurm_mutex_unlock(&rcred->mutex); return rcred; - - fail: - slurm_mutex_unlock(&cred->mutex); - slurm_mutex_unlock(&rcred->mutex); - slurm_cred_destroy(rcred); - return NULL; } slurm_cred_t diff --git a/src/common/slurm_jobacct.c b/src/common/slurm_jobacct.c index 637c2b17c1ebb21aedf9e567e780358078ff4c56..7ff4afaaf1784bb126125b2c95d3247b965a0480 100644 --- a/src/common/slurm_jobacct.c +++ b/src/common/slurm_jobacct.c @@ -54,7 +54,7 @@ * The following global is used by the jobacct/log plugin; it must * persist when the plugin is reloaded, so we define it here. */ -extern FILE * JOBACCT_LOGFILE = NULL; +extern FILE * JOBACCT_LOGFILE; /* * WARNING: Do not change the order of these fields or add additional diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 74b0b0a352be8f8bf21b3e16d1f25f1f242186b3..298a7e020e724c29c64b9f1d91aa626fb35091ca 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -701,10 +701,7 @@ List slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout) forward_struct_t *forward_struct = NULL; ret_types_t *ret_type = NULL; ListIterator itr; - int i=0; int16_t fwd_cnt = 0; - char addrbuf[INET_ADDRSTRLEN]; - int steps = 0; List ret_list = list_create(destroy_ret_types); @@ -1254,8 +1251,6 @@ void slurm_print_slurm_addr(slurm_addr * address, char *buf, size_t n) Buf slurm_pack_msg_no_header(slurm_msg_t * msg) { Buf buffer = NULL; - void * auth_cred; - int rc; buffer = init_buf(0); @@ -1264,8 +1259,6 @@ Buf slurm_pack_msg_no_header(slurm_msg_t * msg) */ pack_msg(msg, buffer); -ret_error: - return buffer; } @@ -1543,7 +1536,6 @@ int slurm_send_only_node_msg(slurm_msg_t *req) */ static List _send_recv_rc_msg(slurm_fd fd, slurm_msg_t *req, int timeout) { - int retval = SLURM_SUCCESS; slurm_msg_t msg; List ret_list = NULL; ListIterator itr = NULL; @@ -1834,11 +1826,11 @@ int convert_to_kilo(int number, char *tmp) if(i > 0) { i *= 10; i /= 1024; - sprintf(tmp, "%d.%dk\0", number/1024, i); + sprintf(tmp, "%d.%dk", number/1024, i); } else - sprintf(tmp, "%dk\0", number/1024); + sprintf(tmp, "%dk", number/1024); } else - sprintf(tmp, "%d\0", number); + sprintf(tmp, "%d", number); return SLURM_SUCCESS; } diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index 639b39945f0cd1bf05c305a168dde7a671314509..02804084582e98139e1f70450ddf0b749ca030a6 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -2175,8 +2175,6 @@ _unpack_slurm_ctl_conf_msg(slurm_ctl_conf_info_msg_t ** static void _pack_job_desc_msg(job_desc_msg_t * job_desc_ptr, Buf buffer) { - select_jobinfo_t jobinfo; - /* load the data values */ pack16((uint16_t)job_desc_ptr->contiguous, buffer); pack16((uint16_t)job_desc_ptr->exclusive, buffer); diff --git a/src/common/switch.h b/src/common/switch.h index 1bbeeb897b609f3d82809c0f42d01149f88704f1..b1f3216701290b5f40a36a76f81052fbb0b8faa7 100644 --- a/src/common/switch.h +++ b/src/common/switch.h @@ -56,6 +56,8 @@ typedef struct slurm_switch_context * slurm_switch_context_t; /* initialize the switch plugin */ extern int switch_init (void); +extern int switch_g_slurmd_init(void); + /* terminate the switch plugin and free all memory */ extern int switch_fini (void); @@ -279,6 +281,11 @@ extern int interconnect_attach(switch_jobinfo_t jobinfo, char ***env, */ extern int switch_g_clear_node_state(void); +/* + * Initialize slurmd step switch state + */ +extern int switch_g_slurmd_step_init(void); + /* * Allocate storage for a node's switch state record */ diff --git a/src/plugins/mpi/mpichgm/mpichgm.c b/src/plugins/mpi/mpichgm/mpichgm.c index 6195c227a056d90ae9fb437ba841929c142d649e..65a1ce89d8022811feafc42fada2572590870381 100644 --- a/src/plugins/mpi/mpichgm/mpichgm.c +++ b/src/plugins/mpi/mpichgm/mpichgm.c @@ -34,6 +34,7 @@ #endif #include <signal.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -42,6 +43,7 @@ #include "src/common/xmalloc.h" #include "src/common/xstring.h" #include "src/common/net.h" +#include "src/common/global_srun.h" #include "src/plugins/mpi/mpichgm/mpichgm.h" @@ -62,7 +64,6 @@ static int _gmpi_parse_init_recv_msg(srun_job_t *job, char *rbuf, gm_slave_t *slave_data); static int gmpi_fd = -1; -static int gmpi_port = -1; static int _gmpi_parse_init_recv_msg(srun_job_t *job, char *rbuf, gm_slave_t *slave_data) diff --git a/src/plugins/mpi/mvapich/mvapich.c b/src/plugins/mpi/mvapich/mvapich.c index ed0d3188ba9aabfd226bc6ec483fb9553b2be236..03081c20e2142a6fd22a02e77c8cdda4ddeef44b 100644 --- a/src/plugins/mpi/mvapich/mvapich.c +++ b/src/plugins/mpi/mvapich/mvapich.c @@ -42,6 +42,8 @@ #include "src/common/xmalloc.h" #include "src/common/xstring.h" #include "src/common/net.h" +#include "src/common/fd.h" +#include "src/common/global_srun.h" /* NOTE: MVAPICH has changed protocols without changing version numbers. * This makes support of MVAPICH very difficult. @@ -108,8 +110,6 @@ static void mvapich_info_destroy (struct mvapich_info *mvi); */ static struct mvapich_info * mvapich_info_create (int fd) { - int n; - unsigned char host[4]; struct mvapich_info *mvi = xmalloc (sizeof (*mvi)); mvi->fd = fd; @@ -335,7 +335,6 @@ static void *mvapich_thr(void *arg) extern int mvapich_thr_create(srun_job_t *job) { int port; - char name[128]; pthread_attr_t attr; pthread_t tid; diff --git a/src/plugins/mpi/none/mpi_none.c b/src/plugins/mpi/none/mpi_none.c index 4eec1a283f890434cb20955820af30c8e5545148..46d6ddd35941b8cd21fc9520cb986cff7ebc41ae 100644 --- a/src/plugins/mpi/none/mpi_none.c +++ b/src/plugins/mpi/none/mpi_none.c @@ -35,10 +35,10 @@ #include <slurm/slurm_errno.h> +#include "src/common/slurm_xlator.h" #include "src/srun/srun_job.h" #include "src/slurmd/slurmstepd/slurmstepd_job.h" #include "src/common/env.h" -#include "src/common/slurm_xlator.h" /* * These variables are required by the generic plugin interface. If they diff --git a/src/plugins/proctrack/linuxproc/kill_tree.c b/src/plugins/proctrack/linuxproc/kill_tree.c index 8c239e2ed853a576d650b235e6095a8194de4df9..77470d238cf1cb1fd7be2df8b44db52254d01e3d 100644 --- a/src/plugins/proctrack/linuxproc/kill_tree.c +++ b/src/plugins/proctrack/linuxproc/kill_tree.c @@ -44,6 +44,7 @@ #include "src/common/xmalloc.h" #include "src/common/xstring.h" #include "src/common/log.h" +#include "kill_tree.h" typedef struct xpid_s { pid_t pid; @@ -123,7 +124,7 @@ static int get_myname(char *s) return -1; } close(fd); - if (sscanf(rbuf, "%*ld %s ", s) != 1) { + if (sscanf(rbuf, "%*d %s ", s) != 1) { error("Cannot get the command name from /proc/getpid()/stat"); return -1; } @@ -297,7 +298,7 @@ extern pid_t find_ancestor(pid_t process, char *process_name) return 0; } - sprintf(path, "/proc/%d/stat", ppid); + sprintf(path, "/proc/%ld/stat", ppid); if ((fd = open(path, O_RDONLY)) < 0) { return 0; } @@ -310,7 +311,7 @@ extern pid_t find_ancestor(pid_t process, char *process_name) return 0; } - sprintf(path, "/proc/%d/cmdline", pid); + sprintf(path, "/proc/%ld/cmdline", pid); if ((fd = open(path, O_RDONLY)) < 0) { continue; } diff --git a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c index 3b78c896c7598b78dc85b8f65d5f13750728508e..a5e2e53e9d63a63af40cd5de1d513a4c99a7e319 100644 --- a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c +++ b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c @@ -40,6 +40,7 @@ #include <slurm/slurm_errno.h> #include "src/common/log.h" #include "src/slurmd/slurmstepd/slurmstepd_job.h" +#include "kill_tree.h" /* * These variables are required by the generic plugin interface. If they diff --git a/src/plugins/proctrack/pgid/proctrack_pgid.c b/src/plugins/proctrack/pgid/proctrack_pgid.c index 64bb95e68fa6fad6fb4d7181f4fc564679e068d0..68c5cbb50be46d8e0ed59fecf3ba179af19f4ef2 100644 --- a/src/plugins/proctrack/pgid/proctrack_pgid.c +++ b/src/plugins/proctrack/pgid/proctrack_pgid.c @@ -35,10 +35,12 @@ # include <inttypes.h> #endif +#define __USE_XOPEN_EXTENDED /* getpgid */ +#include <unistd.h> + #include <sys/types.h> #include <signal.h> #include <stdlib.h> -#include <unistd.h> #include <slurm/slurm.h> #include <slurm/slurm_errno.h> #include "src/common/log.h" diff --git a/src/plugins/proctrack/rms/proctrack_rms.c b/src/plugins/proctrack/rms/proctrack_rms.c index 9b94cdacb07e6755eb7560868e44f4dcaf44bd8b..2aad0c842befcb241aeef275eb0a77dffdf9352a 100644 --- a/src/plugins/proctrack/rms/proctrack_rms.c +++ b/src/plugins/proctrack/rms/proctrack_rms.c @@ -36,6 +36,7 @@ #include <rms/rmscall.h> #include <sys/types.h> +#include <sys/wait.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> @@ -114,8 +115,6 @@ extern int slurm_container_signal (uint32_t id, int signal) int nids = 0; int i; int rc; - int ids[MAX_IDS]; - bool cont_exists = false; if (id <= 0) return -1; @@ -156,10 +155,6 @@ extern int slurm_container_signal (uint32_t id, int signal) */ extern int slurm_container_destroy (uint32_t id) { - pid_t pids[8]; - int nids = 0; - int i; - debug2("proctrack/rms: destroying container %u\n", id); if (id == 0) return SLURM_SUCCESS; diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.c b/src/plugins/select/bluegene/block_allocator/block_allocator.c index 8f8d9a3e4ce44b48f3e79e4de57e0444f52d541e..628fe56e48a8d1dd0d5a2d6aadbd89be2ef98fda 100644 --- a/src/plugins/select/bluegene/block_allocator/block_allocator.c +++ b/src/plugins/select/bluegene/block_allocator/block_allocator.c @@ -554,11 +554,7 @@ static void _db2_check(void) */ extern void ba_init(node_info_msg_t *node_info_ptr) { - node_info_t *node_ptr = NULL; - int start, temp; - char *numeric = NULL; int x,y,z; - #ifdef HAVE_BG int i; #endif @@ -607,6 +603,9 @@ extern void ba_init(node_info_msg_t *node_info_ptr) if(node_info_ptr!=NULL) { #ifdef HAVE_BG + node_info_t *node_ptr = NULL; + int start, temp; + char *numeric = NULL; for (i = 0; i < node_info_ptr->record_count; i++) { node_ptr = &node_info_ptr->node_array[i]; start = 0; @@ -647,7 +646,9 @@ extern void ba_init(node_info_msg_t *node_info_ptr) #endif ba_system_ptr->num_of_proc = node_info_ptr->record_count; } +#ifdef HAVE_BG node_info_error: +#endif #ifdef HAVE_BG_FILES if (have_db2 && (DIM_SIZE[X]==0) || (DIM_SIZE[Y]==0) || (DIM_SIZE[Z]==0)) { @@ -934,10 +935,8 @@ extern char *set_bg_block(List results, int *start, { char *name = NULL; ba_node_t* ba_node = NULL; - int size = 0; + int size = 0; int send_results = 0; - List start_list = NULL; - ListIterator itr; int found = 0; if(!results) @@ -996,6 +995,9 @@ extern char *set_bg_block(List results, int *start, } if(found) { #ifdef HAVE_BG + List start_list = NULL; + ListIterator itr; + start_list = list_create(NULL); itr = list_iterator_create(results); while((ba_node = (ba_node_t*) list_next(itr))) { @@ -2003,7 +2005,9 @@ static int _find_match(ba_request_t *ba_request, List results) #endif return 0; +#ifdef HAVE_BG start_again: +#endif x=0; if(x == startx) x = startx-1; @@ -2016,7 +2020,9 @@ start_again: ba_request->geometry[Z], #endif x); +#ifdef HAVE_BG new_node: +#endif debug2("starting at %d%d%d", start[X] #ifdef HAVE_BG @@ -2435,7 +2441,7 @@ static char *_set_internal_wires(List nodes, int size, int conn_type) return NULL; itr = list_iterator_create(nodes); while((ba_node[count] = (ba_node_t*) list_next(itr))) { - sprintf(name, "%d%d%d\0", + sprintf(name, "%d%d%d", ba_node[count]->coord[X], ba_node[count]->coord[Y], ba_node[count]->coord[Z]); @@ -2496,11 +2502,10 @@ static int _find_x_path(List results, ba_node_t *ba_node, int port_tar; int source_port=0; int target_port=0; - int num_visited=0; int broke = 0, not_first = 0; int ports_to_try[2] = {3,5}; int *node_tar = NULL; - int i, i2; + int i; ba_node_t *next_node = NULL; ba_node_t *check_node = NULL; int highest_phys_x = geometry[X] - start[X]; @@ -2807,11 +2812,10 @@ static int _find_x_path2(List results, ba_node_t *ba_node, int port_tar; int source_port=0; int target_port=0; - int num_visited=0; int broke = 0, not_first = 0; int ports_to_try[2] = {3,5}; int *node_tar = NULL; - int i, i2; + int i; ba_node_t *next_node = NULL; ba_node_t *check_node = NULL; @@ -3043,7 +3047,6 @@ static int _find_x_path2(List results, ba_node_t *ba_node, if(path) list_destroy(path); path = list_create(_delete_path_list); - int ports_to_try2[2] = {2,4}; _find_next_free_using_port_2(curr_switch, 0, @@ -3138,7 +3141,6 @@ static int _find_next_free_using_port_2(ba_switch_t *curr_switch, int port_to_try = 2; int *node_tar= curr_switch->ext_wire[0].node_tar; int *node_src = curr_switch->ext_wire[0].node_tar; - int i; int used=0; int broke = 0; ba_node_t *ba_node = NULL; @@ -3495,7 +3497,6 @@ static int _finish_torus(ba_switch_t *curr_switch, int source_port, int *node_src = curr_switch->ext_wire[0].node_tar; int i; int used=0; - ba_node_t *ba_node = NULL; ListIterator itr; static bool found = false; diff --git a/src/plugins/select/bluegene/plugin/bg_job_place.c b/src/plugins/select/bluegene/plugin/bg_job_place.c index de7c52f1bf0c31b574dccf0a881afc49426f435f..41ff879017b8626874b65abceb6335c1faa50fb4 100644 --- a/src/plugins/select/bluegene/plugin/bg_job_place.c +++ b/src/plugins/select/bluegene/plugin/bg_job_place.c @@ -351,7 +351,7 @@ try_again: return SLURM_ERROR; } slurm_conf_lock(); - sprintf(tmp_char, "%s%s\0", + sprintf(tmp_char, "%s%s", slurmctld_conf.node_prefix, request.save_name); slurm_conf_unlock(); if (node_name2bitmap(tmp_char, diff --git a/src/plugins/select/bluegene/plugin/bluegene.c b/src/plugins/select/bluegene/plugin/bluegene.c index 4c2679f95ce9dba02b0cafdef2ed0c03cc994416..17ac6af537d97550951fc5fad6407954ed1007c2 100644 --- a/src/plugins/select/bluegene/plugin/bluegene.c +++ b/src/plugins/select/bluegene/plugin/bluegene.c @@ -96,7 +96,6 @@ static int _validate_config_nodes(void); static int _bg_record_cmpf_inc(bg_record_t *rec_a, bg_record_t *rec_b); static int _delete_old_blocks(void); static char *_get_bg_conf(void); -static void _strip_13_10(char *line); static int _add_block_db(bg_record_t *bg_record, int *block_inx); static int _split_block(bg_record_t *bg_record, int procs, int *block_inx); static int _breakup_blocks(ba_request_t *request, List my_block_list, @@ -152,8 +151,9 @@ extern int init_bg(void) /* Purge all plugin variables */ extern void fini_bg(void) { +#ifdef HAVE_BG_FILES int rc; - +#endif _set_bg_lists(); if (bg_list) { @@ -577,17 +577,17 @@ extern int format_node_name(bg_record_t *bg_record, char tmp_char[]) { if(bg_record->quarter != (uint16_t)NO_VAL) { if(bg_record->nodecard != (uint16_t)NO_VAL) { - sprintf(tmp_char,"%s.%d.%d\0", + sprintf(tmp_char,"%s.%d.%d", bg_record->nodes, bg_record->quarter, bg_record->nodecard); } else { - sprintf(tmp_char,"%s.%d\0", + sprintf(tmp_char,"%s.%d", bg_record->nodes, bg_record->quarter); } } else { - sprintf(tmp_char,"%s\0",bg_record->nodes); + sprintf(tmp_char,"%s",bg_record->nodes); } return SLURM_SUCCESS; } @@ -876,13 +876,13 @@ extern int create_defined_blocks(bg_layout_t overlapped) int rc = SLURM_SUCCESS; ListIterator itr; - struct passwd *pw_ent = NULL; - bg_record_t *bg_record = NULL, *found_record = NULL; + bg_record_t *bg_record = NULL; + +#ifdef HAVE_BG_FILES + bg_record_t *found_record = NULL; char *name = NULL; int geo[BA_SYSTEM_DIMENSIONS]; int i; - -#ifdef HAVE_BG_FILES ListIterator itr_found; init_wires(); #endif @@ -1033,7 +1033,6 @@ extern int create_dynamic_block(ba_request_t *request, List my_block_list) ListIterator itr; bg_record_t *bg_record = NULL; - bg_record_t *found_record = NULL; List results = list_create(NULL); uint16_t num_quarter=0, num_nodecard=0; char *name = NULL; @@ -1234,9 +1233,9 @@ extern int create_full_system_block() slurm_conf_lock(); name = xmalloc(sizeof(char)*(10+strlen(slurmctld_conf.node_prefix))); if((geo[X] == 0) && (geo[Y] == 0) && (geo[Z] == 0)) - sprintf(name, "%s000\0", slurmctld_conf.node_prefix); + sprintf(name, "%s000", slurmctld_conf.node_prefix); else - sprintf(name, "%s[000x%d%d%d]\0", + sprintf(name, "%s[000x%d%d%d]", slurmctld_conf.node_prefix, geo[X], geo[Y], geo[Z]); slurm_conf_unlock(); @@ -1354,8 +1353,9 @@ extern int remove_from_bg_list(List my_bg_list, bg_record_t *bg_record) extern int bg_free_block(bg_record_t *bg_record) { +#ifdef HAVE_BG_FILES int rc; - +#endif if(!bg_record) { error("bg_free_block: there was no bg_record"); return SLURM_ERROR; @@ -1454,8 +1454,9 @@ extern void *mult_destroy_block(void *args) { bg_record_t *bg_record = NULL; bg_record_t *found_record = NULL; +#ifdef HAVE_BG_FILES int rc; - char *temp_name = NULL; +#endif slurm_mutex_lock(&freed_cnt_mutex); if ((bg_freeing_list == NULL) && ((bg_freeing_list = list_create(destroy_bg_record)) == NULL)) @@ -1925,8 +1926,6 @@ static int _addto_node_list(bg_record_t *bg_record, int *start, int *end) static void _set_bg_lists() { - bg_record_t *bg_record = NULL; - slurm_mutex_lock(&block_state_mutex); if (bg_found_block_list) list_destroy(bg_found_block_list); @@ -2250,20 +2249,6 @@ static char *_get_bg_conf(void) return rc; } -/* Explicitly strip out new-line and carriage-return */ -static void _strip_13_10(char *line) -{ - int len = strlen(line); - int i; - - for(i=0;i<len;i++) { - if(line[i]==13 || line[i]==10) { - line[i] = '\0'; - return; - } - } -} - static int _add_block_db(bg_record_t *bg_record, int *block_inx) { #ifdef HAVE_BG_FILES @@ -2375,7 +2360,7 @@ static int _breakup_blocks(ba_request_t *request, List my_block_list, bg_record->bg_block_id, bg_record->nodes); request->save_name = xmalloc(sizeof(char) * 4); - sprintf(request->save_name, "%d%d%d\0", + sprintf(request->save_name, "%d%d%d", bg_record->start[X], bg_record->start[Y], bg_record->start[Z]); @@ -2395,7 +2380,7 @@ static int _breakup_blocks(ba_request_t *request, List my_block_list, total_proc_cnt, last_quarter); if(total_proc_cnt == request->procs) { request->save_name = xmalloc(sizeof(char) * 4); - sprintf(request->save_name, "%d%d%d\0", + sprintf(request->save_name, "%d%d%d", bg_record->start[X], bg_record->start[Y], bg_record->start[Z]); @@ -2440,7 +2425,7 @@ static int _breakup_blocks(ba_request_t *request, List my_block_list, bg_record->bg_block_id, bg_record->nodes); request->save_name = xmalloc(sizeof(char) * 4); - sprintf(request->save_name, "%d%d%d\0", + sprintf(request->save_name, "%d%d%d", bg_record->start[X], bg_record->start[Y], bg_record->start[Z]); @@ -2461,7 +2446,7 @@ static int _breakup_blocks(ba_request_t *request, List my_block_list, total_proc_cnt, last_quarter); if(total_proc_cnt == request->procs) { request->save_name = xmalloc(sizeof(char) * 4); - sprintf(request->save_name, "%d%d%d\0", + sprintf(request->save_name, "%d%d%d", bg_record->start[X], bg_record->start[Y], bg_record->start[Z]); @@ -2497,7 +2482,7 @@ found_one: bg_record->bg_block_id, tmp_char); request->save_name = xmalloc(sizeof(char) * 4); - sprintf(request->save_name, "%d%d%d\0", + sprintf(request->save_name, "%d%d%d", bg_record->start[X], bg_record->start[Y], bg_record->start[Z]); @@ -2597,7 +2582,7 @@ static int _add_bg_record(List records, blockreq_t *blockreq) +strlen(slurmctld_conf.node_prefix) +1)); - sprintf(bg_record->nodes, "%s%s\0", + sprintf(bg_record->nodes, "%s%s", slurmctld_conf.node_prefix, blockreq->block+i); slurm_conf_unlock(); diff --git a/src/plugins/select/bluegene/plugin/bluegene.h b/src/plugins/select/bluegene/plugin/bluegene.h index 09e230464134ef2e3f0c0787d981d6ead2a4546f..9768817b81839a8404f8721f11b09b27571a8612 100644 --- a/src/plugins/select/bluegene/plugin/bluegene.h +++ b/src/plugins/select/bluegene/plugin/bluegene.h @@ -40,6 +40,7 @@ #include "src/common/hostlist.h" #include "src/common/list.h" #include "src/common/macros.h" +#include "src/common/node_select.h" #include "src/slurmctld/slurmctld.h" #include "../block_allocator/block_allocator.h" #include "../wrap_rm_api.h" diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c index a6bc029ddc93f169bdcf2afdb569a357d002954b..a4cc9897ffc71534b63c52dbeb0678d70e7848d1 100644 --- a/src/plugins/select/cons_res/select_cons_res.c +++ b/src/plugins/select/cons_res/select_cons_res.c @@ -481,7 +481,7 @@ static int _synchronize_bitmaps(bitstr_t ** partially_idle_bitmap) static int _clear_select_jobinfo(struct job_record *job_ptr) { - int rc = SLURM_SUCCESS, i, j, nodes; + int rc = SLURM_SUCCESS, i, nodes; struct select_cr_job *job = NULL; int job_id; ListIterator iterator; @@ -1029,7 +1029,7 @@ extern int select_p_job_suspend(struct job_record *job_ptr) { ListIterator job_iterator; struct select_cr_job *job; - int i, j, rc = ESLURM_INVALID_JOB_ID; + int i, rc = ESLURM_INVALID_JOB_ID; xassert(job_ptr); xassert(select_cr_job_list); @@ -1078,7 +1078,7 @@ extern int select_p_job_resume(struct job_record *job_ptr) { ListIterator job_iterator; struct select_cr_job *job; - int i, j, rc = ESLURM_INVALID_JOB_ID; + int i, rc = ESLURM_INVALID_JOB_ID; xassert(job_ptr); xassert(select_cr_job_list); @@ -1192,8 +1192,7 @@ extern int select_p_get_select_nodeinfo(struct node_record *node_ptr, enum select_data_info info, void *data) { - int rc = SLURM_SUCCESS, i; - int incr = -1; + int rc = SLURM_SUCCESS; struct node_cr_record *this_cr_node; xassert(node_ptr); @@ -1223,7 +1222,7 @@ extern int select_p_get_select_nodeinfo(struct node_record *node_ptr, extern int select_p_update_nodeinfo(struct job_record *job_ptr, enum select_data_info info) { - int rc = SLURM_SUCCESS, i, j, job_id, nodes; + int rc = SLURM_SUCCESS, i, job_id, nodes; struct select_cr_job *job = NULL; ListIterator iterator; diff --git a/src/plugins/select/linear/select_linear.c b/src/plugins/select/linear/select_linear.c index ce5a18677e19c56f33c16c213cb9707aad790005..42ed24630d4ea84f69742a1130b899b84249a71a 100644 --- a/src/plugins/select/linear/select_linear.c +++ b/src/plugins/select/linear/select_linear.c @@ -529,9 +529,12 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t *bitmap, extern int select_p_job_begin(struct job_record *job_ptr) { - int i, rc=SLURM_SUCCESS; + int i; uint32_t cnt=0; - +#ifdef HAVE_XCPU + /* FIXME - rc is not returned! */ + int rc=SLURM_SUCCESS; +#endif xassert(job_ptr); xassert(job_ptr->node_bitmap); diff --git a/src/plugins/switch/elan/qsw.h b/src/plugins/switch/elan/qsw.h index b2891041143e684b126279332deb95710ec4ef60..1616c6f2f5813e74ab1f637cd23031afa206feb7 100644 --- a/src/plugins/switch/elan/qsw.h +++ b/src/plugins/switch/elan/qsw.h @@ -88,10 +88,12 @@ int qsw_unpack_libstate(qsw_libstate_t ls, Buf buffer); int qsw_init(qsw_libstate_t restorestate); void qsw_fini(qsw_libstate_t savestate); +int qsw_clear(void); int qsw_alloc_jobinfo(qsw_jobinfo_t *jp); qsw_jobinfo_t qsw_copy_jobinfo(qsw_jobinfo_t j); void qsw_free_jobinfo(qsw_jobinfo_t j); +int qsw_restore_jobinfo(struct qsw_jobinfo *jobinfo); int qsw_pack_jobinfo(qsw_jobinfo_t j, Buf buffer); int qsw_unpack_jobinfo(qsw_jobinfo_t j, Buf buffer); diff --git a/src/plugins/task/affinity/schedutils.c b/src/plugins/task/affinity/schedutils.c index 8b076711fc2ce9bad1ed60fa6f191430c0f7cd28..5b55f98b8b9377b9cfcd91149fc383a3bbfc1ac2 100644 --- a/src/plugins/task/affinity/schedutils.c +++ b/src/plugins/task/affinity/schedutils.c @@ -22,6 +22,7 @@ * with SLURM; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. \*****************************************************************************/ +#include <ctype.h> #include "affinity.h" /* diff --git a/src/sbcast/sbcast.c b/src/sbcast/sbcast.c index 0788ff4558a885927adaf7a78647f253db3403c4..361ee191b92b49edd44fd4eb288d16af6e47053b 100644 --- a/src/sbcast/sbcast.c +++ b/src/sbcast/sbcast.c @@ -47,6 +47,7 @@ #include "src/common/slurm_protocol_interface.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" +#include "src/common/forward.h" #include "src/sbcast/sbcast.h" /* global variables */ diff --git a/src/sinfo/print.c b/src/sinfo/print.c index 47df33e8d9411d995d2a57aa866146dd633b5f4b..95a560b604713f8c65ab353664b25be5db604a07 100644 --- a/src/sinfo/print.c +++ b/src/sinfo/print.c @@ -159,7 +159,6 @@ static int _print_secs(long time, int width, bool right, bool cut_output) static int _build_min_max_string(char *buffer, int buf_size, int min, int max, bool range) { - int i; char tmp_min[7]; char tmp_max[7]; convert_to_kilo(min, tmp_min); diff --git a/src/sinfo/sinfo.c b/src/sinfo/sinfo.c index 991fd61a313011e8c40f332b8fc6db6263fcf18a..843fc37fc70037f8c9cea5d0201582a7bcfbb1cf 100644 --- a/src/sinfo/sinfo.c +++ b/src/sinfo/sinfo.c @@ -281,7 +281,6 @@ static int _build_sinfo_data(List sinfo_list, hostlist_t hl; sinfo_data_t *sinfo_ptr; char *node_name = NULL; - int offset = 0; /* by default every partition is shown, even if no nodes */ if ((!params.node_flag) && params.match_flags.partition_flag) { diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c index 3ab68dd3e17a9d5dd820eb5e93b4be10fee9b7cb..50f3038d85fd7678162548777647faf0cb7120c2 100644 --- a/src/slurmctld/agent.c +++ b/src/slurmctld/agent.c @@ -61,6 +61,7 @@ #include <string.h> #include <unistd.h> #include <sys/types.h> +#include <sys/wait.h> #include <unistd.h> #include <stdlib.h> @@ -340,7 +341,7 @@ static int _valid_agent_arg(agent_arg_t *agent_arg_ptr) static agent_info_t *_make_agent_info(agent_arg_t *agent_arg_ptr) { - int i, j; + int i; agent_info_t *agent_info_ptr; thd_t *thread_ptr; int *span = set_span(agent_arg_ptr->node_count); @@ -451,11 +452,8 @@ static void *_wdog(void *args) agent_info_t *agent_ptr = (agent_info_t *) args; thd_t *thread_ptr = agent_ptr->thread_struct; unsigned long usec = 1250000; - time_t now; ListIterator itr; ret_types_t *ret_type = NULL; - state_t state; - int is_ret_list = 1; thd_complete_t thd_comp; @@ -559,7 +557,7 @@ static void _notify_slurmctld_jobs(agent_info_t *agent_ptr) static void _notify_slurmctld_nodes(agent_info_t *agent_ptr, int no_resp_cnt, int retry_cnt) { - ListIterator itr; + ListIterator itr = NULL; ListIterator data_itr; ret_types_t *ret_type = NULL; ret_data_info_t *ret_data_info = NULL; diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 580826cc726d906257f09ed8252bad399702f4a1..01cbed80a864542f6890f3ae51102b221609ffbd 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -599,7 +599,6 @@ static void *_service_connection(void *arg) slurm_fd newsockfd = ((connection_arg_t *) arg)->newsockfd; void *return_code = NULL; List ret_list = NULL; - ListIterator itr; slurm_msg_t *msg = xmalloc(sizeof(slurm_msg_t)); msg->conn_fd = newsockfd; diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 570f77503e91f1f7920cdfebc4b845ca03614778..9a651143c688c6ab33bf461ce79341a3ce97ddb7 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -53,6 +53,7 @@ #include "src/common/switch.h" #include "src/common/xassert.h" #include "src/common/xstring.h" +#include "src/common/forward.h" #include "src/slurmctld/agent.h" #include "src/slurmctld/locks.h" @@ -1668,7 +1669,6 @@ static int _job_create(job_desc_msg_t * job_desc, int allocate, int will_run, bitstr_t *req_bitmap = NULL, *exc_bitmap = NULL; bool super_user = false; struct job_record *job_ptr; - uint16_t geo[SYSTEM_DIMENSIONS]; select_g_alter_node_cnt(SELECT_SET_NODE_CNT, job_desc); @@ -2705,7 +2705,7 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer) if (detail_ptr) { packstr(detail_ptr->features, buffer); } else { - packstr(NULL, buffer); + packnull(buffer); } if (detail_ptr && dump_job_ptr->job_state == JOB_PENDING) @@ -2717,8 +2717,6 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer) /* pack job details for "get_job_info" RPC */ static void _pack_job_details(struct job_details *detail_ptr, Buf buffer) { - uint32_t altered; - if (detail_ptr) { pack32((uint32_t) detail_ptr->min_nodes, buffer); pack16((uint16_t) detail_ptr->shared, buffer); @@ -2747,10 +2745,10 @@ static void _pack_job_details(struct job_details *detail_ptr, Buf buffer) pack32((uint32_t) 0, buffer); pack16((uint16_t) 0, buffer); - packstr(NULL, buffer); - packstr(NULL, buffer); - packstr(NULL, buffer); - packstr(NULL, buffer); + packnull(buffer); + packnull(buffer); + packnull(buffer); + packnull(buffer); } } diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c index 1ab9f562225dd6ae211a38af274228977be943ab..1f210d8ad5f118facb029a327650cfa061abbe65 100644 --- a/src/slurmctld/node_scheduler.c +++ b/src/slurmctld/node_scheduler.c @@ -1157,8 +1157,8 @@ extern void build_node_details(struct job_record *job_ptr) /* Use hostlist here to insure ordering of info matches that of srun */ if ((host_list = hostlist_create(job_ptr->nodes)) == NULL) - fatal("hostlist_create error for %s: %m", this_node_name); - + fatal("hostlist_create error for %s: %m", job_ptr->nodes); + job_ptr->node_cnt = hostlist_count(host_list); xrealloc(job_ptr->cpus_per_node, diff --git a/src/slurmctld/ping_nodes.c b/src/slurmctld/ping_nodes.c index e8ff2171e15edb8d511012965767542eaca80fcd..5e0d2095b67b3d8d071dfd74c33c3b3e5372b913 100644 --- a/src/slurmctld/ping_nodes.c +++ b/src/slurmctld/ping_nodes.c @@ -94,8 +94,6 @@ void ping_begin (void) */ void ping_end (void) { - long start, end; - slurm_mutex_lock(&lock_mutex); if (ping_count > 0) ping_count--; diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c index 8f2b91466fae72b7cfec20dd7791dc43e4b4ad3f..2084d4ad065f1e579d7a9c3bec37d33e4dbcbd1d 100644 --- a/src/slurmctld/proc_req.c +++ b/src/slurmctld/proc_req.c @@ -57,6 +57,7 @@ #include "src/common/slurm_protocol_api.h" #include "src/common/switch.h" #include "src/common/xstring.h" +#include "src/common/forward.h" #include "src/slurmctld/agent.h" #include "src/slurmctld/locks.h" diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c index 92a687306f5b8b5bc412178bbc5ca6a8ad758552..97fd0c66a7418182640696e21b044df20242ecff 100644 --- a/src/slurmctld/read_config.c +++ b/src/slurmctld/read_config.c @@ -50,6 +50,7 @@ #include "src/common/slurm_jobcomp.h" #include "src/common/switch.h" #include "src/common/xstring.h" +#include "src/common/node_select.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/node_scheduler.h" @@ -177,9 +178,9 @@ static int _build_bitmaps(void) if (((base_state == NODE_STATE_IDLE) && (job_cnt == 0)) || (base_state == NODE_STATE_DOWN)) bit_set(idle_node_bitmap, i); - if ((base_state == NODE_STATE_IDLE) - || (base_state == NODE_STATE_ALLOCATED) - && (no_resp_flag == 0)) + if (( (base_state == NODE_STATE_IDLE) + || (base_state == NODE_STATE_ALLOCATED) ) + && (no_resp_flag == 0)) bit_set(avail_node_bitmap, i); if (node_record_table_ptr[i].config_ptr) bit_set(node_record_table_ptr[i].config_ptr-> @@ -326,7 +327,7 @@ static int _build_single_nodeline_info(slurm_conf_node_t *node_ptr, struct config_record *config_ptr, slurm_ctl_conf_t *conf) { - int error_code, i; + int error_code; struct node_record *node_rec = NULL; hostlist_t alias_list = NULL; hostlist_t hostname_list = NULL; @@ -633,7 +634,7 @@ static int _build_all_partitionline_info() int read_slurm_conf(int recover) { DEF_TIMERS; - int i, j, error_code; + int error_code; int old_node_record_count; struct node_record *old_node_table_ptr; char *old_auth_type = xstrdup(slurmctld_conf.authtype); @@ -973,14 +974,3 @@ static void _validate_node_proc_count(void) } #endif -/* Normalize supplied debug level to be in range per log.h definitions */ -static void _normalize_debug_level(uint16_t *level) -{ - if (*level > LOG_LEVEL_DEBUG3) { - error("Normalizing debug level from %u to %d", - *level, LOG_LEVEL_DEBUG3); - *level = LOG_LEVEL_DEBUG3; - } - /* level is uint16, always > LOG_LEVEL_QUIET(0), can't underflow */ -} - diff --git a/src/slurmctld/sched_upcalls.c b/src/slurmctld/sched_upcalls.c index 1d6eb4e208c5279ddaf625e2df98a415649346f8..3b89baf803b2ee6fdb431fc332a4624e48b261ec 100644 --- a/src/slurmctld/sched_upcalls.c +++ b/src/slurmctld/sched_upcalls.c @@ -116,7 +116,6 @@ static void * sched_get_job_end_time( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_user_id( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_group_name( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_req_nodes( sched_obj_list_t, int32_t, char * ); -static void * sched_get_job_alloc_nodes( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_min_nodes( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_partition( sched_obj_list_t, int32_t, char * ); static void * sched_get_job_min_disk( sched_obj_list_t, int32_t, char * ); @@ -754,35 +753,6 @@ sched_get_job_req_nodes( sched_obj_list_t job_data, } -/* ************************************************************************ */ -/* TAG( sched_get_job_alloc_nodes ) */ -/* ************************************************************************ */ -static void * -sched_get_job_alloc_nodes( sched_obj_list_t job_data, - int32_t idx, - char *type ) -{ - void *cache; - char *nodes; - - if ( type ) *type = 'S'; - nodes = ( (struct job_record *)job_data->data )[ idx ].nodes; - - if ( nodes ) { - if ( ( cache = sched_obj_cache_entry_find( job_data, - idx, - "alloc_nodes" ) ) != NULL ) { - return cache; - } - cache = expand_hostlist( nodes ); - if ( ! cache ) - return nodes; - sched_obj_cache_entry_add( job_data, idx, "alloc_nodes", cache ); - return cache; - } - return ""; -} - /* ************************************************************************ */ /* TAG( sched_get_job_min_nodes ) */ /* ************************************************************************ */ diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c index e351fbb80ef3e59a3432b261ab333e1b96a02ecf..eec21d0399dda0786470d92b0ea9c6e482fe9eeb 100644 --- a/src/slurmctld/step_mgr.c +++ b/src/slurmctld/step_mgr.c @@ -54,7 +54,6 @@ #define MAX_RETRIES 10 -static int _job_step_ckpt_error(struct step_record *step_ptr, slurm_fd conn_fd); static void _pack_ctld_job_step_info(struct step_record *step, Buf buffer); static bitstr_t * _pick_step_nodes (struct job_record *job_ptr, job_step_create_request_msg_t *step_spec ); @@ -422,7 +421,7 @@ try_again: "switch type elan. Switching DIST type " "to BLOCK"); xfree(step_spec->node_list); - step_spec->task_dist == SLURM_DIST_BLOCK; + step_spec->task_dist = SLURM_DIST_BLOCK; FREE_NULL_BITMAP(nodes_picked); goto try_again; } @@ -891,7 +890,6 @@ extern int job_step_checkpoint(checkpoint_msg_t *ckpt_ptr, /* operate on all of a job's steps */ else { int update_rc = -2; - bool error_reply = false; ListIterator step_iterator; step_iterator = list_iterator_create (job_ptr->step_list); diff --git a/src/slurmd/common/run_script.c b/src/slurmd/common/run_script.c index b3d8d4b15f5f82dbea64981400c740f80a5e38e0..13408947847b96936f6cb2cc8ecb013770260c99 100644 --- a/src/slurmd/common/run_script.c +++ b/src/slurmd/common/run_script.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <sys/wait.h> #include <sys/errno.h> +#include <string.h> #include "src/common/xmalloc.h" #include "src/common/xstring.h" diff --git a/src/slurmd/common/stepd_api.c b/src/slurmd/common/stepd_api.c index 60e5054c42a28fbf61660b96a2bdf1698019ebf3..d9159d16817ce80239e5ae0e8aa7c57b307f213e 100644 --- a/src/slurmd/common/stepd_api.c +++ b/src/slurmd/common/stepd_api.c @@ -44,6 +44,7 @@ #include "src/common/slurm_auth.h" #include "src/common/slurm_cred.h" #include "src/common/list.h" +#include "src/common/slurm_protocol_api.h" #include "src/slurmd/common/stepd_api.h" static int @@ -313,6 +314,8 @@ _sockname_regex_init(regex_t *re, const char *nodename) } xfree(pattern); + + return 0; } static int @@ -390,7 +393,6 @@ stepd_available(const char *directory, const char *nodename) } } -done2: closedir(dp); done: regfree(&re); diff --git a/src/slurmd/common/stepd_api.h b/src/slurmd/common/stepd_api.h index 6be167636d306bf22715a8b536f0edec93d289ec..fc3ec858c4cda9aaa6a392a74b74648d5afcafb9 100644 --- a/src/slurmd/common/stepd_api.h +++ b/src/slurmd/common/stepd_api.h @@ -70,6 +70,13 @@ typedef struct { uint32_t stepid; } slurmstepd_info_t; +/* + * Cleanup stale stepd domain sockets. + */ +int stepd_cleanup_sockets(const char *directory, const char *nodename); + +int stepd_terminate(int fd); + /* * Connect to a slurmstepd proccess by way of its unix domain socket. * diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c index d6ff7ca346db507430115e9c09f15dbafa9dd406..637e22c6f811565c8365f1647ef34fb2de47b875 100644 --- a/src/slurmd/slurmd/req.c +++ b/src/slurmd/slurmd/req.c @@ -42,6 +42,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <utime.h> +#include <grp.h> #include "src/common/hostlist.h" #include "src/common/log.h" @@ -57,12 +58,14 @@ #include "src/common/xmalloc.h" #include "src/common/list.h" #include "src/common/util-net.h" +#include "src/common/forward.h" #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/slurmd/xcpu.h" #include "src/slurmd/common/proctrack.h" #include "src/slurmd/common/slurmstepd_init.h" #include "src/slurmd/common/stepd_api.h" +#include "src/slurmd/common/run_script.h" #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 @@ -118,6 +121,7 @@ static List waiters; static pthread_mutex_t launch_mutex = PTHREAD_MUTEX_INITIALIZER; + void slurmd_req(slurm_msg_t *msg, slurm_addr *cli) { @@ -233,24 +237,10 @@ slurmd_req(slurm_msg_t *msg, slurm_addr *cli) return; } -/* - * Need to close all open fds - */ -static void -_close_fds(void) -{ - int i; - int maxfd = 1024; - for (i = 4; i < maxfd; i++) { - close(i); - } -} - static int _send_slurmstepd_init(int fd, slurmd_step_type_t type, void *req, slurm_addr *cli, slurm_addr *self) { - int rc; int len = 0; Buf buffer; slurm_msg_t msg; @@ -338,7 +328,7 @@ _send_slurmstepd_init(int fd, slurmd_step_type_t type, void *req, safe_write(fd, &len, sizeof(int)); return -1; } - if (gids = _gids_cache_lookup(pw->pw_name, pw->pw_gid)) { + if ((gids = _gids_cache_lookup(pw->pw_name, pw->pw_gid))) { int i; uint32_t tmp32; safe_write(fd, &gids->ngids, sizeof(int)); @@ -1064,7 +1054,7 @@ static void _rpc_pid2jid(slurm_msg_t *msg, slurm_addr *cli) steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { int fd; fd = stepd_connect(stepd->directory, stepd->nodename, stepd->jobid, stepd->stepid); @@ -1201,7 +1191,6 @@ _rpc_reattach_tasks(slurm_msg_t *msg, slurm_addr *cli) int rc = SLURM_SUCCESS; uint16_t port = 0; char host[MAXHOSTNAMELEN]; - int i; slurm_addr ioaddr; void *job_cred_sig; int len; @@ -1301,7 +1290,7 @@ _get_job_uid(uint32_t jobid) steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid != jobid) { /* multiple jobs expected on shared nodes */ continue; @@ -1350,7 +1339,7 @@ _kill_all_active_steps(uint32_t jobid, int sig, bool batch) steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid != jobid) { /* multiple jobs expected on shared nodes */ debug3("Step from other job: jobid=%u (this jobid=%u)", @@ -1401,7 +1390,7 @@ _terminate_all_steps(uint32_t jobid, bool batch) steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid != jobid) { /* multiple jobs expected on shared nodes */ debug3("Step from other job: jobid=%u (this jobid=%u)", @@ -1501,7 +1490,7 @@ _steps_completed_now(uint32_t jobid) steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid == jobid) { int fd; fd = stepd_connect(stepd->directory, stepd->nodename, @@ -1567,7 +1556,6 @@ _epilog_complete(uint32_t jobid, int rc) static void _rpc_signal_job(slurm_msg_t *msg, slurm_addr *cli) { - int rc = SLURM_SUCCESS; signal_job_msg_t *req = msg->data; uid_t req_uid = g_slurm_auth_get_uid(msg->cred); uid_t job_uid; @@ -1613,7 +1601,7 @@ _rpc_signal_job(slurm_msg_t *msg, slurm_addr *cli) */ steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid != req->job_id) { /* multiple jobs expected on shared nodes */ debug3("Step from other job: jobid=%u (this jobid=%u)", @@ -1698,7 +1686,7 @@ _rpc_suspend_job(slurm_msg_t *msg, slurm_addr *cli) */ steps = stepd_available(conf->spooldir, conf->node_name); i = list_iterator_create(steps); - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { if (stepd->jobid != req->job_id) { /* multiple jobs expected on shared nodes */ debug3("Step from other job: jobid=%u (this jobid=%u)", @@ -1982,7 +1970,6 @@ _rpc_update_time(slurm_msg_t *msg, slurm_addr *cli) { int rc = SLURM_SUCCESS; uid_t req_uid = g_slurm_auth_get_uid(msg->cred); - job_time_msg_t *req = (job_time_msg_t *) msg->data; if ((req_uid != conf->slurm_user_id) && (req_uid != 0)) { rc = ESLURM_USER_ID_MISSING; @@ -2173,7 +2160,7 @@ _gids_cache_register(char *user, gid_t gid, gids_t *gids) static gids_t * _getgroups(void) { - int n, i, found; + int n; gid_t *gg; if ((n = getgroups(0, NULL)) < 0) { @@ -2206,7 +2193,7 @@ init_gids_cache(int cache) orig_gids = (gid_t *)xmalloc(ngids * sizeof(gid_t)); getgroups(ngids, orig_gids); - while (pwd = getpwent()) { + while ((pwd = getpwent())) { if (_gids_cache_lookup(pwd->pw_name, pwd->pw_gid)) continue; if (initgroups(pwd->pw_name, pwd->pw_gid)) { diff --git a/src/slurmd/slurmd/req.h b/src/slurmd/slurmd/req.h index 38573cb3d8d4b42735db49b75c2c25857ceca01c..909ef9677e8d5e47232f991cf163210b90206db7 100644 --- a/src/slurmd/slurmd/req.h +++ b/src/slurmd/slurmd/req.h @@ -34,4 +34,6 @@ */ void slurmd_req(slurm_msg_t *msg, slurm_addr *client_addr); +int init_gids_cache(int cache); + #endif diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c index 0fb9d5ed10f1639b161528d5e98ee3e2bcea3fef..92d7eae4333bbbbbf471d9123a4d6ed7d9495869 100644 --- a/src/slurmd/slurmd/slurmd.c +++ b/src/slurmd/slurmd/slurmd.c @@ -58,6 +58,7 @@ #include "src/common/hostlist.h" #include "src/common/macros.h" #include "src/common/fd.h" +#include "src/common/forward.h" #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/slurmd/req.h" @@ -124,12 +125,6 @@ static void _atfork_prepare(void); static void _atfork_final(void); static void _install_fork_handlers(void); -static void -_step_state_free(void *state) -{ - xfree(state); -} - int main (int argc, char *argv[]) { @@ -341,11 +336,9 @@ _handle_connection(slurm_fd fd, slurm_addr *cli) static void * _service_connection(void *arg) { - int rc; conn_t *con = (conn_t *) arg; List ret_list = NULL; slurm_msg_t *msg = xmalloc(sizeof(slurm_msg_t)); - char addrbuf[INET_ADDRSTRLEN]; debug3("in the service_connection"); msg->conn_fd = con->fd; @@ -450,7 +443,7 @@ _fill_registration_msg(slurm_node_registration_status_msg_t *msg) i = list_iterator_create(steps); n = 0; - while (stepd = list_next(i)) { + while ((stepd = list_next(i))) { int fd; fd = stepd_connect(stepd->directory, stepd->nodename, stepd->jobid, stepd->stepid); diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c index 47e364f6a01d9fc8aacf3ce78f3b0de16ad96456..544154fda31ff99fd9aa135862a8ea1fd24db834 100644 --- a/src/slurmd/slurmstepd/io.c +++ b/src/slurmd/slurmstepd/io.c @@ -155,7 +155,6 @@ static int _send_io_init_msg(int sock, srun_key_t *key, slurmd_job_t *job); static void _send_eof_msg(struct task_read_info *out); static struct io_buf *_task_build_message(struct task_read_info *out, slurmd_job_t *job, cbuf_t cbuf); -static struct io_obj *_io_obj(slurmd_job_t *, slurmd_task_info_t *, int, int); static void *_io_thr(void *arg); static void _route_msg_task_to_client(eio_obj_t *obj); static void _free_outgoing_msg(struct io_buf *msg, slurmd_job_t *job); @@ -216,7 +215,7 @@ _client_writable(eio_obj_t *obj) struct io_buf *msg; client->msg_queue = list_create(NULL); /* need destructor */ msgs = list_iterator_create(client->job->outgoing_cache); - while (msg = list_next(msgs)) { + while ((msg = list_next(msgs))) { msg->ref_count++; list_enqueue(client->msg_queue, msg); } @@ -455,8 +454,6 @@ _task_writable(eio_obj_t *obj) static int _task_write_error(eio_obj_t *obj, List objs) { - struct task_write_info *t = (struct task_write_info *) obj->arg; - debug4("Called _task_write_error, closing fd %d", obj->fd); close(obj->fd); @@ -578,10 +575,6 @@ static int _task_read(eio_obj_t *obj, List objs) { struct task_read_info *out = (struct task_read_info *)obj->arg; - struct client_io_info *client; - struct io_buf *msg = NULL; - eio_obj_t *eio; - ListIterator clients; int len; int rc = -1; @@ -628,31 +621,10 @@ again: /********************************************************************** * General fuctions **********************************************************************/ -static char * -_local_filename (char *fname, int taskid) -{ - int id; - - if (fname == NULL) - return NULL; - - if ((id = fname_single_task_io(fname)) < 0) - return fname; - - if (id != taskid) - return "/dev/null"; - - return (NULL); -} static int _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job) { - char *name; - int single; - int fd; - struct passwd *spwd = NULL; - /* * Initialize stdin */ @@ -692,7 +664,7 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job) error("Could not open stdout file: %m"); return SLURM_ERROR; } - task->from_stdout == -1; /* not used */ + task->from_stdout = -1; /* not used */ } else { /* create pipe and eio object */ int pout[2]; @@ -723,7 +695,7 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job) error("Could not open stderr file: %m"); return SLURM_ERROR; } - task->from_stderr == -1; /* not used */ + task->from_stderr = -1; /* not used */ } else { /* create pipe and eio object */ int perr[2]; @@ -741,6 +713,8 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job) list_append(job->stderr_eio_objs, (void *)task->err); eio_new_initial_obj(job->eio, (void *)task->err); } + + return SLURM_SUCCESS; } int @@ -751,6 +725,8 @@ io_init_tasks_stdio(slurmd_job_t *job) for (i = 0; i < job->ntasks; i++) { _init_task_stdio_fds(job->task[i], job); } + + return 0; } int @@ -768,15 +744,6 @@ io_thread_start(slurmd_job_t *job) return 0; } -static int -_xclose(int fd) -{ - int rc; - do { - rc = close(fd); - } while (rc == -1 && errno == EINTR); - return rc; -} void _shrink_msg_cache(List cache, slurmd_job_t *job) @@ -818,7 +785,7 @@ _route_msg_task_to_client(eio_obj_t *obj) /* Add message to the msg_queue of all clients */ clients = list_iterator_create(out->job->clients); - while(eio = list_next(clients)) { + while((eio = list_next(clients))) { client = (struct client_io_info *)eio->arg; if (client->out_eof == true) continue; @@ -840,8 +807,6 @@ _route_msg_task_to_client(eio_obj_t *obj) static void _free_incoming_msg(struct io_buf *msg, slurmd_job_t *job) { - int i; - msg->ref_count--; if (msg->ref_count == 0) { /* Put the message back on the free List */ @@ -889,7 +854,7 @@ _free_all_outgoing_msgs(List msg_queue, slurmd_job_t *job) struct io_buf *msg; msgs = list_iterator_create(msg_queue); - while(msg = list_next(msgs)) { + while((msg = list_next(msgs))) { _free_outgoing_msg(msg, job); } list_iterator_destroy(msgs); @@ -910,9 +875,8 @@ io_close_task_fds(slurmd_job_t *job) void io_close_all(slurmd_job_t *job) { - int i; - #if 0 + int i; for (i = 0; i < job->ntasks; i++) _io_finalize(job->task[i]); #endif @@ -959,7 +923,6 @@ _io_thr(void *arg) int io_initial_client_connect(srun_info_t *srun, slurmd_job_t *job) { - int i; int sock = -1; struct client_io_info *client; eio_obj_t *obj; @@ -1014,7 +977,6 @@ io_initial_client_connect(srun_info_t *srun, slurmd_job_t *job) int io_client_connect(srun_info_t *srun, slurmd_job_t *job) { - int i; int sock = -1; struct client_io_info *client; eio_obj_t *obj; @@ -1148,7 +1110,7 @@ _send_eof_msg(struct task_read_info *out) /* Add eof message to the msg_queue of all clients */ clients = list_iterator_create(out->job->clients); - while(eio = list_next(clients)) { + while((eio = list_next(clients))) { client = (struct client_io_info *)eio->arg; debug5("======================== Enqueued eof message"); xassert(client->magic == CLIENT_IO_MAGIC); diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index 38b4cce8ad10a9e7e1fb3adb22432349464dc33c..4a41bec240fe5602610b7bd91f0b0d5dad8e0c04 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -67,11 +67,13 @@ #include "src/common/xstring.h" #include "src/common/xmalloc.h" #include "src/common/util-net.h" +#include "src/common/forward.h" #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/common/setproctitle.h" #include "src/slurmd/common/proctrack.h" #include "src/slurmd/common/task_plugin.h" +#include "src/slurmd/common/run_script.h" #include "src/slurmd/slurmstepd/slurmstepd.h" #include "src/slurmd/slurmstepd/mgr.h" #include "src/slurmd/slurmstepd/task.h" @@ -79,22 +81,6 @@ #include "src/slurmd/slurmstepd/pdebug.h" #include "src/slurmd/slurmstepd/req.h" -/* - * Map session manager exit status to slurm errno: - * Keep in sync with smgr.c exit codes. - */ -static int exit_errno[] = -{ 0, - ESLURM_INTERCONNECT_FAILURE, - ESLURMD_SET_UID_OR_GID_ERROR, - ESLURMD_SET_SID_ERROR, - ESCRIPT_CHDIR_FAILED, - -1, - ESLURMD_EXECVE_FAILED -}; - -#define MAX_SMGR_EXIT_STATUS 6 - #define RETRY_DELAY 15 /* retry every 15 seconds */ #define MAX_RETRY 240 /* retry 240 times (one hour max) */ @@ -130,7 +116,6 @@ static void _slurmd_job_log_init(slurmd_job_t *job); static void _wait_for_io(slurmd_job_t *job); static int _send_exit_msg(slurmd_job_t *job, uint32_t *tid, int n, int status); -static void _set_unexited_task_status(slurmd_job_t *job, int status); static int _send_pending_exit_msgs(slurmd_job_t *job); static void _kill_running_tasks(slurmd_job_t *job); static void _wait_for_all_tasks(slurmd_job_t *job); @@ -215,7 +200,6 @@ slurmd_job_t * mgr_launch_batch_job_setup(batch_job_launch_msg_t *msg, slurm_addr *cli) { int status = 0; - uint32_t jobid = msg->job_id; slurmd_job_t *job = NULL; char buf[1024]; hostlist_t hl = hostlist_create(msg->nodes); @@ -455,7 +439,6 @@ job_manager(slurmd_job_t *job) { int rc = 0; bool io_initialized = false; - int fd; debug3("Entered job_manager for %u.%u pid=%lu", job->jobid, job->stepid, (unsigned long) job->jmgr_pid); @@ -542,7 +525,6 @@ job_manager(slurmd_job_t *job) g_slurmd_jobacct_jobstep_terminated(job); fail1: - fail0: /* If interactive job startup was abnormal, * be sure to notify client. */ @@ -564,7 +546,6 @@ _fork_all_tasks(slurmd_job_t *job) int i; int *writefds; /* array of write file descriptors */ int *readfds; /* array of read file descriptors */ - uint32_t cont_id; int fdpair[2]; xassert(job != NULL); @@ -851,23 +832,6 @@ _wait_for_all_tasks(slurmd_job_t *job) } } - -static void -_set_unexited_task_status(slurmd_job_t *job, int status) -{ - int i; - for (i = 0; i < job->ntasks; i++) { - slurmd_task_info_t *t = job->task[i]; - - if (t->exited) continue; - - t->exited = true; - t->estatus = status; - } -} - - - /* * Make sure all processes in session are dead for interactive jobs. On * systems with an IBM Federation switch, all processes must be terminated @@ -1269,7 +1233,7 @@ _initgroups(slurmd_job_t *job) username = job->pwd->pw_name; gid = job->pwd->pw_gid; debug2("Uncached user/gid: %s/%ld", username, (long)gid); - if (rc = initgroups(username, gid)) { + if ((rc = initgroups(username, gid))) { if ((errno == EPERM) && (getuid != (uid_t) 0)) { debug("Error in initgroups(%s, %ld): %m", username, (long)gid); diff --git a/src/slurmd/slurmstepd/req.c b/src/slurmd/slurmstepd/req.c index 76552e9d98578d48e9d1b203afffde4e79af6ca7..7e63a0e5aeb553e94790a8098b92bd28fe4d0a36 100644 --- a/src/slurmd/slurmstepd/req.c +++ b/src/slurmd/slurmstepd/req.c @@ -44,8 +44,10 @@ #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/common/stepd_api.h" +#include "src/slurmd/common/proctrack.h" #include "src/slurmd/slurmstepd/slurmstepd_job.h" #include "src/slurmd/slurmstepd/req.h" +#include "src/slurmd/slurmstepd/io.h" static void *_handle_accept(void *arg); static int _handle_request(int fd, slurmd_job_t *job, uid_t uid, gid_t gid); @@ -180,6 +182,8 @@ _msg_thr_internal(void *job_arg) debug("Message thread started pid = %lu", (unsigned long) getpid()); eio_handle_mainloop(job->msg_handle); debug("Message thread exited"); + + return NULL; } int @@ -715,7 +719,6 @@ _handle_attach(int fd, slurmd_job_t *job, uid_t uid) { srun_info_t *srun; int rc = SLURM_SUCCESS; - int sig_len; debug("_handle_attach for job %u.%u", job->jobid, job->stepid); diff --git a/src/slurmd/slurmstepd/slurmstepd.c b/src/slurmd/slurmstepd/slurmstepd.c index 3763c91978763916f1eed56f04348e8ce4dbcb4e..a690c5921898db8d984673b337a04f2eb8c9c2d3 100644 --- a/src/slurmd/slurmstepd/slurmstepd.c +++ b/src/slurmd/slurmstepd/slurmstepd.c @@ -35,12 +35,17 @@ #include "src/common/xmalloc.h" #include "src/common/xsignal.h" +#include "src/common/slurm_jobacct.h" +#include "src/common/switch.h" #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/common/slurmstepd_init.h" #include "src/slurmd/common/stepd_api.h" +#include "src/slurmd/common/setproctitle.h" +#include "src/slurmd/common/proctrack.h" #include "src/slurmd/slurmstepd/slurmstepd.h" #include "src/slurmd/slurmstepd/mgr.h" +#include "src/slurmd/slurmstepd/req.h" #include "src/slurmd/slurmstepd/slurmstepd_job.h" static int _init_from_slurmd(int sock, char **argv, slurm_addr **_cli, @@ -151,8 +156,6 @@ _init_from_slurmd(int sock, char **argv, Buf buffer; int step_type; int len; - int rc; - char c; slurm_addr *cli = NULL; slurm_addr *self = NULL; slurm_msg_t *msg = NULL; @@ -279,7 +282,7 @@ rwfail: static slurmd_job_t * _step_setup(slurm_addr *cli, slurm_addr *self, slurm_msg_t *msg) { - slurmd_job_t *job; + slurmd_job_t *job = NULL; switch(msg->msg_type) { case REQUEST_BATCH_JOB_LAUNCH: diff --git a/src/slurmd/slurmstepd/slurmstepd_job.c b/src/slurmd/slurmstepd/slurmstepd_job.c index 0b15ea17b9a5f370ce6f954df66cfc4034bd941a..a4be5b0356f157f4986583b02bd574841e4913fc 100644 --- a/src/slurmd/slurmstepd/slurmstepd_job.c +++ b/src/slurmd/slurmstepd/slurmstepd_job.c @@ -142,7 +142,6 @@ job_create(launch_tasks_request_msg_t *msg, slurm_addr *cli_addr) srun_info_t *srun; slurm_addr resp_addr; slurm_addr io_addr; - int i; xassert(msg != NULL); @@ -321,7 +320,6 @@ job_batch_job_create(batch_job_launch_msg_t *msg) slurmd_job_t *job; srun_info_t *srun = NULL; uint32_t global_taskid = 0; - char *ofname, *efname; xassert(msg != NULL); diff --git a/src/slurmd/slurmstepd/task.c b/src/slurmd/slurmstepd/task.c index ed1d80f3d58130886ddedb29b85b72e65f94fce5..e9bf96a9f004c3a3b1a95d4d81d57ad56ac882be 100644 --- a/src/slurmd/slurmstepd/task.c +++ b/src/slurmd/slurmstepd/task.c @@ -37,6 +37,7 @@ #include <grp.h> #include <string.h> #include <assert.h> +#include <ctype.h> #if HAVE_STDLIB_H # include <stdlib.h> @@ -61,6 +62,7 @@ #include "src/common/switch.h" #include "src/common/xsignal.h" #include "src/common/xstring.h" +#include "src/common/mpi.h" #include "src/slurmd/slurmd/slurmd.h" #include "src/slurmd/common/proctrack.h" @@ -74,7 +76,6 @@ * Static prototype definitions. */ static void _make_tmpdir(slurmd_job_t *job); -static char *_signame(int signo); static void _cleanup_file_descriptors(slurmd_job_t *job); static void _setup_spawn_io(slurmd_job_t *job); static int _run_script(const char *name, const char *path, @@ -345,40 +346,6 @@ exec_task(slurmd_job_t *job, int i, int waitfd) exit(errno); } -/* - * Translate a signal number to recognizable signal name. - * Returns signal name or "signal <num>" - */ -static char * -_signame(int signo) -{ - int i; - static char str[10]; - static struct { - int s_num; - char * s_name; - } sigtbl[] = { - {SIGHUP, "SIGHUP" }, {SIGINT, "SIGINT" }, {SIGQUIT,"SIGQUIT"}, - {SIGABRT,"SIGABRT"}, {SIGUSR1,"SIGUSR1"}, {SIGUSR2,"SIGUSR2"}, - {SIGPIPE,"SIGPIPE"}, {SIGALRM,"SIGALRM"}, {SIGTERM,"SIGTERM"}, - {SIGCHLD,"SIGCHLD"}, {SIGCONT,"SIGCONT"}, {SIGSTOP,"SIGSTOP"}, - {SIGTSTP,"SIGTSTP"}, {SIGTTIN,"SIGTTIN"}, {SIGTTOU,"SIGTTOU"}, - {SIGURG, "SIGURG" }, {SIGXCPU,"SIGXCPU"}, {SIGXFSZ,"SIGXFSZ"}, - {0, NULL} - }; - - for (i = 0; ; i++) { - if ( sigtbl[i].s_num == signo ) - return sigtbl[i].s_name; - if ( sigtbl[i].s_num == 0 ) - break; - } - - snprintf(str, 9, "signal %d", signo); - return str; -} - - static void _make_tmpdir(slurmd_job_t *job) { diff --git a/src/slurmd/slurmstepd/ulimits.c b/src/slurmd/slurmstepd/ulimits.c index bc4527ca4accb2689f919efe4b6c8b6778690f35..4e1cc4f692a26aec5ebf6d2ff03781177e66d582 100644 --- a/src/slurmd/slurmstepd/ulimits.c +++ b/src/slurmd/slurmstepd/ulimits.c @@ -100,6 +100,7 @@ _set_umask(char **env) mask = strtol(val, (char **)NULL, 8); umask(mask); + return SLURM_SUCCESS; } /* diff --git a/src/smap/configure_functions.c b/src/smap/configure_functions.c index c9146903058272385a7dc00dd0b9a1ba40175142..95d672531987d62ac227459e3c078a97d8a3810c 100644 --- a/src/smap/configure_functions.c +++ b/src/smap/configure_functions.c @@ -189,7 +189,6 @@ static int _create_allocation(char *com, List allocated_blocks) { int i=6, geoi=-1, starti=-1, i2=0, nodecards=-1, quarters=-1; int len = strlen(com); - char *temp = NULL; allocated_block_t *allocated_block = NULL; ba_request_t *request = (ba_request_t*) xmalloc(sizeof(ba_request_t)); @@ -271,7 +270,7 @@ static int _create_allocation(char *com, List allocated_blocks) sprintf(error_string, "please specify a complete split of a " "Base Partion\n" - "(i.e. nodecards=4)\0"); + "(i.e. nodecards=4)"); geoi = -1; } request->size = 1; @@ -466,11 +465,11 @@ static int _change_state_all_bps(char *com, int state) } static int _change_state_bps(char *com, int state) { - int i=0, j=0, x; + int i=0, x; int len = strlen(com); int start[SYSTEM_DIMENSIONS], end[SYSTEM_DIMENSIONS]; #ifdef HAVE_BG - int number=0, y=0, z=0; + int number=0, y=0, z=0, j=0; #endif char letter = '.'; char opposite = '#'; @@ -581,6 +580,7 @@ error_message: start[X],end[X]); #endif return 0; +#if HAVE_BG error_message2: memset(error_string,0,255); sprintf(error_string, @@ -588,6 +588,7 @@ error_message2: "You need to specify XYZ or XYZxXYZ", com+i,com); return 0; +#endif } static int _remove_allocation(char *com, List allocated_blocks) { @@ -781,7 +782,6 @@ static int _save_allocation(char *com, List allocated_blocks) char save_string[255]; FILE *file_ptr = NULL; char *conn_type = NULL; - char *mode_type = NULL; char extra[20]; ListIterator results_i; @@ -827,13 +827,13 @@ static int _save_allocation(char *com, List allocated_blocks) file_ptr); fputs ("Numpsets=8\n", file_ptr); fputs ("BridgeAPIVerbose=0\n", file_ptr); - sprintf(save_string, "BasePartitionNodeCnt=%d\n\0", + sprintf(save_string, "BasePartitionNodeCnt=%d\n", base_part_node_cnt); fputs (save_string,file_ptr); - sprintf(save_string, "NodeCardNodeCnt=%d\n\0", + sprintf(save_string, "NodeCardNodeCnt=%d\n", nodecard_node_cnt); fputs (save_string,file_ptr); - sprintf(save_string, "LayoutMode=%s\n\0", + sprintf(save_string, "LayoutMode=%s\n", layout_mode); fputs (save_string,file_ptr); @@ -849,7 +849,7 @@ static int _save_allocation(char *com, List allocated_blocks) conn_type = "MESH"; else { conn_type = "SMALL"; - sprintf(extra, " NodeCards=%d Quarters=%d\0", + sprintf(extra, " NodeCards=%d Quarters=%d", allocated_block->request->nodecards, allocated_block->request->quarters); } @@ -1010,7 +1010,6 @@ static int _load_configuration(char *com, List allocated_blocks) char in_line[BUFSIZE]; /* input line */ int line_num = 0; /* line number in input file */ - ListIterator results_i; _delete_allocated_blocks(allocated_blocks); allocated_blocks = list_create(NULL); diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index 913dbc9b92b0206d32018e7116cb218a7fa98f78..941c6dca49d8328cd07acbb1f1c257dd16af0288 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -57,7 +57,9 @@ static List block_list = NULL; static char* _convert_conn_type(enum connection_type conn_type); static char* _convert_node_use(enum node_use_type node_use); +#ifdef HAVE_BG static int _marknodes(db2_block_info_t *block_ptr, int count); +#endif static void _print_header_part(void); static char *_part_state_str(rm_partition_state_t state); static int _print_text_part(partition_info_t *part_ptr, @@ -348,6 +350,7 @@ extern void get_bg_part() return; } +#ifdef HAVE_BG static int _marknodes(db2_block_info_t *block_ptr, int count) { int j=0; @@ -407,6 +410,7 @@ static int _marknodes(db2_block_info_t *block_ptr, int count) } return SLURM_SUCCESS; } +#endif static void _print_header_part(void) { diff --git a/src/squeue/print.c b/src/squeue/print.c index 58fbd22bb12162181b1c7c146c010a257b899ea3..e7f09fe2eb64782cb81690ed293ca390eeca7aff 100644 --- a/src/squeue/print.c +++ b/src/squeue/print.c @@ -575,9 +575,9 @@ int _print_job_reason_list(job_info_t * job, int width, bool right, _print_nodes(job->nodes, width, right, false); if(quarter != (uint16_t) NO_VAL) { if(nodecard != (uint16_t) NO_VAL) - sprintf(tmp_char,".%d.%d\0",quarter,nodecard); + sprintf(tmp_char,".%d.%d",quarter,nodecard); else - sprintf(tmp_char,".%d\0",quarter); + sprintf(tmp_char,".%d",quarter); _print_str(tmp_char, width, right, false); } } @@ -626,7 +626,6 @@ int _print_job_num_nodes(job_info_t * job, int width, bool right_justify, { uint32_t node_cnt = 0; char tmp_char[6]; - int i=0; if (job == NULL) /* Print the Header instead */ _print_str("NODES", width, right_justify, true); diff --git a/src/srun/allocate.c b/src/srun/allocate.c index ed976bef2f8fd6362e61023be910614b82949a18..adc69c7ecf0c59ef5de7c90f37aa14dcfed833a8 100644 --- a/src/srun/allocate.c +++ b/src/srun/allocate.c @@ -40,6 +40,7 @@ #include "src/common/xmalloc.h" #include "src/common/xsignal.h" #include "src/common/xstring.h" +#include "src/common/forward.h" #include "src/srun/allocate.h" #include "src/srun/msg.h" @@ -538,7 +539,6 @@ create_job_step(srun_job_t *job, { job_step_create_request_msg_t *req = NULL; job_step_create_response_msg_t *resp = NULL; - char *temp = NULL; if (!(req = _step_req_create(job))) { error ("Unable to allocate step request message"); diff --git a/src/srun/core-format.c b/src/srun/core-format.c index 1750a3f3c9c0cfabe38cd84e60dd8e68977f73c4..9e4acc0976decb86f7275c90ea5c6e30883242fb 100644 --- a/src/srun/core-format.c +++ b/src/srun/core-format.c @@ -39,6 +39,7 @@ //#include "src/common/env.h" #include "src/srun/core-format.h" #include "src/common/log.h" +#include "src/common/env.h" #define CORE_NORMAL 0 #define CORE_LIGHT 1 /* Default lightweight corefile from liblwcf */ diff --git a/src/srun/io.c b/src/srun/io.c index e9cab59b3b6fb2587f30a18d5f23bd9ce6210b96..2da00953ae906229efdc2dc8fc225bcaab3c0950 100644 --- a/src/srun/io.c +++ b/src/srun/io.c @@ -61,7 +61,6 @@ static int fmt_width = 0; static void _init_stdio_eio_objs(srun_job_t *job); static void _handle_io_init_msg(int fd, srun_job_t *job); -static ssize_t _readx(int fd, char *buf, size_t maxbytes); static int _read_io_init_msg(int fd, srun_job_t *job, char *host); static int _wid(int n); static bool _incoming_buf_free(srun_job_t *job); @@ -174,6 +173,8 @@ _listening_socket_read(eio_obj_t *obj, List objs) debug3("Called _listening_socket_read"); _handle_io_init_msg(obj->fd, job); + + return (0); } static void @@ -215,7 +216,6 @@ static bool _server_readable(eio_obj_t *obj) { struct server_io_info *s = (struct server_io_info *) obj->arg; - int i; debug4("Called _server_readable"); @@ -513,7 +513,7 @@ static int _write_msg(int fd, void *buf, int len, int taskid) int remaining = len; int written = 0; int line_len; - int rc; + int rc = SLURM_SUCCESS; while (remaining > 0) { start = buf + written; @@ -814,8 +814,8 @@ io_thr_create(srun_job_t *job) xsignal(SIGTTIN, SIG_IGN); slurm_attr_init(&attr); - while (errno = pthread_create(&job->ioid, &attr, - &_io_thr_internal, (void *) job)) { + while ((errno = pthread_create(&job->ioid, &attr, + &_io_thr_internal, (void *) job))) { if (++retries > MAX_RETRIES) { error ("pthread_create error %m"); return SLURM_ERROR; @@ -944,23 +944,6 @@ _handle_io_init_msg(int fd, srun_job_t *job) } } -static ssize_t -_readx(int fd, char *buf, size_t maxbytes) -{ - size_t n; - - if ((n = read(fd, (void *) buf, maxbytes)) < 0) { - if (errno == EINTR) - return -1; - if ((errno == EAGAIN) || - (errno == EWOULDBLOCK)) - return -1; - error("readx fd %d: %m", fd, n); - return -1; /* shutdown socket, cleanup. */ - } - return n; -} - /* * io_node_fail - Some nodes have failed. Identify affected I/O streams. diff --git a/src/srun/launch.c b/src/srun/launch.c index 401901c30858ecb3c606f53dcd2a4dcd34f4c761..2e80209d1001d1e3e22c57a4e7326313833f2abf 100644 --- a/src/srun/launch.c +++ b/src/srun/launch.c @@ -33,6 +33,7 @@ #include <signal.h> #include <string.h> #include <unistd.h> +#include <stdlib.h> #include <sys/param.h> #include "src/common/log.h" @@ -44,6 +45,7 @@ #include "src/common/xstring.h" #include "src/common/xsignal.h" #include "src/common/forward.h" +#include "src/common/mpi.h" #include "src/srun/srun_job.h" #include "src/srun/launch.h" @@ -62,16 +64,16 @@ static int fail_launch_cnt = 0; typedef enum {DSH_NEW, DSH_ACTIVE, DSH_DONE, DSH_FAILED, DSH_JOINED} state_t; -typedef struct task_info { +typedef struct launch_info { slurm_msg_t *req; srun_job_t *job; -} task_info_t; +} launch_info_t; typedef struct thd { pthread_t thread; /* thread ID */ state_t state; /* thread state */ time_t tstart; /* time thread started */ - task_info_t task; + launch_info_t task; } thd_t; static int _check_pending_threads(thd_t *thd, int count); @@ -114,7 +116,6 @@ launch(void *arg) hostlist_iterator_t itr = NULL; char *host = NULL; int *span = set_span(job->step_layout->num_hosts); - char addrbuf[INET_ADDRSTRLEN]; Buf buffer = NULL; update_job_state(job, SRUN_JOB_LAUNCHING); @@ -479,19 +480,17 @@ _update_contacted_node(srun_job_t *j, int id) static void * _p_launch_task(void *arg) { thd_t *th = (thd_t *)arg; - task_info_t *tp = &(th->task); + launch_info_t *tp = &(th->task); slurm_msg_t *req = tp->req; launch_tasks_request_msg_t *msg = req->data; srun_job_t *job = tp->job; int nodeid = req->srun_node_id; - int failure = 0; int retry = 3; /* retry thrice */ List ret_list = NULL; ListIterator itr; ListIterator data_itr; ret_types_t *ret_type = NULL; ret_data_info_t *ret_data_info = NULL; - int found = 0; th->state = DSH_ACTIVE; th->tstart = time(NULL); diff --git a/src/srun/msg.c b/src/srun/msg.c index 7f8e3e753976501d5d384523505fabb9602b0f9e..22c84bed197afea01ea09dbada9cbbb4f031d1ad 100644 --- a/src/srun/msg.c +++ b/src/srun/msg.c @@ -53,6 +53,9 @@ #include "src/common/slurm_protocol_defs.h" #include "src/common/xassert.h" #include "src/common/xmalloc.h" +#include "src/common/mpi.h" +#include "src/common/forward.h" +#include "src/common/global_srun.h" #include "src/srun/srun_job.h" #include "src/srun/opt.h" @@ -61,6 +64,7 @@ #include "src/srun/pmi.h" #include "src/srun/sigstr.h" #include "src/srun/attach.h" +#include "src/srun/allocate.h" #include "src/common/xstring.h" @@ -104,6 +108,7 @@ static void _node_fail_handler(char *nodelist, srun_job_t *job); #define _poll_wr_isset(pfd) ((pfd).revents & POLLOUT) #define _poll_err(pfd) ((pfd).revents & POLLERR) +#undef safe_read #define safe_read(fd, ptr, size) do { \ if (read(fd, ptr, size) != size) { \ debug("%s:%d: %s: read (%d bytes) failed: %m", \ @@ -113,6 +118,7 @@ static void _node_fail_handler(char *nodelist, srun_job_t *job); } \ } while (0) +#undef safe_write #define safe_write(fd, ptr, size) do { \ if (write(fd, ptr, size) != size) { \ debug("%s:%d: %s: write (%d bytes) failed: %m", \ @@ -1039,7 +1045,6 @@ msg_thr(void *arg) { srun_job_t *job = (srun_job_t *) arg; forked_msg_pipe_t *par_msg = job->forked_msg->par_msg; - int done = 0; debug3("msg thread pid = %lu", (unsigned long) getpid()); slurm_uid = (uid_t) slurm_get_slurm_user_id(); @@ -1152,7 +1157,7 @@ par_thr(void *arg) close(par_msg->msg_pipe[0]); // close excess fildes close(msg_par->msg_pipe[1]); // close excess fildes if(waitpid(par_msg->pid,&status,0)<0) // wait for pid to finish - return;// there was an error + return NULL;// there was an error debug3("par thread done"); return (void *)1; } diff --git a/src/srun/pmi.c b/src/srun/pmi.c index 84593c206b7bb43d97f8055d78d7d0fb4c18b1a7..5a876b4f8c3b4574fb699fd648d88fb593f21f23 100644 --- a/src/srun/pmi.c +++ b/src/srun/pmi.c @@ -35,6 +35,7 @@ #include "src/api/slurm_pmi.h" #include "src/common/macros.h" #include "src/common/slurm_protocol_defs.h" +#include "src/common/slurm_protocol_api.h" #include "src/common/xsignal.h" #include "src/common/xstring.h" #include "src/common/xmalloc.h" @@ -161,7 +162,8 @@ static void *_msg_thread(void *x) success = 1; } -fini: slurm_mutex_lock(&agent_mutex); +/* fini: */ + slurm_mutex_lock(&agent_mutex); agent_cnt--; if (success) msg_arg_ptr->bar_ptr->port = 0; diff --git a/src/srun/reattach.c b/src/srun/reattach.c index 2f280fb1ae1d627cad402bcd4bd39f6ab273ee3b..f304d29c6b4fd353b76321f16ae9bf92d1f342a4 100644 --- a/src/srun/reattach.c +++ b/src/srun/reattach.c @@ -45,6 +45,7 @@ #include "src/common/hostlist.h" #include "src/common/slurm_protocol_api.h" #include "src/common/read_config.h" +#include "src/common/forward.h" #include "src/srun/srun_job.h" #include "src/srun/launch.h" @@ -324,7 +325,7 @@ _attach_to_job(srun_job_t *job) m->data = r; m->msg_type = REQUEST_REATTACH_TASKS; - forward_init(&m->forward.cnt, NULL); + forward_init(&m->forward, NULL); m->ret_list = NULL; memcpy(&m->address, &job->slurmd_addr[i], sizeof(slurm_addr)); diff --git a/src/srun/signals.c b/src/srun/signals.c index fe3629db14d610f4bde15e7dc4a878f4434046fc..1e681c4adf59a641ef5988d5acfc6facf3ec32f9 100644 --- a/src/srun/signals.c +++ b/src/srun/signals.c @@ -44,6 +44,7 @@ #include "src/common/slurm_protocol_defs.h" #include "src/common/xmalloc.h" #include "src/common/xsignal.h" +#include "src/common/global_srun.h" #include "src/srun/srun_job.h" @@ -57,19 +58,6 @@ static int srun_sigarray[] = { SIGALRM, SIGUSR1, SIGUSR2, SIGPIPE, 0 }; -/* number of active threads */ -static pthread_mutex_t active_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t active_cond = PTHREAD_COND_INITIALIZER; -static int active = 0; - -typedef enum {DSH_NEW, DSH_ACTIVE, DSH_DONE, DSH_FAILED} state_t; - -typedef struct thd { - pthread_t thread; /* thread ID */ - pthread_attr_t attr; /* thread attributes */ - state_t state; /* thread state */ -} thd_t; - typedef struct task_info { slurm_msg_t *req_ptr; srun_job_t *job_ptr; diff --git a/src/srun/srun.c b/src/srun/srun.c index b4ba6a1293110ee71faf88cf13bcb0d8cfd1381f..667db80ba0f96e130041d965df4c554e6076f7f3 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -117,11 +117,8 @@ int srun(int ac, char **av) { allocation_resp *resp; srun_job_t *job = NULL; - char *task_cnt, *bgl_part_id = NULL; int exitcode = 0; env_t *env = xmalloc(sizeof(env_t)); - char *prolog = NULL; - char *epilog = NULL; log_options_t logopt = LOG_OPTS_STDERR_ONLY; diff --git a/src/srun/srun_job.c b/src/srun/srun_job.c index e42875d9e61fc70279ffc1c31247ebdc70762ee5..28398026c291a176c2cf9c5301a5fd615eb0e201 100644 --- a/src/srun/srun_job.c +++ b/src/srun/srun_job.c @@ -45,6 +45,7 @@ #include "src/common/xmalloc.h" #include "src/common/xstring.h" #include "src/common/io_hdr.h" +#include "src/common/global_srun.h" #include "src/srun/srun_job.h" #include "src/srun/opt.h" @@ -198,7 +199,7 @@ static srun_job_t * _job_create_structure(allocation_info_t *info) { srun_job_t *job = xmalloc(sizeof(srun_job_t)); - int i, cpu_inx, cpu_cnt; + int i; _set_nprocs(info); debug2("creating job with %d tasks", opt.nprocs);