diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index ceaf22d520776327581ea5584e3cdffb8e354d59..a422bfbda78f36d386a7a16ce19600f7a6472b98 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -201,7 +201,12 @@ typedef enum { \*****************************************************************************/ typedef struct forward { slurm_addr *addr; /* array of network addresses */ - char *name; /* node names in hostlist_t string format */ + /* "name" must be a string of length (cnt * MAX_SLURM_NAME), with + * NodeName strings for each node available at regular offsets + * of MAX_SLURM_NAME characters into the string. + * FIXME - This is ugly, and scales poorly - CJM. + */ + char *name; uint32_t *node_id; /* ARRAY of node ids (relative to job) */ /* Or not, forwarding used to talk to non-job and non-jobstep sets of nodes, so what are the node_ids supposed to be then?!? - CJM */ diff --git a/src/sattach/sattach.c b/src/sattach/sattach.c index fdae4575983ba129ddac6e49c65a7e15bc388d10..77059bbdf59c758d8cfd4fec226ce86e540e1e01 100644 --- a/src/sattach/sattach.c +++ b/src/sattach/sattach.c @@ -185,6 +185,7 @@ static slurm_cred_t _generate_fake_cred(uint32_t jobid, uint32_t stepid, } +#if 0 /* * Take a string representing a node list, remove the first node in the list, * and return an xmalloc()ed string of the remaining nodes. @@ -213,6 +214,43 @@ static char *_node_list_remove_first(const char *nodes) hostlist_destroy(nodes_list); return new_nodes; } +#endif + +/* + * Take a NodeNode name list in hostlist_t string format, and expand + * it into one giant string of NodeNames, in which each NodeName is + * found at regular offsets of MAX_SLURM_NAME bytes into the string. + * + * Also, it trims off the first NodeName, which is not used because we + * send to that node directly. + * + * Free returned string with xfree(); + */ +static char *_create_ugly_nodename_string(const char *node_list, uint32_t count) +{ + char *ugly_str; + hostlist_t nl; + hostlist_iterator_t itr; + char *node; + int i; + + ugly_str = xmalloc(MAX_SLURM_NAME *count); + nl = hostlist_create(node_list); + itr = hostlist_iterator_create(nl); + + /* skip the first node */ + free(hostlist_next(itr)); + + /* now add all remaining node names up to a maximum of "count" */ + for (i = 0; (i < count) && ((node = hostlist_next(itr)) != NULL); i++) { + strcpy(ugly_str + (i*MAX_SLURM_NAME), node); + free(node); + } + + hostlist_iterator_destroy(itr); + hostlist_destroy(nl); + return ugly_str; +} /* * Create a simple array of sequential uint32_t values from "first" to "last". @@ -282,7 +320,8 @@ static int _attach_to_tasks(uint32_t jobid, msg.forward.cnt = layout->node_cnt - 1; msg.forward.node_id = _create_range_array(1, layout->node_cnt-1); info("msg.forward.cnt = %d", msg.forward.cnt); - msg.forward.name = _node_list_remove_first(layout->node_list); + msg.forward.name = _create_ugly_nodename_string(layout->node_list, + layout->node_cnt-1); info("msg.forward.name = %s", msg.forward.name); msg.forward.addr = layout->node_addr + 1; msg.forward.timeout = timeout * 1000; /* sec to msec */