diff --git a/src/sbcast/sbcast.c b/src/sbcast/sbcast.c index e0420e472158d5d24d46091c7e50b82a90c7955d..3cffb04b58be9d8f212f24233964846d4f9e8bc3 100644 --- a/src/sbcast/sbcast.c +++ b/src/sbcast/sbcast.c @@ -44,6 +44,7 @@ #include "src/common/log.h" #include "src/common/slurm_protocol_api.h" #include "src/common/slurm_protocol_defs.h" +#include "src/common/slurm_protocol_interface.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" #include "src/sbcast/sbcast.h" @@ -165,7 +166,8 @@ static int _get_block(char *buffer, size_t buf_size) /* issue the RPC to ship the file's data */ static void _send_rpc(file_bcast_msg_t *bcast_msg) { -#if 1 +#if 0 + /* Temporary test code to xmit a file to only node 0 */ slurm_msg_t msg; int rc; @@ -177,45 +179,72 @@ static void _send_rpc(file_bcast_msg_t *bcast_msg) error("slurm_send_recv_rc_msg_only_one: %m"); exit(1); } + if (rc) { + error("REQUEST_FILE_BCAST: %s", slurm_strerror(rc)); + exit(1); + } #else -// This code will handle message fanout to multiple slurmd, not implemented yet - int i, rc; - - /* use static structures for persistent communcations data */ - static slurm_msg_t *msg = NULL; /* array of message structs, one per node */ - static int *rc_array; - static int node_cnt; - - if (!msg) { - node_cnt = alloc_resp->node_cnt; - msg = xmalloc(sizeof(slurm_msg_t) * node_cnt); - rc_array = xmalloc(sizeof(int) * node_cnt); - for (i = 0; i < node_cnt; i++) { - msg[i].msg_type = REQUEST_FILE_BCAST; - msg[i].address = alloc_resp->node_addr[i]; - } - slurm_free_resource_allocation_response_msg(alloc_resp); + /* This code will handle message fanout to multiple slurmd */ + forward_t from, forward; + slurm_msg_t msg; + hostlist_t hl; + List ret_list = NULL; + ListIterator itr, data_itr; + ret_types_t *ret_type = NULL; + ret_data_info_t *ret_data_info = NULL; + int i, rc = SLURM_SUCCESS; + + from.cnt = alloc_resp->node_cnt; + from.name = xmalloc(MAX_SLURM_NAME * alloc_resp->node_cnt); + hl = hostlist_create(alloc_resp->node_list); + for (i=0; i<alloc_resp->node_cnt; i++) { + char *host = hostlist_shift(hl); + strncpy(&from.name[MAX_SLURM_NAME*i], host, MAX_SLURM_NAME); + free(host); + } + hostlist_destroy(hl); + from.addr = alloc_resp->node_addr; + from.node_id = NULL; + from.timeout = SLURM_MESSAGE_TIMEOUT_MSEC_STATIC; + i = 0; + forward_set(&forward, alloc_resp->node_cnt, &i, &from); + + msg.msg_type = REQUEST_FILE_BCAST; + msg.address = alloc_resp->node_addr[0]; + msg.data = bcast_msg; + msg.forward = forward; + msg.ret_list = NULL; + msg.orig_addr.sin_addr.s_addr = 0; + msg.srun_node_id = 0; + + ret_list = slurm_send_recv_rc_msg(&msg, + SLURM_MESSAGE_TIMEOUT_MSEC_STATIC); + if (ret_list == NULL) { + error("slurm_send_recv_rc_msg: %m"); + exit(1); } - for (i = 0; i < node_cnt; i++) - msg[i].data = bcast_msg; - - verbose("sending block %u with %u bytes to %d nodes", - bcast_msg->block_no, bcast_msg->block_len, node_cnt); - //_p_send_recv_rc_msg(alloc_resp->node_cnt, msg, rc_array, 10); - rc = 0; - for (i = 0; i < node_cnt; i++) { - if (rc_array[i]) { - rc = rc_array[i]; - break; + itr = list_iterator_create(ret_list); + while ((ret_type = list_next(itr)) != NULL) { + data_itr = list_iterator_create(ret_type->ret_data_list); + while((ret_data_info = list_next(data_itr)) != NULL) { + i = ret_type->msg_rc; + if (i != SLURM_SUCCESS) { + error("REQUEST_FILE_BCAST(%s): %s", + ret_data_info->node_name, + slurm_strerror(i)); + rc = i; + } } + list_iterator_destroy(data_itr); } -#endif - - if (rc) { - error("REQUEST_FILE_BCAST: %s", slurm_strerror(rc)); + list_iterator_destroy(itr); + if (ret_list) + list_destroy(ret_list); + if (rc) exit(1); - } +// slurm_free_resource_allocation_response_msg(alloc_resp); +#endif } /* read and broadcast the file */