static void _destroy_persist_service(persist_service_conn_t *persist_service) { if (persist_service) { slurm_persist_conn_destroy(persist_service->conn); xfree(persist_service); } }
static int _close_controller_conn(slurmdb_cluster_rec_t *cluster) { int rc = SLURM_SUCCESS; // slurm_persist_conn_t *persist_conn = NULL; xassert(cluster); slurm_mutex_lock(&cluster->lock); if (slurmctld_conf.debug_flags & DEBUG_FLAG_FEDR) info("closing sibling conn to %s", cluster->name); /* The recv free of this is handled directly in the persist_conn code, * don't free it here */ // slurm_persist_conn_destroy(cluster->fed.recv); cluster->fed.recv = NULL; slurm_persist_conn_destroy(cluster->fed.send); cluster->fed.send = NULL; if (slurmctld_conf.debug_flags & DEBUG_FLAG_FEDR) info("closed sibling conn to %s", cluster->name); slurm_mutex_unlock(&cluster->lock); return rc; }
/* Close the SlurmDBD socket connection */ extern int close_slurmdbd_conn(void) { /* NOTE: agent_lock not needed for _shutdown_agent() */ _shutdown_agent(); /* * Only send the FINI message if we haven't shutdown * (i.e. not slurmctld) */ if (!slurmdbd_shutdown) { if (_send_fini_msg() != SLURM_SUCCESS) error("slurmdbd: Sending fini msg: %m"); else debug("slurmdbd: Sent fini msg"); } slurm_mutex_lock(&slurmdbd_lock); slurm_persist_conn_destroy(slurmdbd_conn); slurmdbd_conn = NULL; xfree(slurmdbd_cluster); slurm_mutex_unlock(&slurmdbd_lock); return SLURM_SUCCESS; }
extern slurmdb_federation_rec_t *fed_mgr_state_load(char *state_save_location) { Buf buffer = NULL; char *data = NULL, *state_file; time_t buf_time; uint16_t ver = 0; uint32_t data_size = 0; int state_fd; int data_allocated, data_read = 0, error_code = SLURM_SUCCESS; slurmdb_federation_rec_t *ret_fed = NULL; state_file = xstrdup_printf("%s/%s", state_save_location, FED_MGR_STATE_FILE); state_fd = open(state_file, O_RDONLY); if (state_fd < 0) { error("No fed_mgr state file (%s) to recover", state_file); xfree(state_file); return NULL; } else { data_allocated = BUF_SIZE; data = xmalloc(data_allocated); while (1) { data_read = read(state_fd, &data[data_size], BUF_SIZE); if (data_read < 0) { if (errno == EINTR) continue; else { error("Read error on %s: %m", state_file); break; } } else if (data_read == 0) /* eof */ break; data_size += data_read; data_allocated += data_read; xrealloc(data, data_allocated); } close(state_fd); } xfree(state_file); buffer = create_buf(data, data_size); safe_unpack16(&ver, buffer); debug3("Version in fed_mgr_state header is %u", ver); if (ver > SLURM_PROTOCOL_VERSION || ver < SLURM_MIN_PROTOCOL_VERSION) { error("***********************************************"); error("Can not recover fed_mgr state, incompatible version, " "got %u need > %u <= %u", ver, SLURM_MIN_PROTOCOL_VERSION, SLURM_PROTOCOL_VERSION); error("***********************************************"); free_buf(buffer); return NULL; } safe_unpack_time(&buf_time, buffer); error_code = slurmdb_unpack_federation_rec((void **)&ret_fed, ver, buffer); if (error_code != SLURM_SUCCESS) goto unpack_error; else if (!ret_fed || !ret_fed->name || !list_count(ret_fed->cluster_list)) { slurmdb_destroy_federation_rec(ret_fed); ret_fed = NULL; error("No feds retrieved"); } else { /* We want to free the connections here since they don't exist * anymore, but they were packed when state was saved. */ slurmdb_cluster_rec_t *cluster; ListIterator itr = list_iterator_create( ret_fed->cluster_list); while ((cluster = list_next(itr))) { slurm_persist_conn_destroy(cluster->fed.recv); cluster->fed.recv = NULL; slurm_persist_conn_destroy(cluster->fed.send); cluster->fed.send = NULL; } list_iterator_destroy(itr); } free_buf(buffer); return ret_fed; unpack_error: free_buf(buffer); return NULL; }