Skip to content
Snippets Groups Projects
Commit de11fda3 authored by Danny Auble's avatar Danny Auble
Browse files

updated documentation for slurm_receive_msg and fixes where that function wasn't used correctly

parent 01b95a7f
No related branches found
No related tags found
No related merge requests found
...@@ -110,6 +110,7 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr, ...@@ -110,6 +110,7 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr,
uint16_t port; uint16_t port;
kvs_get_msg_t data; kvs_get_msg_t data;
char *env_pmi_ifhn; char *env_pmi_ifhn;
List ret_list = NULL;
if (kvs_set_ptr == NULL) if (kvs_set_ptr == NULL)
return EINVAL; return EINVAL;
...@@ -183,12 +184,20 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr, ...@@ -183,12 +184,20 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr,
error("slurm_accept_msg_conn: %m"); error("slurm_accept_msg_conn: %m");
return errno; return errno;
} }
while (slurm_receive_msg(srun_fd, &msg_rcv, 0) < 0) { while ((ret_list = slurm_receive_msg(srun_fd, &msg_rcv, 0)) == NULL) {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
error("slurm_receive_msg: %m"); error("slurm_receive_msg: %m");
return errno; return errno;
} }
if(ret_list) {
if(list_count(ret_list)>0) {
error("We didn't do things correctly "
"got %d responses didn't expect any",
list_count(ret_list));
}
list_destroy(ret_list);
}
msg_rcv.conn_fd = srun_fd; msg_rcv.conn_fd = srun_fd;
if (msg_rcv.msg_type != PMI_KVS_GET_RESP) { if (msg_rcv.msg_type != PMI_KVS_GET_RESP) {
error("slurm_get_kvs_comm_set msg_type=%d", msg_rcv.msg_type); error("slurm_get_kvs_comm_set msg_type=%d", msg_rcv.msg_type);
......
...@@ -697,11 +697,13 @@ int slurm_close_accepted_conn(slurm_fd open_fd) ...@@ -697,11 +697,13 @@ int slurm_close_accepted_conn(slurm_fd open_fd)
\**********************************************************************/ \**********************************************************************/
/* /*
* NOTE: memory is allocated for the returned msg and must be freed at * NOTE: memory is allocated for the returned msg and the returned list
* some point using the slurm_free_functions * both must be freed at some point using the slurm_free_functions
* and list_destroy function.
* IN open_fd - file descriptor to receive msg on * IN open_fd - file descriptor to receive msg on
* OUT msg - a slurm_msg struct to be filled in by the function * OUT msg - a slurm_msg struct to be filled in by the function
* RET int - size of msg received in bytes before being unpacked * RET List - List containing the responses of the childern (if any) we
* forwarded the message to.
*/ */
List slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout) List slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout)
{ {
...@@ -1316,6 +1318,8 @@ int slurm_send_rc_msg(slurm_msg_t *msg, int rc) ...@@ -1316,6 +1318,8 @@ int slurm_send_rc_msg(slurm_msg_t *msg, int rc)
/* /*
* Send and recv a slurm request and response on the open slurm descriptor * Send and recv a slurm request and response on the open slurm descriptor
* with a list containing the responses of the childern (if any) we
* forwarded the message to.
*/ */
static List static List
_send_and_recv_msg(slurm_fd fd, slurm_msg_t *req, _send_and_recv_msg(slurm_fd fd, slurm_msg_t *req,
...@@ -1408,7 +1412,7 @@ int slurm_send_recv_controller_msg(slurm_msg_t *req, slurm_msg_t *resp) ...@@ -1408,7 +1412,7 @@ int slurm_send_recv_controller_msg(slurm_msg_t *req, slurm_msg_t *resp)
if(ret_list) { if(ret_list) {
if(list_count(ret_list)>0) { if(list_count(ret_list)>0) {
error("We didn't do things correctly " error("We didn't do things correctly "
"missed %d responses", "got %d responses didn't expect any",
list_count(ret_list)); list_count(ret_list));
} }
list_destroy(ret_list); list_destroy(ret_list);
......
...@@ -277,8 +277,9 @@ int inline slurm_shutdown_msg_engine(slurm_fd open_fd); ...@@ -277,8 +277,9 @@ int inline slurm_shutdown_msg_engine(slurm_fd open_fd);
* (msg->data) is allocated from within this function, and must be * (msg->data) is allocated from within this function, and must be
* freed at some point using one of the slurm_free* functions. * freed at some point using one of the slurm_free* functions.
* *
* Returns SLURM_SUCCESS if an entire message is successfully * Returns List containing the responses of the childern (if any) we
* received. Otherwise SLURM_ERROR is returned. * forwarded the message to if an entire message is successfully
* received. Otherwise NULL is returned.
*/ */
List slurm_receive_msg(slurm_fd fd, slurm_msg_t *resp, int timeout); List slurm_receive_msg(slurm_fd fd, slurm_msg_t *resp, int timeout);
......
...@@ -12,6 +12,7 @@ int main ( int argc , char * argv[] ) ...@@ -12,6 +12,7 @@ int main ( int argc , char * argv[] )
slurm_msg_t resp; slurm_msg_t resp;
int16_t port = 0; int16_t port = 0;
update_node_msg_t *in_msg, out_msg; update_node_msg_t *in_msg, out_msg;
List ret_list = NULL;
/* init address sturctures */ /* init address sturctures */
if (argc > 1) if (argc > 1)
...@@ -32,9 +33,16 @@ int main ( int argc , char * argv[] ) ...@@ -32,9 +33,16 @@ int main ( int argc , char * argv[] )
slurm_send_node_msg( worker_socket , &msg ) ; slurm_send_node_msg( worker_socket , &msg ) ;
printf("Sending message=%s\n", out_msg.node_names); printf("Sending message=%s\n", out_msg.node_names);
if (slurm_receive_msg (worker_socket, &resp, 0) < 0) { if ((ret_list = slurm_receive_msg(worker_socket, &resp, 0)) == NULL) {
printf("Error reading slurm_receive_msg %m\n"); printf("Error reading slurm_receive_msg %m\n");
exit(1); exit(1);
} else {
if(list_count(ret_list)>0) {
error("We didn't do things correctly "
"got %d responses didn't expect any",
list_count(ret_list));
}
list_destroy(ret_list);
} }
if (resp.msg_type != REQUEST_UPDATE_NODE) { if (resp.msg_type != REQUEST_UPDATE_NODE) {
printf("Got wrong message type: %u\n", resp.msg_type); printf("Got wrong message type: %u\n", resp.msg_type);
......
...@@ -13,6 +13,7 @@ int main ( int argc , char * argv[] ) ...@@ -13,6 +13,7 @@ int main ( int argc , char * argv[] )
slurm_msg_t resp; slurm_msg_t resp;
int16_t port = 0; int16_t port = 0;
update_node_msg_t *in_msg, out_msg; update_node_msg_t *in_msg, out_msg;
List ret_list = NULL;
/* init address sturctures */ /* init address sturctures */
if (argc > 1) if (argc > 1)
...@@ -29,9 +30,17 @@ int main ( int argc , char * argv[] ) ...@@ -29,9 +30,17 @@ int main ( int argc , char * argv[] )
printf ( "worker socket %i\n", worker_socket ) ; printf ( "worker socket %i\n", worker_socket ) ;
while (1) { while (1) {
if (slurm_receive_msg (worker_socket, &msg, 0) == SLURM_SOCKET_ERROR ) { if ((ret_list = slurm_receive_msg(worker_socket, &resp, 0))
printf ("slurm_receive_msg error\n"); == NULL) {
printf ("Error reading slurm_receive_msg %m\n");
break; break;
} else {
if(list_count(ret_list)>0) {
error("We didn't do things correctly "
"got %d responses didn't expect any",
list_count(ret_list));
}
list_destroy(ret_list);
} }
if (msg.msg_type == REQUEST_SHUTDOWN_IMMEDIATE) { if (msg.msg_type == REQUEST_SHUTDOWN_IMMEDIATE) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment