diff --git a/NEWS b/NEWS index 664d2ab7113a9937b351a1f5664e8ba246a20a9b..c7c8da6990d6d56cf1b05ac48135089bd01e6283 100644 --- a/NEWS +++ b/NEWS @@ -285,8 +285,6 @@ documents those changes that are of interest to users and administrators. -- Documentation - cleanup typos. -- Add logic so that slurmstepd can be launched under valgrind. -- Increase buffer size to read /proc/*/stat files. - -- Fix hostrange_hn_within to allow hostname lookup within a set of nodes - with different length prefixes. -- MYSQL - Handle ER_HOST_IS_BLOCKED better by failing when it occurs instead of continuously printing the message over and over as the problem will most likely not resolve itself. diff --git a/src/common/hostlist.c b/src/common/hostlist.c index 3ffca6ad48386be74d5a550774c22c424274ce04..422c3057d9906cd17949669dbb8c05f217d3b413 100644 --- a/src/common/hostlist.c +++ b/src/common/hostlist.c @@ -76,7 +76,6 @@ #include "src/common/working_cluster.h" #include "src/common/xassert.h" #include "src/common/xmalloc.h" -#include "src/common/xstring.h" /* * Define slurm-specific aliases for use by plugins, see slurm_xlator.h @@ -372,7 +371,7 @@ static char * hostrange_pop(hostrange_t); static char * hostrange_shift(hostrange_t, int); static int hostrange_join(hostrange_t, hostrange_t); static hostrange_t hostrange_intersect(hostrange_t, hostrange_t); -static bool _hostrange_hn_within(const hostrange_t, const hostname_t); +static int hostrange_hn_within(hostrange_t, hostname_t); static size_t hostrange_to_string(hostrange_t hr, size_t, char *, char *, int); static size_t hostrange_numstr(hostrange_t, size_t, char *, int); @@ -1102,12 +1101,11 @@ static hostrange_t hostrange_intersect(hostrange_t h1, hostrange_t h2) return new; } -/* return true if hostname hn is within the hostrange hr */ -static bool _hostrange_hn_within(const hostrange_t hr, const hostname_t hn) +/* return 1 if hostname hn is within the hostrange hr + * 0 if not. + */ +static int hostrange_hn_within(hostrange_t hr, hostname_t hn) { - hostname_t hn_tmp; - int retval = false; - if (hr->singlehost) { /* * If the current hostrange [hr] is a `singlehost' (no valid @@ -1118,7 +1116,10 @@ static bool _hostrange_hn_within(const hostrange_t hr, const hostname_t hn) * which case we return true. Otherwise, there is no * possibility that [hn] matches [hr]. */ - return !xstrcmp(hn->hostname, hr->prefix); + if (strcmp (hn->hostname, hr->prefix) == 0) + return 1; + else + return 0; } /* @@ -1126,20 +1127,19 @@ static bool _hostrange_hn_within(const hostrange_t hr, const hostname_t hn) * better have a valid numeric suffix, or there is no * way we can match */ - if (!hostname_suffix_is_valid(hn)) - return false; + if (!hostname_suffix_is_valid (hn)) + return 0; /* * If hostrange and hostname prefixes don't match, then * there is way the hostname falls within the range [hr]. */ - hn_tmp = hostname_create(hn->hostname); - if (xstrcmp(hr->prefix, hn->prefix) != 0) { + if (strcmp(hr->prefix, hn->prefix) != 0) { int len1, len2, ldiff; int dims = slurmdb_setup_cluster_name_dims(); if (dims != 1) - goto done; + return 0; /* Below logic was added since primarily for a cray * where people typically drop @@ -1160,14 +1160,14 @@ static bool _hostrange_hn_within(const hostrange_t hr, const hostname_t hn) ldiff = len1 - len2; if (ldiff > 0 && isdigit(hr->prefix[len1-1]) - && (strlen(hn_tmp->suffix) >= ldiff)) { + && (strlen(hn->suffix) >= ldiff)) { /* Tack on ldiff of the hostname's suffix to that of * it's prefix */ hn->prefix = realloc(hn->prefix, len2+ldiff+1); - strncat(hn_tmp->prefix, hn_tmp->suffix, ldiff); + strncat(hn->prefix, hn->suffix, ldiff); /* Now adjust the suffix of the hostname object. */ - hn_tmp->suffix += ldiff; - /* And the numeric representation just in case + hn->suffix += ldiff; + /* And the numeric representation just incase * whatever we just tacked on to the prefix * had something other than 0 in it. * @@ -1175,29 +1175,26 @@ static bool _hostrange_hn_within(const hostrange_t hr, const hostname_t hn) * single dimension systems we will always use * the base 10. */ - hn_tmp->num = strtoul(hn_tmp->suffix, NULL, 10); + hn->num = strtoul(hn->suffix, NULL, 10); /* Now compare them and see if they match */ - if (xstrcmp(hr->prefix, hn_tmp->prefix) != 0) - goto done; - } else { - goto done; - } + if (strcmp(hr->prefix, hn->prefix) != 0) + return 0; + } else + return 0; } /* * Finally, check whether [hn], with a valid numeric suffix, * falls within the range of [hr]. */ - if (hn_tmp->num <= hr->hi && hn_tmp->num >= hr->lo) { - int width = hostname_suffix_width(hn_tmp); - int num = hn_tmp->num; - retval = _width_equiv(hr->lo, &hr->width, num, &width); + if (hn->num <= hr->hi && hn->num >= hr->lo) { + int width = hostname_suffix_width(hn); + int num = hn->num; + return (_width_equiv(hr->lo, &hr->width, num, &width)); } -done: - hostname_destroy(hn_tmp); - return retval; + return 0; } @@ -2445,7 +2442,7 @@ int hostlist_find(hostlist_t hl, const char *hostname) LOCK_HOSTLIST(hl); for (i = 0, count = 0; i < hl->nranges; i++) { - if (_hostrange_hn_within(hl->hr[i], hn)) { + if (hostrange_hn_within(hl->hr[i], hn)) { if (hostname_suffix_is_valid(hn)) ret = count + hn->num - hl->hr[i]->lo; else @@ -3667,7 +3664,7 @@ static int hostset_find_host(hostset_t set, const char *host) LOCK_HOSTLIST(set->hl); hn = hostname_create(host); for (i = 0; i < set->hl->nranges; i++) { - if (_hostrange_hn_within(set->hl->hr[i], hn)) { + if (hostrange_hn_within(set->hl->hr[i], hn)) { retval = 1; goto done; }