From dbe7f2d568f88483b8a1d386c21f5e81c5177ab0 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" <morrone2@llnl.gov> Date: Wed, 6 Sep 2006 03:14:32 +0000 Subject: [PATCH] Attempt to clean up the slurm_msg_t initializer function. slurm_init_slurm_msg is replaced by slurm_msg_t_init and slurm_msg_t_copy. slurm_msg_t_init COMPLETELY initializes the structure, so it needs to be called BEFORE setting any variables within the structure. It is not clear if slurm_msg_t_copy is even necessary, it is only used in three places. --- src/api/allocate.c | 24 +++++---------- src/api/checkpoint.c | 2 ++ src/api/job_info.c | 6 ++-- src/api/reconfigure.c | 5 ++-- src/api/slurm_pmi.c | 4 +-- src/api/step_launch.c | 3 +- src/common/slurm_protocol_api.c | 34 ++++++++++++++++----- src/common/slurm_protocol_defs.c | 51 ++++++++++++++++++++------------ src/common/slurm_protocol_defs.h | 19 ++++++++---- src/salloc/msg.c | 2 +- src/sattach/sattach.c | 19 +++++------- src/slurmctld/agent.c | 3 +- src/slurmctld/controller.c | 2 +- src/slurmctld/job_mgr.c | 8 ++--- src/slurmctld/proc_req.c | 32 ++++++++++---------- src/slurmctld/step_mgr.c | 4 +-- src/slurmd/slurmd/req.c | 11 ++++--- src/slurmd/slurmd/slurmd.c | 6 ++-- src/slurmd/slurmstepd/mgr.c | 8 ++--- src/srun/allocate.c | 2 +- src/srun/launch.c | 2 +- src/srun/msg.c | 2 +- src/srun/reattach.c | 2 +- 23 files changed, 140 insertions(+), 111 deletions(-) diff --git a/src/api/allocate.c b/src/api/allocate.c index b181d82bb6a..414606da3bb 100644 --- a/src/api/allocate.c +++ b/src/api/allocate.c @@ -99,8 +99,8 @@ slurm_allocate_resources (job_desc_msg_t *req, bool host_set = false; char host[64]; - slurm_init_slurm_msg(&req_msg, NULL); - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&req_msg); + slurm_msg_t_init(&resp_msg); /* * set Node and session id for this request @@ -182,8 +182,8 @@ slurm_allocate_resources_blocking (const job_desc_msg_t *user_req, if (timeout == 0) timeout = (time_t)-1; - slurm_init_slurm_msg(&req_msg, NULL); - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&req_msg); + slurm_msg_t_init(&resp_msg); /* make a copy of the user's job description struct so that we * can make changes before contacting the controller */ @@ -324,14 +324,10 @@ slurm_job_step_create (job_step_create_request_msg_t *req, slurm_msg_t req_msg; slurm_msg_t resp_msg; + slurm_msg_t_init(&resp_msg); + slurm_msg_t_init(&req_msg); req_msg.msg_type = REQUEST_JOB_STEP_CREATE; req_msg.data = req; - forward_init(&req_msg.forward, NULL); - req_msg.ret_list = NULL; - req_msg.forward_struct_init = 0; - forward_init(&resp_msg.forward, NULL); - resp_msg.ret_list = NULL; - resp_msg.forward_struct_init = 0; if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; @@ -369,11 +365,9 @@ slurm_allocation_lookup(uint32_t jobid, slurm_msg_t resp_msg; req.job_id = jobid; + slurm_msg_t_init(&req_msg); req_msg.msg_type = REQUEST_JOB_ALLOCATION_INFO; req_msg.data = &req; - forward_init(&req_msg.forward, NULL); - req_msg.ret_list = NULL; - req_msg.forward_struct_init = 0; if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; @@ -413,11 +407,9 @@ slurm_allocation_lookup_lite(uint32_t jobid, slurm_msg_t resp_msg; req.job_id = jobid; + slurm_msg_t_init(&req_msg); req_msg.msg_type = REQUEST_JOB_ALLOCATION_INFO_LITE; req_msg.data = &req; - forward_init(&req_msg.forward, NULL); - req_msg.ret_list = NULL; - req_msg.forward_struct_init = 0; if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; diff --git a/src/api/checkpoint.c b/src/api/checkpoint.c index 801e056ccbd..33e19288098 100644 --- a/src/api/checkpoint.c +++ b/src/api/checkpoint.c @@ -97,6 +97,7 @@ extern int slurm_checkpoint_able (uint32_t job_id, uint32_t step_id, ckp_req.op = CHECK_ABLE; ckp_req.job_id = job_id; ckp_req.step_id = step_id; + slurm_msg_t_init(&req_msg); req_msg.msg_type = REQUEST_CHECKPOINT; req_msg.data = &ckp_req; @@ -245,6 +246,7 @@ extern int slurm_checkpoint_error ( uint32_t job_id, uint32_t step_id, req.op = CHECK_ERROR; req.job_id = job_id; req.step_id = step_id; + slurm_msg_t_init(&msg); msg.msg_type = REQUEST_CHECKPOINT; msg.data = &req; diff --git a/src/api/job_info.c b/src/api/job_info.c index cc1fb74d329..d6fe99cf078 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -408,10 +408,8 @@ slurm_pid2jobid (pid_t job_pid, uint32_t *jobid) job_id_request_msg_t req; List ret_list; - memset(&req_msg, 0, sizeof(slurm_msg_t)); - slurm_init_slurm_msg(&req_msg, NULL); - memset(&resp_msg, 0, sizeof(slurm_msg_t)); - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&req_msg); + slurm_msg_t_init(&resp_msg); /* * Set request message address to slurmd on localhost diff --git a/src/api/reconfigure.c b/src/api/reconfigure.c index 5af6c78072e..ba07cb41cb8 100644 --- a/src/api/reconfigure.c +++ b/src/api/reconfigure.c @@ -87,6 +87,7 @@ slurm_ping (int primary) int rc ; slurm_msg_t request_msg ; + slurm_msg_t_init(&request_msg); request_msg.msg_type = REQUEST_PING ; if (primary == 1) @@ -114,6 +115,7 @@ slurm_shutdown (uint16_t core) slurm_msg_t req_msg; shutdown_msg_t shutdown_msg; + slurm_msg_t_init(&req_msg); shutdown_msg.core = core; req_msg.msg_type = REQUEST_SHUTDOWN; req_msg.data = &shutdown_msg; @@ -136,8 +138,7 @@ _send_message_controller (enum controller_id dest, slurm_msg_t *req) List ret_list = NULL; /*always only going to 1 node */ - slurm_init_slurm_msg(req, NULL); - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&resp_msg); if ((fd = slurm_open_controller_conn_spec(dest)) < 0) slurm_seterrno_ret(SLURMCTLD_COMMUNICATIONS_CONNECTION_ERROR); diff --git a/src/api/slurm_pmi.c b/src/api/slurm_pmi.c index b27ecf94b2d..84d4040f77c 100644 --- a/src/api/slurm_pmi.c +++ b/src/api/slurm_pmi.c @@ -84,7 +84,7 @@ int slurm_send_kvs_comm_set(struct kvs_comm_set *kvs_set_ptr, if ((rc = _get_addr()) != SLURM_SUCCESS) return rc; - slurm_init_slurm_msg(&msg_send, NULL); + slurm_msg_t_init(&msg_send); msg_send.address = srun_addr; msg_send.msg_type = PMI_KVS_PUT_REQ; msg_send.data = (void *) kvs_set_ptr; @@ -153,7 +153,7 @@ int slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr, data.size = pmi_size; data.port = port; data.hostname = hostname; - slurm_init_slurm_msg(&msg_send, NULL); + slurm_msg_t_init(&msg_send); msg_send.address = srun_addr; msg_send.msg_type = PMI_KVS_GET_REQ; msg_send.data = &data; diff --git a/src/api/step_launch.c b/src/api/step_launch.c index a7d9e193786..2d0f831c451 100644 --- a/src/api/step_launch.c +++ b/src/api/step_launch.c @@ -515,7 +515,7 @@ static int _message_socket_accept(eio_obj_t *obj, List objs) fflush(stdout); msg = xmalloc(sizeof(slurm_msg_t)); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); /* multiple jobs (easily induced via no_alloc) and highly * parallel jobs using PMI sometimes result in slow message @@ -722,6 +722,7 @@ static int _launch_tasks(slurm_step_ctx ctx, int timeout; debug("Entering _launch_tasks"); + slurm_msg_t_init(&msg); msg.msg_type = REQUEST_LAUNCH_TASKS; msg.data = launch_msg; buffer = slurm_pack_msg_no_header(&msg); diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 0022ce81c31..ab1ac4d1b62 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -741,14 +741,13 @@ List slurm_receive_msg(slurm_fd fd, slurm_msg_t *msg, int timeout) int rc; void *auth_cred = NULL; Buf buffer; - /* int count = 0; */ ret_types_t *ret_type = NULL; -/* ListIterator itr; */ - List ret_list = list_create(destroy_ret_types); - slurm_init_slurm_msg(msg, NULL); xassert(fd >= 0); + + slurm_msg_t_init(msg); + msg->conn_fd = fd; if (timeout == 0) timeout = slurm_get_msg_timeout(); @@ -1459,7 +1458,14 @@ int slurm_send_recv_controller_msg(slurm_msg_t *req, slurm_msg_t *resp) bool backup_controller_flag; uint16_t slurmctld_timeout; - slurm_init_slurm_msg(req, NULL); + /* Just in case the caller didn't initialize his slurm_msg_t, and + * since we KNOW that we are only sending to one node (the controller), + * we initialize some forwarding variables to disable forwarding. + */ + forward_init(&req->forward, NULL); + req->ret_list = NULL; + req->forward_struct_init = 0; + req->forward_struct = NULL; if ((fd = slurm_open_controller_conn()) < 0) { rc = -1; @@ -1790,7 +1796,14 @@ int slurm_send_recv_rc_msg_only_one(slurm_msg_t *req, int *rc, int timeout) ret_types_t *ret_type = NULL; int ret_c = 0; - slurm_init_slurm_msg(req, NULL); + /* Just in case the caller didn't initialize his slurm_msg_t, and + * since we KNOW that we are only sending to one node, + * we initialize some forwarding variables to disable forwarding. + */ + forward_init(&req->forward, NULL); + req->ret_list = NULL; + req->forward_struct_init = 0; + req->forward_struct = NULL; if ((fd = slurm_open_msg_conn(&req->address)) < 0) { return -1; @@ -1828,7 +1841,14 @@ int slurm_send_recv_controller_rc_msg(slurm_msg_t *req, int *rc) ret_types_t *ret_type = NULL; int ret_val = 0; - slurm_init_slurm_msg(req, NULL); + /* Just in case the caller didn't initialize his slurm_msg_t, and + * since we KNOW that we are only sending to one node (the controller), + * we initialize some forwarding variables to disable forwarding. + */ + forward_init(&req->forward, NULL); + req->ret_list = NULL; + req->forward_struct_init = 0; + req->forward_struct = NULL; if ((fd = slurm_open_controller_conn()) < 0) return -1; diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index 67bb29d6cc4..9c6f7e873f4 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -72,29 +72,42 @@ static void _free_all_step_info (job_step_info_response_msg_t *msg); static void _slurm_free_job_step_info_members (job_step_info_t * msg); /* - * slurm_init_slurm_msg - initialize slurm message - * OUT msg - user defined slurm message - * IN in_msg - NULL if fresh initialization, or already initialized message to - * initialize from. (Usually for reponse messages send in - * the request message) + * slurm_msg_t_init - initialize a slurm message + * OUT msg - pointer to the slurm_msg_t structure which will be initialized */ -void slurm_init_slurm_msg (slurm_msg_t * msg, slurm_msg_t * in_msg) -{ - if(in_msg) { - msg->forward = in_msg->forward; - msg->ret_list = msg->ret_list; - msg->forward_struct_init = msg->forward_struct_init; - msg->forward_struct = msg->forward_struct; - } else { - forward_init(&msg->forward, NULL); - msg->ret_list = NULL; - msg->forward_struct_init = 0; - msg->forward_struct = NULL; - } - msg->orig_addr.sin_addr.s_addr = 0; +extern void slurm_msg_t_init (slurm_msg_t *msg) +{ + memset(msg, 0, sizeof(slurm_msg_t)); + + msg->msg_type = (slurm_msg_type_t)NO_VAL; + msg->conn_fd = -1; + + forward_init(&msg->forward, NULL); + return; } +/* + * slurm_msg_t_copy - initialize a slurm_msg_t structure "dest" with + * values from the "src" slurm_msg_t structure. + * IN src - Pointer to the initialized message from which "dest" will + * be initialized. + * OUT dest - Pointer to the slurm_msg_t which will be intialized. + * NOTE: the "dest" structure will contain pointers into the contents of "src". + */ +extern void slurm_msg_t_copy(slurm_msg_t *dest, slurm_msg_t *src) +{ + memset(dest, 0, sizeof(slurm_msg_t)); + + dest->forward = src->forward; + dest->ret_list = src->ret_list; + dest->forward_struct_init = src->forward_struct_init; + dest->forward_struct = src->forward_struct; + dest->orig_addr.sin_addr.s_addr = 0; + return; +} + + void slurm_free_last_update_msg(last_update_msg_t * msg) { xfree(msg); diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 6385ff7bfa1..8ec23fdfe8c 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -638,13 +638,20 @@ typedef struct slurm_ctl_conf slurm_ctl_conf_info_msg_t; \*****************************************************************************/ /* - * slurm_init_slurm_msg - initialize slurm message - * OUT msg - user defined slurm message - * IN in_msg - NULL if fresh initialization, or already initialized message to - * initialize from. (Usually for reponse messages send in - * the request message) + * slurm_msg_t_init - initialize a slurm message + * OUT msg - pointer to the slurm_msg_t structure which will be initialized */ -extern void slurm_init_slurm_msg (slurm_msg_t * msg, slurm_msg_t * in_msg); +extern void slurm_msg_t_init (slurm_msg_t *msg); + +/* + * slurm_msg_t_copy - initialize a slurm_msg_t structure "dest" with + * values from the "src" slurm_msg_t structure. + * IN src - Pointer to the initialized message from which "dest" will + * be initialized. + * OUT dest - Pointer to the slurm_msg_t which will be intialized. + * NOTE: the "dest" structure will contain pointers into the contents of "src". + */ +extern void slurm_msg_t_copy(slurm_msg_t *dest, slurm_msg_t *src); /* free message functions */ void inline slurm_free_last_update_msg(last_update_msg_t * msg); diff --git a/src/salloc/msg.c b/src/salloc/msg.c index 278e2c8e58d..04cea6a6aeb 100644 --- a/src/salloc/msg.c +++ b/src/salloc/msg.c @@ -179,7 +179,7 @@ static int _message_socket_accept(eio_obj_t *obj, List objs) fflush(stdout); msg = xmalloc(sizeof(slurm_msg_t)); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); msg->conn_fd = fd; timeout = slurm_get_msg_timeout(); diff --git a/src/sattach/sattach.c b/src/sattach/sattach.c index 8d891c990c4..9f36da7a3e1 100644 --- a/src/sattach/sattach.c +++ b/src/sattach/sattach.c @@ -217,7 +217,7 @@ static char *_node_list_remove_first(const char *nodes) #endif /* - * Take a NodeNode name list in hostlist_t string format, and expand + * Take a NodeName 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. * @@ -288,7 +288,7 @@ static int _attach_to_tasks(uint32_t jobid, uint16_t num_resp_port, uint16_t *resp_port) { - slurm_msg_t msg, dummy_resp_msg; + slurm_msg_t msg, first_node_resp; List ret_list = NULL; ListIterator ret_itr; ListIterator ret_data_itr; @@ -298,11 +298,8 @@ static int _attach_to_tasks(uint32_t jobid, reattach_tasks_request_msg_t reattach_msg; debug("Entering _attach_to_tasks"); - /* Lets make sure that the slurm_msg_t are zeroed out at the start */ - memset(&msg, 0, sizeof(slurm_msg_t)); - slurm_init_slurm_msg(&msg, NULL); - memset(&dummy_resp_msg, 0, sizeof(slurm_msg_t)); - slurm_init_slurm_msg(&dummy_resp_msg, NULL); + slurm_msg_t_init(&msg); + slurm_msg_t_init(&first_node_resp); timeout = slurm_get_msg_timeout(); @@ -320,15 +317,13 @@ 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 = _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 */ memcpy(&msg.address, layout->node_addr + 0, sizeof(slurm_addr)); - ret_list = slurm_send_recv_node_msg(&msg, &dummy_resp_msg, timeout); + ret_list = slurm_send_recv_node_msg(&msg, &first_node_resp, timeout); if (ret_list == NULL) { error("slurm_send_recv_node_msg failed: %m"); xfree(msg.forward.node_id); @@ -338,7 +333,7 @@ static int _attach_to_tasks(uint32_t jobid, ret_itr = list_iterator_create(ret_list); while ((ret = list_next(ret_itr)) != NULL) { - debug("launch returned msg_rc=%d err=%d type=%d", + debug("Attach returned msg_rc=%d err=%d type=%d", ret->msg_rc, ret->err, ret->type); if (ret->msg_rc != SLURM_SUCCESS) { ret_data_itr = @@ -479,7 +474,7 @@ static int _message_socket_accept(eio_obj_t *obj, List objs) fflush(stdout); msg = xmalloc(sizeof(slurm_msg_t)); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); /* multiple jobs (easily induced via no_alloc) and highly * parallel jobs using PMI sometimes result in slow message diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c index e8b431d4b3a..11d8a9b707a 100644 --- a/src/slurmctld/agent.c +++ b/src/slurmctld/agent.c @@ -759,6 +759,7 @@ static void *_thread_per_group_rpc(void *args) int found = 0; forward_msg_t fwd_msg; + #if AGENT_IS_THREAD /* Locks: Write job, write node */ slurmctld_lock_t job_write_lock = { @@ -814,10 +815,10 @@ static void *_thread_per_group_rpc(void *args) slurm_mutex_unlock(thread_mutex_ptr); /* send request message */ + slurm_msg_t_init(&msg); msg.address = thread_ptr->slurm_addr; msg.msg_type = msg_type; msg.data = task_ptr->msg_args_ptr; - slurm_init_slurm_msg(&msg, NULL); forward_init(&msg.forward, &thread_ptr->forward); //info("%s forwarding to %d",thread_ptr->node_name, msg.forward.cnt); diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index ac39d36fe87..fa95c1733a5 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -622,8 +622,8 @@ static void *_service_connection(void *arg) List ret_list = NULL; slurm_msg_t *msg = xmalloc(sizeof(slurm_msg_t)); - msg->conn_fd = newsockfd; ret_list = slurm_receive_msg(newsockfd, msg, 0); + msg->conn_fd = newsockfd; if(!ret_list) { error("slurm_receive_msg: %m"); /* close should only be called when the socket implementation is diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 7c2d3cd93c2..43e9187dfa7 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -4234,10 +4234,10 @@ extern int job_suspend(suspend_msg_t *sus_ptr, uid_t uid, jobacct_g_suspend_slurmctld(job_ptr); if (conn_fd >= 0) { - rc_msg.return_code = rc; + slurm_msg_t_init(&resp_msg); resp_msg.msg_type = RESPONSE_SLURM_RC; + rc_msg.return_code = rc; resp_msg.data = &rc_msg; - slurm_init_slurm_msg(&resp_msg, NULL); slurm_send_node_msg(conn_fd, &resp_msg); } return rc; @@ -4326,10 +4326,10 @@ extern int job_requeue (uid_t uid, uint32_t job_id, slurm_fd conn_fd) //FIXME: Test accounting reply: - rc_msg.return_code = rc; + slurm_msg_t_init(&resp_msg); resp_msg.msg_type = RESPONSE_SLURM_RC; + rc_msg.return_code = rc; resp_msg.data = &rc_msg; - slurm_init_slurm_msg(&resp_msg, NULL); slurm_send_node_msg(conn_fd, &resp_msg); return rc; } diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c index 41ac90ea8f6..a490b70a7b6 100644 --- a/src/slurmctld/proc_req.c +++ b/src/slurmctld/proc_req.c @@ -523,9 +523,9 @@ static void _slurm_rpc_allocate_resources(slurm_msg_t * msg) select_g_copy_jobinfo(job_ptr->select_jobinfo); unlock_slurmctld(job_write_lock); + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_RESOURCE_ALLOCATION; response_msg.data = &alloc_msg; - slurm_init_slurm_msg(&response_msg, NULL); if (slurm_send_node_msg(msg->conn_fd, &response_msg) < 0) _kill_job_on_msg_fail(job_ptr->job_id); @@ -571,10 +571,10 @@ static void _slurm_rpc_dump_conf(slurm_msg_t * msg) debug2("_slurm_rpc_dump_conf %s", TIME_STR); /* init response_msg structure */ + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_BUILD_INFO; response_msg.data = &config_tbl; - slurm_init_slurm_msg(&response_msg, NULL); /* send message */ slurm_send_node_msg(msg->conn_fd, &response_msg); @@ -613,11 +613,11 @@ static void _slurm_rpc_dump_jobs(slurm_msg_t * msg) dump_size, TIME_STR); /* init response_msg structure */ + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_JOB_INFO; response_msg.data = dump; response_msg.data_size = dump_size; - slurm_init_slurm_msg(&response_msg, NULL); /* send message */ slurm_send_node_msg(msg->conn_fd, &response_msg); @@ -648,10 +648,10 @@ static void _slurm_rpc_end_time(slurm_msg_t * msg) if (rc != SLURM_SUCCESS) { slurm_send_rc_msg(msg, rc); } else { + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = SRUN_TIMEOUT; response_msg.data = &timeout_msg; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); } debug2("_slurm_rpc_end_time jobid=%u %s", @@ -688,11 +688,11 @@ static void _slurm_rpc_dump_nodes(slurm_msg_t * msg) dump_size, TIME_STR); /* init response_msg structure */ + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_NODE_INFO; response_msg.data = dump; response_msg.data_size = dump_size; - slurm_init_slurm_msg(&response_msg, NULL); /* send message */ slurm_send_node_msg(msg->conn_fd, &response_msg); @@ -729,11 +729,11 @@ static void _slurm_rpc_dump_partitions(slurm_msg_t * msg) dump_size, TIME_STR); /* init response_msg structure */ + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_PARTITION_INFO; response_msg.data = dump; response_msg.data_size = dump_size; - slurm_init_slurm_msg(&response_msg, NULL); /* send message */ slurm_send_node_msg(msg->conn_fd, &response_msg); @@ -1057,10 +1057,10 @@ static void _slurm_rpc_job_step_create(slurm_msg_t * msg) step_rec->switch_job); unlock_slurmctld(job_write_lock); + slurm_msg_t_init(&resp); resp.address = msg->address; resp.msg_type = RESPONSE_JOB_STEP_CREATE; resp.data = &job_step_resp; - slurm_init_slurm_msg(&resp, NULL); slurm_send_node_msg(msg->conn_fd, &resp); slurm_step_layout_destroy(job_step_resp.step_layout); @@ -1120,11 +1120,11 @@ static void _slurm_rpc_job_step_get_info(slurm_msg_t * msg) else { slurm_msg_t response_msg; + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_JOB_STEP_INFO; response_msg.data = resp_buffer; response_msg.data_size = resp_buffer_size; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); xfree(resp_buffer); } @@ -1299,9 +1299,9 @@ static void _slurm_rpc_job_alloc_info(slurm_msg_t * msg) select_g_copy_jobinfo(job_ptr->select_jobinfo); unlock_slurmctld(job_read_lock); + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_JOB_ALLOCATION_INFO; response_msg.data = &job_info_resp_msg; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); select_g_free_jobinfo(&job_info_resp_msg.select_jobinfo); @@ -1370,9 +1370,9 @@ static void _slurm_rpc_job_alloc_info_lite(slurm_msg_t * msg) select_g_copy_jobinfo(job_ptr->select_jobinfo); unlock_slurmctld(job_read_lock); + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_JOB_ALLOCATION_INFO_LITE; response_msg.data = &job_info_resp_msg; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); select_g_free_jobinfo(&job_info_resp_msg.select_jobinfo); @@ -1672,9 +1672,9 @@ static void _slurm_rpc_step_layout(slurm_msg_t *msg) step_layout = slurm_step_layout_copy(step_ptr->step_layout); unlock_slurmctld(job_read_lock); + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_STEP_LAYOUT; response_msg.data = step_layout; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); slurm_step_layout_destroy(step_layout); @@ -1737,9 +1737,9 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg) submit_msg.job_id = job_desc_msg->job_id; submit_msg.step_id = step_id; submit_msg.error_code = error_code; + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_SUBMIT_BATCH_JOB; - slurm_init_slurm_msg(&response_msg, NULL); response_msg.data = &submit_msg; slurm_send_node_msg(msg->conn_fd, @@ -1771,9 +1771,9 @@ static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg) submit_msg.job_id = job_ptr->job_id; submit_msg.step_id = SLURM_BATCH_SCRIPT; submit_msg.error_code = error_code; + slurm_msg_t_init(&response_msg); response_msg.msg_type = RESPONSE_SUBMIT_BATCH_JOB; response_msg.data = &submit_msg; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); schedule(); /* has own locks */ schedule_job_save(); /* has own locks */ @@ -2036,11 +2036,11 @@ static void _slurm_rpc_job_ready(slurm_msg_t * msg) } else { debug2("_slurm_rpc_job_ready(%u)=%d %s", id_msg->job_id, result, TIME_STR); - rc_msg.return_code = result; + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_JOB_READY; + rc_msg.return_code = result; response_msg.data = &rc_msg; - slurm_init_slurm_msg(&response_msg, NULL); slurm_send_node_msg(msg->conn_fd, &response_msg); } } @@ -2066,11 +2066,11 @@ static void _slurm_rpc_node_select_info(slurm_msg_t * msg) slurm_send_rc_msg(msg, error_code); } else { /* init response_msg structure */ + slurm_msg_t_init(&response_msg); response_msg.address = msg->address; response_msg.msg_type = RESPONSE_NODE_SELECT_INFO; response_msg.data = get_buf_data(buffer); response_msg.data_size = get_buf_offset(buffer); - slurm_init_slurm_msg(&response_msg, NULL); /* send message */ slurm_send_node_msg(msg->conn_fd, &response_msg); diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c index 68a52168197..209eda61134 100644 --- a/src/slurmctld/step_mgr.c +++ b/src/slurmctld/step_mgr.c @@ -1003,7 +1003,7 @@ extern int job_step_checkpoint(checkpoint_msg_t *ckpt_ptr, checkpoint_resp_msg_t resp_data; slurm_msg_t resp_msg; - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&resp_msg); /* find the job */ job_ptr = find_job_record (ckpt_ptr->job_id); @@ -1096,7 +1096,7 @@ extern int job_step_checkpoint_comp(checkpoint_comp_msg_t *ckpt_ptr, slurm_msg_t resp_msg; return_code_msg_t rc_msg; - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&resp_msg); /* find the job */ job_ptr = find_job_record (ckpt_ptr->job_id); diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c index f1162a75ebb..c14abdc2903 100644 --- a/src/slurmd/slurmd/req.c +++ b/src/slurmd/slurmd/req.c @@ -943,7 +943,7 @@ _abort_job(uint32_t job_id) { complete_batch_script_msg_t resp; slurm_msg_t resp_msg; - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&resp_msg); resp.job_id = job_id; resp.job_rc = 1; @@ -1194,7 +1194,7 @@ _rpc_stat_jobacct(slurm_msg_t *msg) } } resp = xmalloc(sizeof(stat_jobacct_msg_t)); - slurm_init_slurm_msg(&resp_msg, msg); + slurm_msg_t_copy(&resp_msg, msg); resp->job_id = req->job_id; resp->step_id = req->step_id; resp->return_code = SLURM_SUCCESS; @@ -1278,7 +1278,7 @@ static void _rpc_pid2jid(slurm_msg_t *msg) continue; if (stepd_pid_in_container(fd, req->job_pid) || req->job_pid == stepd_daemon_pid(fd)) { - slurm_init_slurm_msg(&resp_msg, msg); + slurm_msg_t_copy(&resp_msg, msg); resp.job_id = stepd->jobid; resp.return_code = SLURM_SUCCESS; found = true; @@ -1420,8 +1420,7 @@ _rpc_reattach_tasks(slurm_msg_t *msg) slurm_addr *cli = &msg->orig_addr; uint32_t nodeid = (uint32_t)NO_VAL; - memset(&resp_msg, 0, sizeof(slurm_msg_t)); - slurm_init_slurm_msg(&resp_msg, msg); + slurm_msg_t_copy(&resp_msg, msg); fd = stepd_connect(conf->spooldir, conf->node_name, req->job_id, req->job_step_id); if (fd == -1) { @@ -1751,7 +1750,7 @@ _epilog_complete(uint32_t jobid, int rc) slurm_msg_t msg; epilog_complete_msg_t req; - slurm_init_slurm_msg(&msg, NULL); + slurm_msg_t_init(&msg); _wait_state_completed(jobid, 5); diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c index 4f48e1dc1b3..b168547ad22 100644 --- a/src/slurmd/slurmd/slurmd.c +++ b/src/slurmd/slurmd/slurmd.c @@ -362,7 +362,7 @@ _service_connection(void *arg) slurm_msg_t *msg = xmalloc(sizeof(slurm_msg_t)); debug3("in the service_connection"); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); msg->conn_fd = con->fd; /* this could change if being forwarded to */ memcpy(&msg->orig_addr, con->cli_addr, sizeof(slurm_addr)); @@ -404,8 +404,8 @@ send_registration_msg(uint32_t status, bool startup) slurm_node_registration_status_msg_t *msg = xmalloc (sizeof (slurm_node_registration_status_msg_t)); - slurm_init_slurm_msg(&req, NULL); - slurm_init_slurm_msg(&resp, NULL); + slurm_msg_t_init(&req); + slurm_msg_t_init(&resp); msg->startup = (uint16_t) startup; _fill_registration_msg(msg); diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index 50febfc2c2a..acf4b2a7672 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -441,10 +441,10 @@ _send_exit_msg(slurmd_job_t *job, uint32_t *tid, int n, int status) msg.task_id_list = tid; msg.num_tasks = n; msg.return_code = status; + slurm_msg_t_init(&resp); resp.data = &msg; resp.msg_type = MESSAGE_TASK_EXIT; resp.srun_node_id = job->nodeid; - slurm_init_slurm_msg(&resp, NULL); /* @@ -1332,11 +1332,11 @@ _send_launch_failure (launch_tasks_request_msg_t *msg, slurm_addr *cli, int rc) debug ("sending launch failure message: %s", slurm_strerror (rc)); + slurm_msg_t_init(&resp_msg); memcpy(&resp_msg.address, cli, sizeof(slurm_addr)); slurm_set_addr(&resp_msg.address, msg->resp_port[msg->srun_node_id % msg->num_resp_port], NULL); - slurm_init_slurm_msg(&resp_msg, NULL); resp_msg.data = &resp; resp_msg.msg_type = RESPONSE_LAUNCH_TASKS; @@ -1363,7 +1363,7 @@ _send_launch_resp(slurmd_job_t *job, int rc) debug("Sending launch resp rc=%d", rc); - slurm_init_slurm_msg(&resp_msg, NULL); + slurm_msg_t_init(&resp_msg); resp_msg.address = srun->resp_addr; resp_msg.data = &resp; resp_msg.msg_type = RESPONSE_LAUNCH_TASKS; @@ -1398,7 +1398,7 @@ _complete_batch_script(slurmd_job_t *job, int err, int status) req.job_rc = status; req.slurm_rc = err; - slurm_init_slurm_msg(&req_msg, NULL); + slurm_msg_t_init(&req_msg); req.node_name = conf->node_name; req_msg.msg_type= REQUEST_COMPLETE_BATCH_SCRIPT; req_msg.data = &req; diff --git a/src/srun/allocate.c b/src/srun/allocate.c index eb500b5a229..98fcdfc33fd 100644 --- a/src/srun/allocate.c +++ b/src/srun/allocate.c @@ -274,7 +274,7 @@ _accept_msg_connection(slurm_fd slurmctld_fd, debug2("got message connection from %s:%d", host, port); msg = xmalloc(sizeof(slurm_msg_t)); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); msg->conn_fd = fd; again: diff --git a/src/srun/launch.c b/src/srun/launch.c index f888a600f4a..6f8c518ae36 100644 --- a/src/srun/launch.c +++ b/src/srun/launch.c @@ -217,7 +217,7 @@ launch(void *arg) free(host); m = &msg_array_ptr[job->thr_count]; - slurm_init_slurm_msg(m, NULL); + slurm_msg_t_init(m); m->srun_node_id = (uint32_t)i; m->msg_type = REQUEST_LAUNCH_TASKS; diff --git a/src/srun/msg.c b/src/srun/msg.c index 087e79f7009..e1811aeb9cd 100644 --- a/src/srun/msg.c +++ b/src/srun/msg.c @@ -913,7 +913,7 @@ _accept_msg_connection(srun_job_t *job, int fdnum) uc[0], uc[1], uc[2], uc[3], ntohs(port)); msg = xmalloc(sizeof(slurm_msg_t)); - slurm_init_slurm_msg(msg, NULL); + slurm_msg_t_init(msg); msg->conn_fd = fd; /* multiple jobs (easily induced via no_alloc) and highly diff --git a/src/srun/reattach.c b/src/srun/reattach.c index cba3b0c41ca..1c31d80e2c4 100644 --- a/src/srun/reattach.c +++ b/src/srun/reattach.c @@ -339,9 +339,9 @@ _attach_to_job(srun_job_t *job) r->resp_port = (uint16_t *)xmalloc(sizeof(uint16_t)); r->resp_port[0] = ntohs(job->jaddr[i%job->njfds].sin_port); r->cred = job->cred; + slurm_msg_t_init(m); m->data = r; m->msg_type = REQUEST_REATTACH_TASKS; - slurm_init_slurm_msg(m, NULL); memcpy(&m->address, &job->step_layout->node_addr[i], sizeof(slurm_addr)); -- GitLab