extern void msg_aggr_resp(slurm_msg_t *msg) { slurm_msg_t *next_msg; composite_msg_t *comp_msg; msg_aggr_t *msg_aggr; ListIterator itr; comp_msg = (composite_msg_t *)msg->data; itr = list_iterator_create(comp_msg->msg_list); if (msg_collection.debug_flags & DEBUG_FLAG_ROUTE) info("msg_aggr_resp: processing composite msg_list..."); while ((next_msg = list_next(itr))) { switch (next_msg->msg_type) { case RESPONSE_SLURM_RC: /* signal sending thread that slurmctld received this * epilog complete msg */ if (msg_collection.debug_flags & DEBUG_FLAG_ROUTE) info("msg_aggr_resp: rc message found for " "index %u signaling sending thread", next_msg->msg_index); slurm_mutex_lock(&msg_collection.aggr_mutex); if (!(msg_aggr = _handle_msg_aggr_ret( next_msg->msg_index, 1))) { debug2("msg_aggr_resp: error: unable to " "locate aggr message struct for job %u", next_msg->msg_index); slurm_mutex_unlock(&msg_collection.aggr_mutex); continue; } pthread_cond_signal(&msg_aggr->wait_cond); slurm_mutex_unlock(&msg_collection.aggr_mutex); break; case RESPONSE_MESSAGE_COMPOSITE: comp_msg = (composite_msg_t *)next_msg->data; /* set up the address here for the next node */ memcpy(&next_msg->address, &comp_msg->sender, sizeof(slurm_addr_t)); if (msg_collection.debug_flags & DEBUG_FLAG_ROUTE) { char addrbuf[100]; slurm_print_slurm_addr(&next_msg->address, addrbuf, 32); info("msg_aggr_resp: composite response msg " "found for %s", addrbuf); } slurm_send_only_node_msg(next_msg); break; default: error("_rpc_composite_resp: invalid msg type in " "composite msg_list"); break; } } list_iterator_destroy(itr); if (msg_collection.debug_flags & DEBUG_FLAG_ROUTE) info("msg aggr: _rpc_composite_resp: finished processing " "composite msg_list..."); }
extern void msg_aggr_add_msg(slurm_msg_t *msg, bool wait) { int count; static uint16_t msg_index = 1; if (!msg_collection.running) return; slurm_mutex_lock(&msg_collection.mutex); if (msg_collection.max_msgs == true) { pthread_cond_wait(&msg_collection.cond, &msg_collection.mutex); } msg->msg_index = msg_index++; /* Add msg to message collection */ list_append(msg_collection.msg_list, msg); count = list_count(msg_collection.msg_list); /* First msg in collection; initiate new window */ if (count == 1) pthread_cond_signal(&msg_collection.cond); /* Max msgs reached; terminate window */ if (count >= msg_collection.max_msg_cnt) { msg_collection.max_msgs = true; pthread_cond_signal(&msg_collection.cond); } slurm_mutex_unlock(&msg_collection.mutex); if (wait) { msg_aggr_t *msg_aggr = xmalloc(sizeof(msg_aggr_t)); uint16_t msg_timeout; struct timeval now; struct timespec timeout; msg_aggr->msg_index = msg->msg_index; pthread_cond_init(&msg_aggr->wait_cond, NULL); slurm_mutex_lock(&msg_collection.aggr_mutex); list_append(msg_collection.msg_aggr_list, msg_aggr); msg_timeout = slurm_get_msg_timeout(); gettimeofday(&now, NULL); timeout.tv_sec = now.tv_sec + msg_timeout; timeout.tv_nsec = now.tv_usec * 1000; if (pthread_cond_timedwait(&msg_aggr->wait_cond, &msg_collection.aggr_mutex, &timeout) == ETIMEDOUT) _handle_msg_aggr_ret(msg_aggr->msg_index, 1); slurm_mutex_unlock(&msg_collection.aggr_mutex); _msg_aggr_free(msg_aggr); } }
extern void msg_aggr_sender_fini(void) { if (!msg_collection.running) return; msg_collection.running = 0; slurm_mutex_lock(&msg_collection.mutex); slurm_cond_signal(&msg_collection.cond); slurm_mutex_unlock(&msg_collection.mutex); pthread_join(msg_collection.thread_id, NULL); msg_collection.thread_id = (pthread_t) 0; slurm_cond_destroy(&msg_collection.cond); /* signal and clear the waiting list */ slurm_mutex_lock(&msg_collection.aggr_mutex); _handle_msg_aggr_ret(0, 1); FREE_NULL_LIST(msg_collection.msg_aggr_list); slurm_mutex_unlock(&msg_collection.aggr_mutex); FREE_NULL_LIST(msg_collection.msg_list); slurm_mutex_destroy(&msg_collection.mutex); }