File Add-call-to-slurm_init-this-makes-sure-the-config-options-are-set.patch of Package pdsh
From: Egbert Eich <eich@suse.com>
Date: Mon Mar 13 15:27:01 2023 +0100
Subject: Add call to slurm_init() - this makes sure, the config options are set.
Patch-mainline: Not yet
Git-commit: b158df3b522360247bef95544c54708b05f069f7
References:
Signed-off-by: Egbert Eich <eich@suse.com>
Signed-off-by: Egbert Eich <eich@suse.de>
---
src/modules/slurm.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/modules/slurm.c b/src/modules/slurm.c
index 48e6dde..20613c2 100644
--- a/src/modules/slurm.c
+++ b/src/modules/slurm.c
@@ -295,6 +295,19 @@ static hostlist_t _hl_append (hostlist_t hl, char *nodes)
return (hl);
}
+/*
+ * Make sure, slurm_init() is called before any call to the Slurm API
+ */
+static void _slurm_init() {
+ static bool _inited = false;
+
+ if (_inited)
+ return;
+
+ slurm_init(NULL);
+ _inited = true;
+}
+
static hostlist_t _slurm_wcoll (List joblist)
{
int i;
@@ -306,6 +319,8 @@ static hostlist_t _slurm_wcoll (List joblist)
if ((joblist == NULL) && (envjobid = _slurm_jobid()) < 0)
return (NULL);
+ _slurm_init(NULL);
+
if (slurm_load_jobs((time_t) NULL, &msg, SHOW_ALL) < 0)
errx ("Unable to contact slurm controller: %s\n",
slurm_strerror (errno));
@@ -355,6 +370,8 @@ static hostlist_t _slurm_wcoll_partition (List partitionlist)
partition_info_t * p;
ListIterator li;
+ _slurm_init(NULL);
+
if (slurm_load_partitions((time_t) NULL, &msg, SHOW_ALL) < 0)
errx ("Unable to contact slurm controller: %s\n",
slurm_strerror (errno));
@@ -398,6 +415,8 @@ static hostlist_t _slurm_wcoll_constraint (hostlist_t wl, List constraintlist)
char *c;
ListIterator li;
+ _slurm_init(NULL);
+
if (slurm_load_node((time_t) NULL, &msg, SHOW_ALL) < 0)
errx ("Unable to contact slurm controller: %s\n",
slurm_strerror (errno));