/* Process incoming RPCs. Meant to execute as a pthread */ extern void *rpc_mgr(void *no_data) { int sockfd, newsockfd; int i; uint16_t port; slurm_addr_t cli_addr; slurmdbd_conn_t *conn_arg = NULL; master_thread_id = pthread_self(); /* initialize port for RPCs */ if ((sockfd = slurm_init_msg_engine_port(get_dbd_port())) == SLURM_SOCKET_ERROR) fatal("slurm_init_msg_engine_port error %m"); slurm_persist_conn_recv_server_init(); /* * Process incoming RPCs until told to shutdown */ while (!shutdown_time && (i = slurm_persist_conn_wait_for_thread_loc()) >= 0) { /* * accept needed for stream implementation is a no-op in * message implementation that just passes sockfd to newsockfd */ if ((newsockfd = slurm_accept_msg_conn(sockfd, &cli_addr)) == SLURM_SOCKET_ERROR) { slurm_persist_conn_free_thread_loc(i); if (errno != EINTR) error("slurm_accept_msg_conn: %m"); continue; } fd_set_nonblocking(newsockfd); conn_arg = xmalloc(sizeof(slurmdbd_conn_t)); conn_arg->conn = xmalloc(sizeof(slurm_persist_conn_t)); conn_arg->conn->fd = newsockfd; conn_arg->conn->flags = PERSIST_FLAG_DBD; conn_arg->conn->callback_proc = proc_req; conn_arg->conn->callback_fini = _connection_fini_callback; conn_arg->conn->shutdown = &shutdown_time; conn_arg->conn->version = SLURM_MIN_PROTOCOL_VERSION; conn_arg->conn->rem_host = xmalloc_nz(sizeof(char) * 16); /* Don't fill in the rem_port here. It will be filled in * later if it is a slurmctld connection. */ slurm_get_ip_str(&cli_addr, &port, conn_arg->conn->rem_host, sizeof(char) * 16); slurm_persist_conn_recv_thread_init( conn_arg->conn, i, conn_arg); } debug("rpc_mgr shutting down"); (void) slurm_shutdown_msg_engine(sockfd); pthread_exit((void *) 0); return NULL; }
extern int fed_mgr_init(void *db_conn) { int rc = SLURM_SUCCESS; slurmdb_federation_cond_t fed_cond; List fed_list; slurmdb_federation_rec_t *fed = NULL; slurm_mutex_lock(&init_mutex); if (inited) { slurm_mutex_unlock(&init_mutex); return SLURM_SUCCESS; } if (!association_based_accounting) goto end_it; slurm_persist_conn_recv_server_init(); if (running_cache) { debug("Database appears down, reading federations from state file."); fed = fed_mgr_state_load( slurmctld_conf.state_save_location); if (!fed) { debug2("No federation state"); rc = SLURM_SUCCESS; goto end_it; } } else { slurmdb_init_federation_cond(&fed_cond, 0); fed_cond.cluster_list = list_create(NULL); list_append(fed_cond.cluster_list, slurmctld_cluster_name); fed_list = acct_storage_g_get_federations(db_conn, getuid(), &fed_cond); FREE_NULL_LIST(fed_cond.cluster_list); if (!fed_list) { error("failed to get a federation list"); rc = SLURM_ERROR; goto end_it; } if (list_count(fed_list) == 1) fed = list_pop(fed_list); else if (list_count(fed_list) > 1) { error("got more federations than expected"); rc = SLURM_ERROR; } FREE_NULL_LIST(fed_list); } if (fed) { slurmdb_cluster_rec_t *cluster = NULL; if ((cluster = list_find_first(fed->cluster_list, slurmdb_find_cluster_in_list, slurmctld_cluster_name))) { _join_federation(fed, cluster, false); } else { error("failed to get cluster from federation that we requested"); rc = SLURM_ERROR; } } end_it: inited = true; slurm_mutex_unlock(&init_mutex); return rc; }