/* * gg_session_handler_search50() * * zajmuje siê obs³ug± wyniku przeszukiwania katalogu publicznego. * * - s - sesja * - e - opis zdarzenia */ void gg_session_handler_search50(session_t *s, struct gg_event *e) { gg_private_t *g = session_private_get(s); gg_pubdir50_t res = e->event.pubdir50; int i, count, all = 0; list_t l; uin_t last_uin = 0; if (!g) return; if ((count = gg_pubdir50_count(res)) < 1) { print("search_not_found"); return; } debug_function("gg_session_handler_search50() handle_search50, count = %d\n", gg_pubdir50_count(res)); for (l = g->searches; l; l = l->next) { gg_pubdir50_t req = l->data; if (gg_pubdir50_seq(req) == gg_pubdir50_seq(res)) { all = 1; break; } } for (i = 0; i < count; i++) { const char *uin = gg_pubdir50_get(res, i, "fmnumber"); const char *__firstname = gg_pubdir50_get(res, i, "firstname"); const char *__lastname = gg_pubdir50_get(res, i, "lastname"); const char *__nickname = gg_pubdir50_get(res, i, "nickname"); const char *__fmstatus = gg_pubdir50_get(res, i, "fmstatus"); const char *__birthyear = gg_pubdir50_get(res, i, "birthyear"); const char *__city = gg_pubdir50_get(res, i, "city"); char *firstname = gg_to_core_dup(s, __firstname); char *lastname = gg_to_core_dup(s, __lastname); char *nickname = gg_to_core_dup(s, __nickname); char *city = gg_to_core_dup(s, __city); int status = (__fmstatus) ? atoi(__fmstatus) : GG_STATUS_NOT_AVAIL; const char *birthyear = (__birthyear && xstrcmp(__birthyear, "0")) ? __birthyear : NULL; char *name, *active, *gender; const char *target = NULL; if (count == 1 && !all) { xfree(last_search_first_name); xfree(last_search_last_name); xfree(last_search_nickname); xfree(last_search_uid); last_search_first_name = xstrdup(firstname); last_search_last_name = xstrdup(lastname); last_search_nickname = xstrdup(nickname); last_search_uid = saprintf("gg:%s", uin); } name = saprintf( ("%s %s"), firstname ? firstname : (""), lastname ? lastname : ("")); #define __format(x) ((count == 1 && !all) ? "search_results_single" x : "search_results_multi" x) { const char *fvalue; switch (status) { case GG_STATUS_AVAIL: case GG_STATUS_AVAIL_DESCR: fvalue = format_find(__format("_avail")); break; case GG_STATUS_BUSY: case GG_STATUS_BUSY_DESCR: fvalue = format_find(__format("_away")); break; default: fvalue = format_find(__format("_notavail")); } active = format_string(fvalue, (__firstname) ? __firstname : nickname); } gender = format_string(format_find(__format("_unknown")), ""); /* XXX: why do we _exactly_ use it here? can't we just always * define target and thus display result in right conversation window? */ for (l = autofinds; l; l = l->next) { char *d = (char *) l->data; if (!xstrcasecmp(d + 3, uin)) { target = d; break; } } print_info(target, s, __format(""), uin ? uin : ("?"), name, nickname ? nickname : (""), city ? city : (""), birthyear ? birthyear : ("-"), gender, active); #undef __format xfree(name); xfree(active); xfree(gender); xfree(firstname); xfree(lastname); xfree(nickname); xfree(city); last_uin = atoi(uin); } /* je¶li mieli¶my ,,/find --all'', szukamy dalej */ for (l = g->searches; l; l = l->next) { gg_pubdir50_t req = l->data; uin_t next; if (gg_pubdir50_seq(req) != gg_pubdir50_seq(res)) continue; /* nie ma dalszych? to dziêkujemy */ if (!(next = gg_pubdir50_next(res)) || !g->sess || next <= last_uin) { list_remove(&g->searches, req, 0); gg_pubdir50_free(req); break; } gg_pubdir50_add(req, GG_PUBDIR50_START, ekg_itoa(next)); gg_pubdir50(g->sess, req); break; } }
static List _create_bb_info_list(burst_buffer_info_msg_t *bb_info_ptr) { static List info_list = NULL; List last_list = NULL; ListIterator last_list_itr = NULL; int i, j, pos = 0; static burst_buffer_info_msg_t *last_bb_info_ptr = NULL; sview_bb_info_t *sview_bb_info_ptr = NULL; burst_buffer_info_t *bb_ptr; burst_buffer_resv_t *bb_resv_ptr = NULL; char bb_name_id[32] = ""; if (info_list && (bb_info_ptr == last_bb_info_ptr)) return info_list; last_bb_info_ptr = bb_info_ptr; if (info_list) last_list = info_list; info_list = list_create(_bb_info_list_del); for (i = 0, bb_ptr = bb_info_ptr->burst_buffer_array; i < bb_info_ptr->record_count; i++, bb_ptr++) { for (j = 0, bb_resv_ptr = bb_ptr->burst_buffer_resv_ptr; j < bb_ptr->buffer_count; j++, bb_resv_ptr++) { /* Find any existing record for this burst buffer */ if (last_list) { last_list_itr = list_iterator_create(last_list); while ((sview_bb_info_ptr = list_next(last_list_itr))) { if (bb_resv_ptr->job_id && (bb_resv_ptr->job_id != sview_bb_info_ptr->bb_ptr->job_id)) continue; if (bb_resv_ptr->name && xstrcmp(sview_bb_info_ptr->bb_name, bb_resv_ptr->name)) continue; if (xstrcmp(sview_bb_info_ptr->plugin, bb_ptr->name)) continue; list_remove(last_list_itr); _bb_info_free(sview_bb_info_ptr); break; } list_iterator_destroy(last_list_itr); } else { sview_bb_info_ptr = NULL; } if (bb_resv_ptr->name) { strlcpy(bb_name_id, bb_resv_ptr->name, sizeof(bb_name_id)); } else if (bb_resv_ptr->array_task_id == NO_VAL) { convert_num_unit(bb_resv_ptr->job_id, bb_name_id, sizeof(bb_name_id), UNIT_NONE, NO_VAL, working_sview_config. convert_flags); } else { snprintf(bb_name_id, sizeof(bb_name_id), "%u_%u(%u)", bb_resv_ptr->array_job_id, bb_resv_ptr->array_task_id, bb_resv_ptr->job_id); } if (!sview_bb_info_ptr) { /* Need new record */ sview_bb_info_ptr = xmalloc(sizeof(sview_bb_info_t)); } sview_bb_info_ptr->bb_ptr = bb_resv_ptr; sview_bb_info_ptr->bb_name = xstrdup(bb_name_id); strcpy(bb_name_id, ""); /* Clear bb_name_id */ sview_bb_info_ptr->color_inx = pos % sview_colors_cnt; sview_bb_info_ptr->plugin = xstrdup(bb_ptr->name); sview_bb_info_ptr->pos = pos++; list_append(info_list, sview_bb_info_ptr); } } FREE_NULL_LIST(last_list); return info_list; }
static COMMAND(xmsg_msg) { char fn[sizeof(XMSG_TMPFILE_PATH)]; int fd; char *msg = (char*) params[1]; const char *uid; int fs; int n; const char *msgcmd = session_get(session, "send_cmd"); char *msgx = NULL, *mymsg; if (!(uid = get_uid(session, target))) { printq("invalid_session"); return -1; } if (!msgcmd || *msgcmd == '\0') { printq("xmsg_nosendcmd", session_name(session)); return -1; } xstrcpy(fn, XMSG_TMPFILE_PATH); fd = mkstemp(fn); if (fd == -1) xerrn("Unable to create temp file"); { const char *charset = session_get(session, "charset"); if (charset) msgx = ekg_convert_string(msg, NULL, charset); mymsg = (msgx ? msgx : msg); } fs = xstrlen(mymsg); while (fs > 0) { if ((n = write(fd, mymsg, fs)) == -1) { unlink(fn); close(fd); xfree(msgx); xerrn("Unable to write message into temp file"); } fs -= n; mymsg += n; } xfree(msgx); close(fd); if ((command_exec_format(NULL, session, 1, "!^%s \"%s\" \"%s\"", msgcmd, target+XMSG_UID_DIROFFSET, fn))) xerr("msgcmd exec failed"); { char **rcpts = xcalloc(2, sizeof(char *)); int class = (xstrcmp(name, "chat") ? EKG_MSGCLASS_SENT : EKG_MSGCLASS_SENT_CHAT); rcpts[0] = xstrdup(uid); rcpts[1] = NULL; protocol_message_emit(session, session->uid, rcpts, params[1], NULL, time(NULL), class, NULL, EKG_NO_BEEP, 0); array_free(rcpts); } return 0; }
static int _sort_step_by_node_list(void *void1, void *void2) { int diff = 0; job_step_info_t *step1; job_step_info_t *step2; hostlist_t hostlist1, hostlist2; char *val1, *val2; char *ptr1, *ptr2; #if PURE_ALPHA_SORT == 0 int inx; #endif _get_step_info_from_void(&step1, &step2, void1, void2); hostlist1 = hostlist_create(step1->nodes); hostlist_sort(hostlist1); val1 = hostlist_shift(hostlist1); if (val1) ptr1 = val1; else ptr1 = ""; hostlist_destroy(hostlist1); hostlist2 = hostlist_create(step2->nodes); hostlist_sort(hostlist2); val2 = hostlist_shift(hostlist2); if (val2) ptr2 = val2; else ptr2 = ""; hostlist_destroy(hostlist2); #if PURE_ALPHA_SORT diff = xstrcmp(ptr1, ptr2); #else for (inx = 0; ; inx++) { if (ptr1[inx] == ptr2[inx]) { if (ptr1[inx] == '\0') break; continue; } if ((isdigit((int)ptr1[inx])) && (isdigit((int)ptr2[inx]))) { int num1, num2; num1 = atoi(ptr1 + inx); num2 = atoi(ptr2 + inx); diff = num1 - num2; } else diff = xstrcmp(ptr1, ptr2); break; } #endif if (val1) free(val1); if (val2) free(val2); if (reverse_order) diff = -diff; return diff; }
/* _background_rpc_mgr - Read and process incoming RPCs to the background * controller (that's us) */ static void *_background_rpc_mgr(void *no_data) { slurm_fd_t newsockfd; slurm_fd_t sockfd; slurm_addr_t cli_addr; slurm_msg_t *msg = NULL; int error_code; char* node_addr = NULL; /* Read configuration only */ slurmctld_lock_t config_read_lock = { READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK }; int sigarray[] = {SIGUSR1, 0}; (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); debug3("_background_rpc_mgr pid = %lu", (unsigned long) getpid()); /* initialize port for RPCs */ lock_slurmctld(config_read_lock); /* set node_addr to bind to (NULL means any) */ if ((xstrcmp(slurmctld_conf.backup_controller, slurmctld_conf.backup_addr) != 0)) { node_addr = slurmctld_conf.backup_addr ; } if ((sockfd = slurm_init_msg_engine_addrname_port(node_addr, slurmctld_conf. slurmctld_port)) == SLURM_SOCKET_ERROR) fatal("slurm_init_msg_engine_addrname_port error %m"); unlock_slurmctld(config_read_lock); /* Prepare to catch SIGUSR1 to interrupt accept(). * This signal is generated by the slurmctld signal * handler thread upon receipt of SIGABRT, SIGINT, * or SIGTERM. That thread does all processing of * all signals. */ xsignal(SIGUSR1, _sig_handler); xsignal_unblock(sigarray); /* * Process incoming RPCs indefinitely */ while (slurmctld_config.shutdown_time == 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) { if (errno != EINTR) error("slurm_accept_msg_conn: %m"); continue; } msg = xmalloc(sizeof(slurm_msg_t)); slurm_msg_t_init(msg); if (slurm_receive_msg(newsockfd, msg, 0) != 0) error("slurm_receive_msg: %m"); error_code = _background_process_msg(msg); if ((error_code == SLURM_SUCCESS) && (msg->msg_type == REQUEST_SHUTDOWN_IMMEDIATE) && (slurmctld_config.shutdown_time == 0)) slurmctld_config.shutdown_time = time(NULL); slurm_free_msg(msg); slurm_close(newsockfd); /* close new socket */ } debug3("_background_rpc_mgr shutting down"); slurm_close(sockfd); /* close the main socket */ pthread_exit((void *) 0); return NULL; }
/* * slurm_sprint_job_info - output information about a specific Slurm * job based upon message as loaded using slurm_load_jobs * IN job_ptr - an individual job information record pointer * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ extern char * slurm_sprint_job_info ( job_info_t * job_ptr, int one_liner ) { int i, j, k; char time_str[32], *group_name, *user_name; char *gres_last = "", tmp1[128], tmp2[128]; char *tmp6_ptr; char tmp_line[1024 * 128]; char tmp_path[MAXPATHLEN]; char *ionodes = NULL; uint16_t exit_status = 0, term_sig = 0; job_resources_t *job_resrcs = job_ptr->job_resrcs; char *out = NULL; time_t run_time; uint32_t min_nodes, max_nodes = 0; char *nodelist = "NodeList"; bitstr_t *cpu_bitmap; char *host; int sock_inx, sock_reps, last; int abs_node_inx, rel_node_inx; int64_t nice; int bit_inx, bit_reps; uint64_t *last_mem_alloc_ptr = NULL; uint64_t last_mem_alloc = NO_VAL64; char *last_hosts; hostlist_t hl, hl_last; char select_buf[122]; uint32_t cluster_flags = slurmdb_setup_cluster_flags(); uint32_t threads; char *line_end = (one_liner) ? " " : "\n "; if (cluster_flags & CLUSTER_FLAG_BG) { nodelist = "MidplaneList"; select_g_select_jobinfo_get(job_ptr->select_jobinfo, SELECT_JOBDATA_IONODES, &ionodes); } /****** Line 1 ******/ xstrfmtcat(out, "JobId=%u ", job_ptr->job_id); if (job_ptr->array_job_id) { if (job_ptr->array_task_str) { xstrfmtcat(out, "ArrayJobId=%u ArrayTaskId=%s ", job_ptr->array_job_id, job_ptr->array_task_str); } else { xstrfmtcat(out, "ArrayJobId=%u ArrayTaskId=%u ", job_ptr->array_job_id, job_ptr->array_task_id); } } xstrfmtcat(out, "JobName=%s", job_ptr->name); xstrcat(out, line_end); /****** Line 2 ******/ user_name = uid_to_string((uid_t) job_ptr->user_id); group_name = gid_to_string((gid_t) job_ptr->group_id); xstrfmtcat(out, "UserId=%s(%u) GroupId=%s(%u) MCS_label=%s", user_name, job_ptr->user_id, group_name, job_ptr->group_id, (job_ptr->mcs_label==NULL) ? "N/A" : job_ptr->mcs_label); xfree(user_name); xfree(group_name); xstrcat(out, line_end); /****** Line 3 ******/ nice = ((int64_t)job_ptr->nice) - NICE_OFFSET; xstrfmtcat(out, "Priority=%u Nice=%"PRIi64" Account=%s QOS=%s", job_ptr->priority, nice, job_ptr->account, job_ptr->qos); if (slurm_get_track_wckey()) xstrfmtcat(out, " WCKey=%s", job_ptr->wckey); xstrcat(out, line_end); /****** Line 4 ******/ xstrfmtcat(out, "JobState=%s ", job_state_string(job_ptr->job_state)); if (job_ptr->state_desc) { /* Replace white space with underscore for easier parsing */ for (j=0; job_ptr->state_desc[j]; j++) { if (isspace((int)job_ptr->state_desc[j])) job_ptr->state_desc[j] = '_'; } xstrfmtcat(out, "Reason=%s ", job_ptr->state_desc); } else xstrfmtcat(out, "Reason=%s ", job_reason_string(job_ptr->state_reason)); xstrfmtcat(out, "Dependency=%s", job_ptr->dependency); xstrcat(out, line_end); /****** Line 5 ******/ xstrfmtcat(out, "Requeue=%u Restarts=%u BatchFlag=%u Reboot=%u ", job_ptr->requeue, job_ptr->restart_cnt, job_ptr->batch_flag, job_ptr->reboot); if (WIFSIGNALED(job_ptr->exit_code)) term_sig = WTERMSIG(job_ptr->exit_code); exit_status = WEXITSTATUS(job_ptr->exit_code); xstrfmtcat(out, "ExitCode=%u:%u", exit_status, term_sig); xstrcat(out, line_end); /****** Line 5a (optional) ******/ if (job_ptr->show_flags & SHOW_DETAIL) { if (WIFSIGNALED(job_ptr->derived_ec)) term_sig = WTERMSIG(job_ptr->derived_ec); else term_sig = 0; exit_status = WEXITSTATUS(job_ptr->derived_ec); xstrfmtcat(out, "DerivedExitCode=%u:%u", exit_status, term_sig); xstrcat(out, line_end); } /****** Line 6 ******/ if (IS_JOB_PENDING(job_ptr)) run_time = 0; else if (IS_JOB_SUSPENDED(job_ptr)) run_time = job_ptr->pre_sus_time; else { time_t end_time; if (IS_JOB_RUNNING(job_ptr) || (job_ptr->end_time == 0)) end_time = time(NULL); else end_time = job_ptr->end_time; if (job_ptr->suspend_time) { run_time = (time_t) (difftime(end_time, job_ptr->suspend_time) + job_ptr->pre_sus_time); } else run_time = (time_t) difftime(end_time, job_ptr->start_time); } secs2time_str(run_time, time_str, sizeof(time_str)); xstrfmtcat(out, "RunTime=%s ", time_str); if (job_ptr->time_limit == NO_VAL) xstrcat(out, "TimeLimit=Partition_Limit "); else { mins2time_str(job_ptr->time_limit, time_str, sizeof(time_str)); xstrfmtcat(out, "TimeLimit=%s ", time_str); } if (job_ptr->time_min == 0) xstrcat(out, "TimeMin=N/A"); else { mins2time_str(job_ptr->time_min, time_str, sizeof(time_str)); xstrfmtcat(out, "TimeMin=%s", time_str); } xstrcat(out, line_end); /****** Line 7 ******/ slurm_make_time_str(&job_ptr->submit_time, time_str, sizeof(time_str)); xstrfmtcat(out, "SubmitTime=%s ", time_str); slurm_make_time_str(&job_ptr->eligible_time, time_str, sizeof(time_str)); xstrfmtcat(out, "EligibleTime=%s", time_str); xstrcat(out, line_end); /****** Line 8 (optional) ******/ if (job_ptr->resize_time) { slurm_make_time_str(&job_ptr->resize_time, time_str, sizeof(time_str)); xstrfmtcat(out, "ResizeTime=%s", time_str); xstrcat(out, line_end); } /****** Line 9 ******/ slurm_make_time_str(&job_ptr->start_time, time_str, sizeof(time_str)); xstrfmtcat(out, "StartTime=%s ", time_str); if ((job_ptr->time_limit == INFINITE) && (job_ptr->end_time > time(NULL))) xstrcat(out, "EndTime=Unknown "); else { slurm_make_time_str(&job_ptr->end_time, time_str, sizeof(time_str)); xstrfmtcat(out, "EndTime=%s ", time_str); } if (job_ptr->deadline) { slurm_make_time_str(&job_ptr->deadline, time_str, sizeof(time_str)); xstrfmtcat(out, "Deadline=%s", time_str); } else { xstrcat(out, "Deadline=N/A"); } xstrcat(out, line_end); /****** Line 10 ******/ if (job_ptr->preempt_time == 0) xstrcat(out, "PreemptTime=None "); else { slurm_make_time_str(&job_ptr->preempt_time, time_str, sizeof(time_str)); xstrfmtcat(out, "PreemptTime=%s ", time_str); } if (job_ptr->suspend_time) { slurm_make_time_str(&job_ptr->suspend_time, time_str, sizeof(time_str)); xstrfmtcat(out, "SuspendTime=%s ", time_str); } else xstrcat(out, "SuspendTime=None "); xstrfmtcat(out, "SecsPreSuspend=%ld", (long int)job_ptr->pre_sus_time); xstrcat(out, line_end); /****** Line 11 ******/ xstrfmtcat(out, "Partition=%s AllocNode:Sid=%s:%u", job_ptr->partition, job_ptr->alloc_node, job_ptr->alloc_sid); xstrcat(out, line_end); /****** Line 12 ******/ xstrfmtcat(out, "Req%s=%s Exc%s=%s", nodelist, job_ptr->req_nodes, nodelist, job_ptr->exc_nodes); xstrcat(out, line_end); /****** Line 13 ******/ xstrfmtcat(out, "%s=%s", nodelist, job_ptr->nodes); if (job_ptr->nodes && ionodes) { xstrfmtcat(out, "[%s]", ionodes); xfree(ionodes); } if (job_ptr->sched_nodes) xstrfmtcat(out, " Sched%s=%s", nodelist, job_ptr->sched_nodes); xstrcat(out, line_end); /****** Line 14 (optional) ******/ if (job_ptr->batch_host) { xstrfmtcat(out, "BatchHost=%s", job_ptr->batch_host); xstrcat(out, line_end); } /****** Line 14a (optional) ******/ if (job_ptr->fed_siblings) { xstrfmtcat(out, "FedOrigin=%s FedSiblings=%s", job_ptr->fed_origin_str, job_ptr->fed_siblings_str); xstrcat(out, line_end); } /****** Line 15 ******/ if (cluster_flags & CLUSTER_FLAG_BG) { select_g_select_jobinfo_get(job_ptr->select_jobinfo, SELECT_JOBDATA_NODE_CNT, &min_nodes); if ((min_nodes == 0) || (min_nodes == NO_VAL)) { min_nodes = job_ptr->num_nodes; max_nodes = job_ptr->max_nodes; } else if (job_ptr->max_nodes) max_nodes = min_nodes; } else if (IS_JOB_PENDING(job_ptr)) { min_nodes = job_ptr->num_nodes; max_nodes = job_ptr->max_nodes; if (max_nodes && (max_nodes < min_nodes)) min_nodes = max_nodes; } else { min_nodes = job_ptr->num_nodes; max_nodes = 0; } _sprint_range(tmp_line, sizeof(tmp_line), min_nodes, max_nodes); xstrfmtcat(out, "NumNodes=%s ", tmp_line); _sprint_range(tmp_line, sizeof(tmp_line), job_ptr->num_cpus, job_ptr->max_cpus); xstrfmtcat(out, "NumCPUs=%s ", tmp_line); xstrfmtcat(out, "NumTasks=%u ", job_ptr->num_tasks); xstrfmtcat(out, "CPUs/Task=%u ", job_ptr->cpus_per_task); if (job_ptr->boards_per_node == (uint16_t) NO_VAL) xstrcat(out, "ReqB:S:C:T=*:"); else xstrfmtcat(out, "ReqB:S:C:T=%u:", job_ptr->boards_per_node); if (job_ptr->sockets_per_board == (uint16_t) NO_VAL) xstrcat(out, "*:"); else xstrfmtcat(out, "%u:", job_ptr->sockets_per_board); if (job_ptr->cores_per_socket == (uint16_t) NO_VAL) xstrcat(out, "*:"); else xstrfmtcat(out, "%u:", job_ptr->cores_per_socket); if (job_ptr->threads_per_core == (uint16_t) NO_VAL) xstrcat(out, "*"); else xstrfmtcat(out, "%u", job_ptr->threads_per_core); xstrcat(out, line_end); /****** Line 16 ******/ /* Tres should already of been converted at this point from simple */ xstrfmtcat(out, "TRES=%s", job_ptr->tres_alloc_str ? job_ptr->tres_alloc_str : job_ptr->tres_req_str); xstrcat(out, line_end); /****** Line 17 ******/ if (job_ptr->sockets_per_node == (uint16_t) NO_VAL) xstrcat(out, "Socks/Node=* "); else xstrfmtcat(out, "Socks/Node=%u ", job_ptr->sockets_per_node); if (job_ptr->ntasks_per_node == (uint16_t) NO_VAL) xstrcat(out, "NtasksPerN:B:S:C=*:"); else xstrfmtcat(out, "NtasksPerN:B:S:C=%u:", job_ptr->ntasks_per_node); if (job_ptr->ntasks_per_board == (uint16_t) NO_VAL) xstrcat(out, "*:"); else xstrfmtcat(out, "%u:", job_ptr->ntasks_per_board); if ((job_ptr->ntasks_per_socket == (uint16_t) NO_VAL) || (job_ptr->ntasks_per_socket == (uint16_t) INFINITE)) xstrcat(out, "*:"); else xstrfmtcat(out, "%u:", job_ptr->ntasks_per_socket); if ((job_ptr->ntasks_per_core == (uint16_t) NO_VAL) || (job_ptr->ntasks_per_core == (uint16_t) INFINITE)) xstrcat(out, "* "); else xstrfmtcat(out, "%u ", job_ptr->ntasks_per_core); if (job_ptr->core_spec == (uint16_t) NO_VAL) xstrcat(out, "CoreSpec=*"); else if (job_ptr->core_spec & CORE_SPEC_THREAD) xstrfmtcat(out, "ThreadSpec=%d", (job_ptr->core_spec & (~CORE_SPEC_THREAD))); else xstrfmtcat(out, "CoreSpec=%u", job_ptr->core_spec); xstrcat(out, line_end); if (job_resrcs && cluster_flags & CLUSTER_FLAG_BG) { if ((job_resrcs->cpu_array_cnt > 0) && (job_resrcs->cpu_array_value) && (job_resrcs->cpu_array_reps)) { int length = 0; xstrcat(out, "CPUs="); for (i = 0; i < job_resrcs->cpu_array_cnt; i++) { /* only print 60 characters worth of this record */ if (length > 60) { /* skip to last CPU group entry */ if (i < job_resrcs->cpu_array_cnt - 1) { continue; } /* add ellipsis before last entry */ xstrcat(out, "...,"); } length += xstrfmtcat(out, "%d", job_resrcs->cpus[i]); if (job_resrcs->cpu_array_reps[i] > 1) { length += xstrfmtcat(out, "*%d", job_resrcs->cpu_array_reps[i]); } if (i < job_resrcs->cpu_array_cnt - 1) { xstrcat(out, ","); length++; } } xstrcat(out, line_end); } } else if (job_resrcs && job_resrcs->core_bitmap && ((last = bit_fls(job_resrcs->core_bitmap)) != -1)) { hl = hostlist_create(job_resrcs->nodes); if (!hl) { error("slurm_sprint_job_info: hostlist_create: %s", job_resrcs->nodes); return NULL; } hl_last = hostlist_create(NULL); if (!hl_last) { error("slurm_sprint_job_info: hostlist_create: NULL"); hostlist_destroy(hl); return NULL; } bit_inx = 0; i = sock_inx = sock_reps = 0; abs_node_inx = job_ptr->node_inx[i]; gres_last = ""; /* tmp1[] stores the current cpu(s) allocated */ tmp2[0] = '\0'; /* stores last cpu(s) allocated */ for (rel_node_inx=0; rel_node_inx < job_resrcs->nhosts; rel_node_inx++) { if (sock_reps >= job_resrcs->sock_core_rep_count[sock_inx]) { sock_inx++; sock_reps = 0; } sock_reps++; bit_reps = job_resrcs->sockets_per_node[sock_inx] * job_resrcs->cores_per_socket[sock_inx]; host = hostlist_shift(hl); threads = _threads_per_core(host); cpu_bitmap = bit_alloc(bit_reps * threads); for (j = 0; j < bit_reps; j++) { if (bit_test(job_resrcs->core_bitmap, bit_inx)){ for (k = 0; k < threads; k++) bit_set(cpu_bitmap, (j * threads) + k); } bit_inx++; } bit_fmt(tmp1, sizeof(tmp1), cpu_bitmap); FREE_NULL_BITMAP(cpu_bitmap); /* * If the allocation values for this host are not the * same as the last host, print the report of the last * group of hosts that had identical allocation values. */ if (xstrcmp(tmp1, tmp2) || ((rel_node_inx < job_ptr->gres_detail_cnt) && xstrcmp(job_ptr->gres_detail_str[rel_node_inx], gres_last)) || (last_mem_alloc_ptr != job_resrcs->memory_allocated) || (job_resrcs->memory_allocated && (last_mem_alloc != job_resrcs->memory_allocated[rel_node_inx]))) { if (hostlist_count(hl_last)) { last_hosts = hostlist_ranged_string_xmalloc( hl_last); xstrfmtcat(out, " Nodes=%s CPU_IDs=%s " "Mem=%"PRIu64" GRES_IDX=%s", last_hosts, tmp2, last_mem_alloc_ptr ? last_mem_alloc : 0, gres_last); xfree(last_hosts); xstrcat(out, line_end); hostlist_destroy(hl_last); hl_last = hostlist_create(NULL); } strcpy(tmp2, tmp1); if (rel_node_inx < job_ptr->gres_detail_cnt) { gres_last = job_ptr-> gres_detail_str[rel_node_inx]; } else { gres_last = ""; } last_mem_alloc_ptr = job_resrcs->memory_allocated; if (last_mem_alloc_ptr) last_mem_alloc = job_resrcs-> memory_allocated[rel_node_inx]; else last_mem_alloc = NO_VAL64; } hostlist_push_host(hl_last, host); free(host); if (bit_inx > last) break; if (abs_node_inx > job_ptr->node_inx[i+1]) { i += 2; abs_node_inx = job_ptr->node_inx[i]; } else { abs_node_inx++; } } if (hostlist_count(hl_last)) { last_hosts = hostlist_ranged_string_xmalloc(hl_last); xstrfmtcat(out, " Nodes=%s CPU_IDs=%s Mem=%"PRIu64" GRES_IDX=%s", last_hosts, tmp2, last_mem_alloc_ptr ? last_mem_alloc : 0, gres_last); xfree(last_hosts); xstrcat(out, line_end); } hostlist_destroy(hl); hostlist_destroy(hl_last); } /****** Line 18 ******/ if (job_ptr->pn_min_memory & MEM_PER_CPU) { job_ptr->pn_min_memory &= (~MEM_PER_CPU); tmp6_ptr = "CPU"; } else tmp6_ptr = "Node"; if (cluster_flags & CLUSTER_FLAG_BG) { convert_num_unit((float)job_ptr->pn_min_cpus, tmp1, sizeof(tmp1), UNIT_NONE, NO_VAL, CONVERT_NUM_UNIT_EXACT); xstrfmtcat(out, "MinCPUsNode=%s ", tmp1); } else { xstrfmtcat(out, "MinCPUsNode=%u ", job_ptr->pn_min_cpus); } convert_num_unit((float)job_ptr->pn_min_memory, tmp1, sizeof(tmp1), UNIT_MEGA, NO_VAL, CONVERT_NUM_UNIT_EXACT); convert_num_unit((float)job_ptr->pn_min_tmp_disk, tmp2, sizeof(tmp2), UNIT_MEGA, NO_VAL, CONVERT_NUM_UNIT_EXACT); xstrfmtcat(out, "MinMemory%s=%s MinTmpDiskNode=%s", tmp6_ptr, tmp1, tmp2); xstrcat(out, line_end); /****** Line ******/ secs2time_str((time_t)job_ptr->delay_boot, tmp1, sizeof(tmp1)); xstrfmtcat(out, "Features=%s DelayBoot=%s", job_ptr->features, tmp1); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "Gres=%s Reservation=%s", job_ptr->gres, job_ptr->resv_name); xstrcat(out, line_end); /****** Line 20 ******/ xstrfmtcat(out, "OverSubscribe=%s Contiguous=%d Licenses=%s Network=%s", job_share_string(job_ptr->shared), job_ptr->contiguous, job_ptr->licenses, job_ptr->network); xstrcat(out, line_end); /****** Line 21 ******/ xstrfmtcat(out, "Command=%s", job_ptr->command); xstrcat(out, line_end); /****** Line 22 ******/ xstrfmtcat(out, "WorkDir=%s", job_ptr->work_dir); if (cluster_flags & CLUSTER_FLAG_BG) { /****** Line 23 (optional) ******/ select_g_select_jobinfo_sprint(job_ptr->select_jobinfo, select_buf, sizeof(select_buf), SELECT_PRINT_BG_ID); if (select_buf[0] != '\0') { xstrcat(out, line_end); xstrfmtcat(out, "Block_ID=%s", select_buf); } /****** Line 24 (optional) ******/ select_g_select_jobinfo_sprint(job_ptr->select_jobinfo, select_buf, sizeof(select_buf), SELECT_PRINT_MIXED_SHORT); if (select_buf[0] != '\0') { xstrcat(out, line_end); xstrcat(out, select_buf); } /****** Line 26 (optional) ******/ select_g_select_jobinfo_sprint(job_ptr->select_jobinfo, select_buf, sizeof(select_buf), SELECT_PRINT_LINUX_IMAGE); if (select_buf[0] != '\0') { xstrcat(out, line_end); xstrfmtcat(out, "CnloadImage=%s", select_buf); } /****** Line 27 (optional) ******/ select_g_select_jobinfo_sprint(job_ptr->select_jobinfo, select_buf, sizeof(select_buf), SELECT_PRINT_MLOADER_IMAGE); if (select_buf[0] != '\0') { xstrcat(out, line_end); xstrfmtcat(out, "MloaderImage=%s", select_buf); } /****** Line 28 (optional) ******/ select_g_select_jobinfo_sprint(job_ptr->select_jobinfo, select_buf, sizeof(select_buf), SELECT_PRINT_RAMDISK_IMAGE); if (select_buf[0] != '\0') { xstrcat(out, line_end); xstrfmtcat(out, "IoloadImage=%s", select_buf); } } /****** Line (optional) ******/ if (job_ptr->admin_comment) { xstrcat(out, line_end); xstrfmtcat(out, "AdminComment=%s ", job_ptr->admin_comment); } /****** Line (optional) ******/ if (job_ptr->comment) { xstrcat(out, line_end); xstrfmtcat(out, "Comment=%s ", job_ptr->comment); } /****** Line 30 (optional) ******/ if (job_ptr->batch_flag) { xstrcat(out, line_end); slurm_get_job_stderr(tmp_path, sizeof(tmp_path), job_ptr); xstrfmtcat(out, "StdErr=%s", tmp_path); } /****** Line 31 (optional) ******/ if (job_ptr->batch_flag) { xstrcat(out, line_end); slurm_get_job_stdin(tmp_path, sizeof(tmp_path), job_ptr); xstrfmtcat(out, "StdIn=%s", tmp_path); } /****** Line 32 (optional) ******/ if (job_ptr->batch_flag) { xstrcat(out, line_end); slurm_get_job_stdout(tmp_path, sizeof(tmp_path), job_ptr); xstrfmtcat(out, "StdOut=%s", tmp_path); } /****** Line 33 (optional) ******/ if (job_ptr->batch_script) { xstrcat(out, line_end); xstrcat(out, "BatchScript=\n"); xstrcat(out, job_ptr->batch_script); } /****** Line 34 (optional) ******/ if (job_ptr->req_switch) { char time_buf[32]; xstrcat(out, line_end); secs2time_str((time_t) job_ptr->wait4switch, time_buf, sizeof(time_buf)); xstrfmtcat(out, "Switches=%u@%s\n", job_ptr->req_switch, time_buf); } /****** Line 35 (optional) ******/ if (job_ptr->burst_buffer) { xstrcat(out, line_end); xstrfmtcat(out, "BurstBuffer=%s", job_ptr->burst_buffer); } /****** Line (optional) ******/ if (job_ptr->burst_buffer_state) { xstrcat(out, line_end); xstrfmtcat(out, "BurstBufferState=%s", job_ptr->burst_buffer_state); } /****** Line 36 (optional) ******/ if (cpu_freq_debug(NULL, NULL, tmp1, sizeof(tmp1), job_ptr->cpu_freq_gov, job_ptr->cpu_freq_min, job_ptr->cpu_freq_max, NO_VAL) != 0) { xstrcat(out, line_end); xstrcat(out, tmp1); } /****** Line 37 ******/ xstrcat(out, line_end); xstrfmtcat(out, "Power=%s", power_flags_str(job_ptr->power_flags)); /****** Line 38 (optional) ******/ if (job_ptr->bitflags) { xstrcat(out, line_end); if (job_ptr->bitflags & GRES_ENFORCE_BIND) xstrcat(out, "GresEnforceBind=Yes"); if (job_ptr->bitflags & KILL_INV_DEP) xstrcat(out, "KillOInInvalidDependent=Yes"); if (job_ptr->bitflags & NO_KILL_INV_DEP) xstrcat(out, "KillOInInvalidDependent=No"); if (job_ptr->bitflags & SPREAD_JOB) xstrcat(out, "SpreadJob=Yes"); } /****** END OF JOB RECORD ******/ if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); return out; }
extern void launch_common_set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds, slurm_opt_t *opt_local) { srun_opt_t *srun_opt = opt_local->srun_opt; bool err_shares_out = false; int file_flags; xassert(srun_opt); if (srun_opt->open_mode == OPEN_MODE_APPEND) file_flags = O_CREAT|O_WRONLY|O_APPEND; else if (srun_opt->open_mode == OPEN_MODE_TRUNCATE) file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC; else { slurm_ctl_conf_t *conf; conf = slurm_conf_lock(); if (conf->job_file_append) file_flags = O_CREAT|O_WRONLY|O_APPEND; else file_flags = O_CREAT|O_WRONLY|O_APPEND|O_TRUNC; slurm_conf_unlock(); } /* * create stdin file descriptor */ if (_is_local_file(job->ifname)) { if ((job->ifname->name == NULL) || (job->ifname->taskid != -1)) { cio_fds->input.fd = STDIN_FILENO; } else { cio_fds->input.fd = open(job->ifname->name, O_RDONLY); if (cio_fds->input.fd == -1) { error("Could not open stdin file: %m"); exit(error_exit); } } if (job->ifname->type == IO_ONE) { cio_fds->input.taskid = job->ifname->taskid; cio_fds->input.nodeid = slurm_step_layout_host_id( launch_common_get_slurm_step_layout(job), job->ifname->taskid); } } /* * create stdout file descriptor */ if (_is_local_file(job->ofname)) { if ((job->ofname->name == NULL) || (job->ofname->taskid != -1)) { cio_fds->out.fd = STDOUT_FILENO; } else { cio_fds->out.fd = open(job->ofname->name, file_flags, 0644); if (cio_fds->out.fd == -1) { error("Could not open stdout file: %m"); exit(error_exit); } } if (job->ofname->name != NULL && job->efname->name != NULL && !xstrcmp(job->ofname->name, job->efname->name)) { err_shares_out = true; } } /* * create seperate stderr file descriptor only if stderr is not sharing * the stdout file descriptor */ if (err_shares_out) { debug3("stdout and stderr sharing a file"); cio_fds->err.fd = cio_fds->out.fd; cio_fds->err.taskid = cio_fds->out.taskid; } else if (_is_local_file(job->efname)) { if ((job->efname->name == NULL) || (job->efname->taskid != -1)) { cio_fds->err.fd = STDERR_FILENO; } else { cio_fds->err.fd = open(job->efname->name, file_flags, 0644); if (cio_fds->err.fd == -1) { error("Could not open stderr file: %m"); exit(error_exit); } } } }
static void load_usual_group(const xmlNode *group, form_element_t *parent) { const xmlNode *p = find_by_path(group, "Properties/Group")->children; int grouping = xstrcmp(p->content, "Horizontal") == 0 ? GROUPING_HORIZONTAL : GROUPING_VERTICAL ; bool show_title = true; p = find_by_path(group, "Properties/ShowTitle"); if (xstrcmp(children_content(p), "false") == 0) show_title = false; const xmlChar *title = entry_title_ex(group, false); int repr = REPRESENTATION_NONE; p = find_by_path(group, "Properties/Representation"); const xmlChar *s = children_content(p); if (xstrcmp(s, "StrongSeparation") == 0) repr = REPRESENTATION_STRONG; form_element_t G; G.widget = grouping == GROUPING_HORIZONTAL ? gtk_hbox_new(false, repr == REPRESENTATION_STRONG ? 2 : 0) : gtk_vbox_new(false, repr == REPRESENTATION_STRONG ? 2 : 0) ; G.box = true; p = find_by_path(group, "ContainedItems"); if (p) { int count_table; const xmlNode *cur_node = p->children; while (cur_node) { count_table = 0; if (grouping == GROUPING_VERTICAL) { const xmlNode *n = cur_node; while (n) { if (is_oftype(n, "Text") || is_oftype(n, "Input")) { ++count_table; n = n->next; while (n && n->type != XML_ELEMENT_NODE) n = n->next; if (!n) break; } else break; } } if ((count_table > 1) && (grouping == GROUPING_VERTICAL)) { form_element_t T; T.widget = gtk_table_new(count_table, 2, false); T.table_index = 0; container_add(&G, T.widget); while (count_table--) { if (is_oftype(cur_node, "Text") || is_oftype(cur_node, "Input")) { load_text_entry(cur_node, &T, true); ++T.table_index; } cur_node = cur_node->next; while (cur_node && cur_node->type != XML_ELEMENT_NODE) cur_node = cur_node->next; } } else { load_form_element(cur_node, &G); cur_node = cur_node->next; } } } if (repr == REPRESENTATION_STRONG) { GtkWidget *widget = gtk_frame_new(""); if (show_title) gtk_frame_set_label(GTK_FRAME(widget), GTK_CHAR(title)); gtk_container_add(GTK_CONTAINER(widget), G.widget); container_add(parent, widget); } else container_add(parent, G.widget); }
static void load_text_entry(const xmlNode *text, form_element_t *parent, bool in_table) { bool is_edit = true; const xmlNode *p; p = find_by_path(text, "Properties/Type"); if (p) if (xstrcmp(children_content(p), "LabelField") == 0) is_edit = false; const xmlChar *label = entry_title_ex(text, is_edit); p = find_by_path(text, "Properties/TitleLocation"); int title_loc = TITLE_LOCATION_LEFT; { const xmlChar *xc_title_loc = children_content(p); if (xc_title_loc) { if (xstrcmp(xc_title_loc, "None") == 0) title_loc = TITLE_LOCATION_NONE; if (xstrcmp(xc_title_loc, "Right") == 0) title_loc = TITLE_LOCATION_RIGHT; } } form_element_t E; E.box = false; if (label && title_loc != TITLE_LOCATION_NONE) { E.widget = gtk_hbox_new(false, 0); GtkWidget *w_label = gtk_label_new(GTK_CHAR(label)); GtkWidget *w_edit = is_edit ? gtk_entry_new() : gtk_label_new("...") ; p = find_by_path(text, "Properties/HeaderHorizontalAlign"); if (p) justify_element(w_label, p); if (!is_edit) { p = find_by_path(text, "Properties/HorizontalAlign"); if (p) justify_element(w_edit, p); } if (in_table) { gtk_table_attach(GTK_TABLE(parent->widget), w_label, 0, 1, parent->table_index + 1, parent->table_index + 2, GTK_FILL, 0, 0, 0 ); gtk_table_attach(GTK_TABLE(parent->widget), w_edit, 1, 2, parent->table_index + 1, parent->table_index + 2, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); } else { if (title_loc == TITLE_LOCATION_LEFT) gtk_box_pack_start(GTK_BOX(E.widget), w_label, false, false, 0); gtk_box_pack_start(GTK_BOX(E.widget), w_edit, true, true, 0); if (title_loc == TITLE_LOCATION_RIGHT) gtk_box_pack_start(GTK_BOX(E.widget), w_label, false, false, 0); container_add(parent, E.widget); } } else { if (is_edit) E.widget = gtk_entry_new(); else { E.widget = gtk_label_new(GTK_CHAR(label)); p = find_by_path(text, "Properties/HorizontalAlign"); if (p) justify_element(E.widget, p); } if (in_table) { gtk_table_attach(GTK_TABLE(parent->widget), E.widget, 1, 2, parent->table_index + 1, parent->table_index + 2, GTK_EXPAND | GTK_FILL, 0, 0, 0 ); } else { container_add(parent, E.widget); } } }
/* _read_lustre_counters() * Read counters from all mounted lustre fs * from the file stats under the directories: * * /proc/fs/lustre/llite/lustre-xxxx * * From the file stat we use 2 entries: * * read_bytes 17996 samples [bytes] 0 4194304 30994606834 * write_bytes 9007 samples [bytes] 2 4194304 31008331389 * */ static int _read_lustre_counters(void) { char lustre_dir[PATH_MAX]; DIR *proc_dir; struct dirent *entry; FILE *fff; char buffer[BUFSIZ]; snprintf(lustre_dir, PATH_MAX, "%s/llite", proc_base_path); proc_dir = opendir(lustre_dir); if (proc_dir == NULL) { error("%s: Cannot open %s %m", __func__, lustre_dir); return SLURM_ERROR; } while ((entry = readdir(proc_dir))) { char *path_stats = NULL; bool bread; bool bwrote; if (xstrcmp(entry->d_name, ".") == 0 || xstrcmp(entry->d_name, "..") == 0) continue; xstrfmtcat(path_stats, "%s/%s/stats", lustre_dir, entry->d_name); debug3("%s: Found file %s", __func__, path_stats); fff = fopen(path_stats, "r"); if (fff == NULL) { error("%s: Cannot open %s %m", __func__, path_stats); xfree(path_stats); continue; } xfree(path_stats); bread = bwrote = false; while (fgets(buffer, BUFSIZ, fff)) { if (bread && bwrote) break; if (strstr(buffer, "write_bytes")) { sscanf(buffer, "%*s %"PRIu64" %*s %*s " "%*d %*d %"PRIu64"", &lustre_se.lustre_nb_writes, &lustre_se.lustre_write_bytes); debug3("%s " "%"PRIu64" " "write_bytes %"PRIu64" " "writes", __func__, lustre_se.lustre_write_bytes, lustre_se.lustre_nb_writes); bwrote = true; } if (strstr(buffer, "read_bytes")) { sscanf(buffer, "%*s %"PRIu64" %*s %*s " "%*d %*d %"PRIu64"", &lustre_se.lustre_nb_reads, &lustre_se.lustre_read_bytes); debug3("%s " "%"PRIu64" " "read_bytes %"PRIu64" " "reads", __func__, lustre_se.lustre_read_bytes, lustre_se.lustre_nb_reads); bread = true; } } fclose(fff); lustre_se.all_lustre_write_bytes += lustre_se.lustre_write_bytes; lustre_se.all_lustre_read_bytes += lustre_se.lustre_read_bytes; lustre_se.all_lustre_nb_writes += lustre_se.lustre_nb_writes; lustre_se.all_lustre_nb_reads += lustre_se.lustre_nb_reads; debug3("%s: all_lustre_write_bytes %"PRIu64" " "all_lustre_read_bytes %"PRIu64"", __func__, lustre_se.all_lustre_write_bytes, lustre_se.all_lustre_read_bytes); debug3("%s: all_lustre_nb_writes %"PRIu64" " "all_lustre_nb_reads %"PRIu64"", __func__, lustre_se.all_lustre_nb_writes, lustre_se.all_lustre_nb_reads); } /* while ((entry = readdir(proc_dir))) */ closedir(proc_dir); lustre_se.last_update_time = lustre_se.update_time; lustre_se.update_time = time(NULL); return SLURM_SUCCESS; }
int irc_parse_line(session_t *s, const char *l) { static GString *strbuf = NULL; irc_private_t *j = s->priv; int i, c=0, ecode, n_params; char *p, *cmd, *colon2, **args = NULL, **pfxcmd = NULL; gchar *buf; int len; if (G_UNLIKELY(!strbuf)) strbuf = g_string_new(l); else g_string_assign(strbuf, l); irc_convert_in(j, strbuf); buf = strbuf->str; len = strbuf->len; query_emit(NULL, "irc-parse-line", &s->uid, &buf); p=buf; if(!p) return -1; /* Each IRC message may consist of up to three main parts: the prefix (optional), the command, and the command parameters (of which there may be up to 15). The prefix, command, and all parameters are separated by one (or more) ASCII space character(s) (0x20). The presence of a prefix is indicated with a single leading ASCII colon character (':', 0x3b), which must be the first character of the message itself. There must be no gap (whitespace) between the colon and the prefix. */ /* GiM: In fact this is probably not needed, but just in case... */ for (i=0; i<len; i++) if (buf[i]=='\n' || buf[i]=='\r') buf[i]='\0'; if ((colon2=xstrstr(p, " :"))) *colon2 = '\0'; args = array_make(OMITCOLON(p), " ", 0, 1, 0); if (colon2) { *colon2 = ' '; array_add(&args, xstrdup(colon2+2)); } #define prefix pfxcmd[0] #define pfx_nick pfxcmd[1] #define pfx_ihost pfxcmd[2] #define cmdname pfxcmd[3] /* prefix is optional... */ if (':' != *buf) { array_add(&pfxcmd, g_strdup("")); // prefix array_add(&pfxcmd, g_strdup("")); // pfx_nick array_add(&pfxcmd, g_strdup("")); // pfx_ihost } else { array_add(&pfxcmd, array_shift(&args)); // prefix p = xstrchr(pfxcmd[0], '!'); array_add(&pfxcmd, p ? g_strndup(pfxcmd[0], p-pfxcmd[0]) : g_strdup("")); // pfx_nick array_add(&pfxcmd, p ? g_strdup(p+1) : g_strdup("")); // pfx_ihost } cmd = array_shift(&args); array_add(&pfxcmd, cmd); // cmdname /* debug only nasty hack ;> */ #ifdef GDEBUG /* mg: well, it's not the exact data sent, but color is needed indeed */ i=0; if (*pfxcmd[0]) debug_iorecv("[%s]", pfxcmd[0]); debug_iorecv("[%s]", cmd); while (args[i] != NULL) debug_iorecv("[%s]",args[i++]); debug_iorecv("\n"); #endif n_params = g_strv_length(args); if (xstrlen(cmd) > 1) { if(!gatoi(cmd, &ecode)) { /* for scripts */ char *emitname = saprintf("irc-protocol-numeric %s", cmd); if ((query_emit(NULL, "irc-protocol-numeric", &s->uid, &ecode, &args) == -1) || (query_emit(NULL, emitname, &s->uid, &args) == -1)) { xfree(emitname); g_strfreev(pfxcmd); g_strfreev(args); return -1; } xfree(emitname); c=0; while(irccommands[c].type != -1) { if (irccommands[c].type == 1 && irccommands[c].num == ecode) { if (irccommands[c].min_params > n_params) { debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n", cmd, n_params, irccommands[c].min_params); } else /* I'm sending c not ecode!!!! */ if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) { debug_error("[irc] parse_line() error while executing handler!\n"); } /* GiM: XXX I don't expect more, * then one handler on list... */ break; } c++; } #ifdef GDEBUG if (irccommands[c].type == -1) { debug("trying default handler\n"); if ((*(irccommands[0].handler))(s, j, 0, pfxcmd, args) == -1 ) { debug("[irc] parse_line() error while executing handler!\n"); } } #endif } else { c=0; while(irccommands[c].type != -1) { if (irccommands[c].type == 0 && !xstrcmp(irccommands[c].comm, cmd)) { if (irccommands[c].min_params > n_params) { debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n", cmd, n_params, irccommands[c].min_params); } else /* dj: instead of ecode, c; */ if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) { debug_error("[irc] parse_line() error while executing handler!\n"); } break; } c++; } } } g_strfreev(pfxcmd); g_strfreev(args); return 0; }
int main() { LIST_STRU entries; LIST_STRU configs; char *configname = "simple-webmail.conf"; FILE *mail; char *dest,*name,*from,*subject,*content; char command[256]; html_header(); read_cgi_input(&entries); read_configs(&configs,configname); if( (is_field_empty(entries,"name")) && (is_field_empty(entries,"from")) && (is_field_empty(entries,"subject")) && (is_field_empty(entries,"content")) ) { printf("重新输入!"); } else { if (is_field_empty(entries,"to")) dest = strdup(TO); else dest = strdup(cgi_val(entries,"to")); if (!xstrcmp("*@*.*",dest)) { printf("收件人 %s 不是标准的邮件格式 *@*.*\n",dest); exit(-1); } name = strdup(cgi_val(entries,"name")); from = strdup(cgi_val(entries,"from")); subject = strdup(cgi_val(entries,"subject")); if (dest[0] == '\0') strcpy(dest,WEBADMIN); sprintf(command,"%s %s",SENDMAIL,dest); mail = popen(command,"w"); if (mail == NULL) { html_begin("系统出错!"); printf("系统出错!"); printf("请发信给 %s 。 \r\n",WEBADMIN); printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: "); printf("<i>%s</i>.\r\n",WEBADMIN); exit(-1); html_end(); } else { content = strdup(cgi_val(entries,"content")); fprintf(mail,"From: %s (%s)\n",from,name); fprintf(mail,"Subject: %s\n",subject); fprintf(mail,"To: %s\n",dest); fprintf(mail,"X-Sender: %s\n\n",WEBADMIN); if (REMOTE_ADDR != NULL) fprintf(mail,"发送者 IP 地址 %s\n",REMOTE_ADDR); // 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址 2003.08.17 if (HTTP_X_FORWARDED_FOR != NULL) fprintf(mail,"经过代理前IP地址 %s\n",HTTP_X_FORWARDED_FOR); if (HTTP_CLIENT_IP != NULL) fprintf(mail,"代理服务器地址 %s\n",HTTP_CLIENT_IP); fprintf(mail,"%s\n\n",content); pclose(mail); html_begin("邮件发送成功"); printf("邮件发送成功"); printf("你发送了以下的信息:\r\n<pre>\r\n"); printf("收信人: %s \r\n",dest); printf("发信人: %s (%s)\r\n",from,name); printf("标 题: %s\r\n\r\n",subject); printf("%s\r\n</pre>\r\n",content); if (REMOTE_ADDR != NULL) printf("发送者 IP 地址 %s<br>\n",REMOTE_ADDR); // 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址 2003.08.17 if (HTTP_X_FORWARDED_FOR != NULL) printf("经过代理前IP地址 %s<br>\n",HTTP_X_FORWARDED_FOR); if (HTTP_CLIENT_IP != NULL) printf("代理服务器地址 %s<br>\n",HTTP_CLIENT_IP); printf("谢谢使用!<p>\r\n"); printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: "); printf("<i>%s</i>.\r\n",WEBADMIN); html_end(); } } list_clear(&entries); list_clear(&configs); return 0; }
int main(int argc, char *argv[]) { log_options_t logopt = LOG_OPTS_STDERR_ONLY; job_desc_msg_t desc; resource_allocation_response_msg_t *alloc; time_t before, after; allocation_msg_thread_t *msg_thr; char **env = NULL, *cluster_name; int status = 0; int retries = 0; pid_t pid = getpid(); pid_t tpgid = 0; pid_t rc_pid = 0; int i, rc = 0; static char *msg = "Slurm job queue full, sleeping and retrying."; slurm_allocation_callbacks_t callbacks; slurm_conf_init(NULL); log_init(xbasename(argv[0]), logopt, 0, NULL); _set_exit_code(); if (spank_init_allocator() < 0) { error("Failed to initialize plugin stack"); exit(error_exit); } /* Be sure to call spank_fini when salloc exits */ if (atexit((void (*) (void)) spank_fini) < 0) error("Failed to register atexit handler for plugins: %m"); if (initialize_and_process_args(argc, argv) < 0) { error("salloc parameter parsing"); exit(error_exit); } /* reinit log with new verbosity (if changed by command line) */ if (opt.verbose || opt.quiet) { logopt.stderr_level += opt.verbose; logopt.stderr_level -= opt.quiet; logopt.prefix_level = 1; log_alter(logopt, 0, NULL); } if (spank_init_post_opt() < 0) { error("Plugin stack post-option processing failed"); exit(error_exit); } _set_spank_env(); _set_submit_dir_env(); if (opt.cwd && chdir(opt.cwd)) { error("chdir(%s): %m", opt.cwd); exit(error_exit); } if (opt.get_user_env_time >= 0) { bool no_env_cache = false; char *sched_params; char *user = uid_to_string(opt.uid); if (xstrcmp(user, "nobody") == 0) { error("Invalid user id %u: %m", (uint32_t)opt.uid); exit(error_exit); } sched_params = slurm_get_sched_params(); no_env_cache = (sched_params && strstr(sched_params, "no_env_cache")); xfree(sched_params); env = env_array_user_default(user, opt.get_user_env_time, opt.get_user_env_mode, no_env_cache); xfree(user); if (env == NULL) exit(error_exit); /* error already logged */ _set_rlimits(env); } /* * Job control for interactive salloc sessions: only if ... * * a) input is from a terminal (stdin has valid termios attributes), * b) controlling terminal exists (non-negative tpgid), * c) salloc is not run in allocation-only (--no-shell) mode, * NOTE: d and e below are configuration dependent * d) salloc runs in its own process group (true in interactive * shells that support job control), * e) salloc has been configured at compile-time to support background * execution and is not currently in the background process group. */ if (tcgetattr(STDIN_FILENO, &saved_tty_attributes) < 0) { /* * Test existence of controlling terminal (tpgid > 0) * after first making sure stdin is not redirected. */ } else if ((tpgid = tcgetpgrp(STDIN_FILENO)) < 0) { #ifdef HAVE_ALPS_CRAY verbose("no controlling terminal"); #else if (!opt.no_shell) { error("no controlling terminal: please set --no-shell"); exit(error_exit); } #endif #ifdef SALLOC_RUN_FOREGROUND } else if ((!opt.no_shell) && (pid == getpgrp())) { if (tpgid == pid) is_interactive = true; while (tcgetpgrp(STDIN_FILENO) != pid) { if (!is_interactive) { error("Waiting for program to be placed in " "the foreground"); is_interactive = true; } killpg(pid, SIGTTIN); } } #else } else if ((!opt.no_shell) && (getpgrp() == tcgetpgrp(STDIN_FILENO))) {
static void _xlate_before(char *depend, uint32_t submit_uid, uint32_t my_job_id) { uint32_t job_id; char *last_ptr = NULL, *new_dep = NULL, *tok, *type; struct job_record *job_ptr; pthread_attr_t attr; pthread_t dep_thread; tok = strtok_r(depend, ":", &last_ptr); if (!xstrcmp(tok, "before")) type = "after"; else if (!xstrcmp(tok, "beforeany")) type = "afterany"; else if (!xstrcmp(tok, "beforenotok")) type = "afternotok"; else if (!xstrcmp(tok, "beforeok")) type = "afterok"; else { info("%s: discarding invalid job dependency option %s", plugin_type, tok); return; } /* NOTE: We are updating a job record here in order to implement * the depend=before option. We are doing so without the write lock * on the job record, but using a local mutex to prevent multiple * updates on the same job when multiple jobs satisfying the dependency * are being processed at the same time (all with read locks). The * job read lock will prevent anyone else from getting a job write * lock and using a job write lock causes serious performance problems * for slow job_submit plugins. Not an ideal solution, but the best * option that we see. */ slurm_mutex_lock(&depend_mutex); tok = strtok_r(NULL, ":", &last_ptr); while (tok) { job_id = atoi(tok); job_ptr = find_job_record(job_id); if (!job_ptr) { info("%s: discarding invalid job dependency before %s", plugin_type, tok); } else if ((submit_uid != job_ptr->user_id) && !validate_super_user(submit_uid)) { error("%s: Security violation: uid %u trying to alter " "job %u belonging to uid %u", plugin_type, submit_uid, job_ptr->job_id, job_ptr->user_id); } else if ((!IS_JOB_PENDING(job_ptr)) || (job_ptr->details == NULL)) { info("%s: discarding job before dependency on " "non-pending job %u", plugin_type, job_ptr->job_id); } else { if (job_ptr->details->dependency) { xstrcat(new_dep, job_ptr->details->dependency); xstrcat(new_dep, ","); } xstrfmtcat(new_dep, "%s:%u", type, my_job_id); xfree(job_ptr->details->dependency); job_ptr->details->dependency = new_dep; new_dep = NULL; _decr_depend_cnt(job_ptr); slurm_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&dep_thread, &attr, _dep_agent, job_ptr); slurm_attr_destroy(&attr); } tok = strtok_r(NULL, ":", &last_ptr); } slurm_mutex_unlock(&depend_mutex); }
static List _create_block_list(partition_info_msg_t *part_info_ptr, block_info_msg_t *block_info_ptr) { int i; static List block_list = NULL; static partition_info_msg_t *last_part_info_ptr = NULL; static block_info_msg_t *last_block_info_ptr = NULL; List last_list = NULL; ListIterator last_list_itr = NULL; sview_block_info_t *block_ptr = NULL; char tmp_mp_str[50]; if (block_list && (part_info_ptr == last_part_info_ptr) && (block_info_ptr == last_block_info_ptr)) return block_list; last_part_info_ptr = part_info_ptr; if (block_list) { /* Only the partition info changed so lets update just that part. */ if (block_info_ptr == last_block_info_ptr) { ListIterator itr = list_iterator_create(block_list); while ((block_ptr = list_next(itr))) _set_block_partition(part_info_ptr, block_ptr); return block_list; } last_list = block_list; } block_list = list_create(_block_list_del); if (!block_list) { g_print("malloc error\n"); return NULL; } last_block_info_ptr = block_info_ptr; if (last_list) last_list_itr = list_iterator_create(last_list); for (i=0; i<block_info_ptr->record_count; i++) { /* If we don't have a block name just continue since ths block hasn't been made in the system yet. */ if (!block_info_ptr->block_array[i].bg_block_id) continue; block_ptr = NULL; if (last_list_itr) { while ((block_ptr = list_next(last_list_itr))) { if (!xstrcmp(block_ptr->bg_block_name, block_info_ptr-> block_array[i].bg_block_id)) { list_remove(last_list_itr); _block_info_free(block_ptr); break; } } list_iterator_reset(last_list_itr); } if (!block_ptr) block_ptr = xmalloc(sizeof(sview_block_info_t)); block_ptr->pos = i; block_ptr->bg_block_name = xstrdup(block_info_ptr-> block_array[i].bg_block_id); block_ptr->color_inx = atoi(block_ptr->bg_block_name+7); /* on some systems they make there own blocks named whatever they want, so doing this fixes what could be a negative number. */ if (block_ptr->color_inx < 0) block_ptr->color_inx = i; block_ptr->color_inx %= sview_colors_cnt; block_ptr->mp_str = xstrdup(block_info_ptr->block_array[i].mp_str); if (block_info_ptr->block_array[i].ionode_str) { block_ptr->small_block = 1; snprintf(tmp_mp_str, sizeof(tmp_mp_str), "%s[%s]", block_ptr->mp_str, block_info_ptr->block_array[i].ionode_str); xfree(block_ptr->mp_str); block_ptr->mp_str = xstrdup(tmp_mp_str); } block_ptr->reason = xstrdup(block_info_ptr->block_array[i].reason); if (cluster_flags & CLUSTER_FLAG_BGP) { block_ptr->imagelinux = xstrdup( block_info_ptr->block_array[i].linuximage); block_ptr->imageramdisk = xstrdup( block_info_ptr->block_array[i].ramdiskimage); } else if (cluster_flags & CLUSTER_FLAG_BGL) { block_ptr->imageblrts = xstrdup( block_info_ptr->block_array[i].blrtsimage); block_ptr->imagelinux = xstrdup( block_info_ptr->block_array[i].linuximage); block_ptr->imageramdisk = xstrdup( block_info_ptr->block_array[i].ramdiskimage); } block_ptr->imagemloader = xstrdup( block_info_ptr->block_array[i].mloaderimage); block_ptr->state = block_info_ptr->block_array[i].state; memcpy(block_ptr->bg_conn_type, block_info_ptr->block_array[i].conn_type, sizeof(block_ptr->bg_conn_type)); if (cluster_flags & CLUSTER_FLAG_BGL) block_ptr->bg_node_use = block_info_ptr->block_array[i].node_use; block_ptr->cnode_cnt = block_info_ptr->block_array[i].cnode_cnt; block_ptr->cnode_err_cnt = block_info_ptr->block_array[i].cnode_err_cnt; block_ptr->mp_inx = block_info_ptr->block_array[i].mp_inx; _set_block_partition(part_info_ptr, block_ptr); block_ptr->job_list = list_create(slurm_free_block_job_info); if (block_info_ptr->block_array[i].job_list) list_transfer(block_ptr->job_list, block_info_ptr->block_array[i].job_list); if (block_ptr->bg_conn_type[0] >= SELECT_SMALL) block_ptr->size = 0; list_append(block_list, block_ptr); } list_sort(block_list, (ListCmpF)_sview_block_sort_aval_dec); if (last_list) { list_iterator_destroy(last_list_itr); FREE_NULL_LIST(last_list); } return block_list; }
static form_element_t * read_83_form(const char *path) { xmlDoc *doc = NULL; xmlNode *root_element = NULL; const xmlNode *el; doc = xmlReadFile(path, NULL, 0); root_element = xmlDocGetRootElement(doc); el = find_by_name(root_element->children, "Elements"); int grouping = GROUPING_VERTICAL; { const xmlNode *p = find_by_path(el, "Properties/ChildrenGrouping")->children; if (xstrcmp(p->content, "Vertical") != 0) grouping = GROUPING_HORIZONTAL; } el = find_by_path(el, "ContainedItems"); form_element_t *form = malloc(sizeof(*form)); form->widget = grouping == GROUPING_HORIZONTAL ? gtk_hbox_new(false, 2) : gtk_vbox_new(false, 2) ; form->box = true; { const xmlNode *pre = find_by_name(root_element->children, "Elements"); pre = find_by_path(pre, "PredefinedContainedItems"); if (pre->children) { form_element_t vbox, pre_box; vbox.widget = gtk_vbox_new(false, 0); vbox.box = true; pre_box.widget = gtk_vbox_new(false, 0); pre_box.box = true; load_form_elements(pre->children, &pre_box); gtk_box_pack_start(GTK_BOX(vbox.widget), pre_box.widget, false, false, 0); gtk_box_pack_start(GTK_BOX(vbox.widget), form->widget, false, false, 0); form->widget = vbox.widget; } } load_form_elements(el->children, form); xmlFreeDoc(doc); xmlCleanupParser(); return form; }
void _display_info_block(List block_list, popup_info_t *popup_win) { specific_info_t *spec_info = popup_win->spec_info; char *name = (char *)spec_info->search_info->gchar_data; int j = 0, found = 0; sview_block_info_t *block_ptr = NULL; int update = 0; GtkTreeView *treeview = NULL; ListIterator itr = NULL; if (!spec_info->search_info->gchar_data) goto finished; need_refresh: if (!spec_info->display_widget) { treeview = create_treeview_2cols_attach_to_table( popup_win->table); spec_info->display_widget = gtk_widget_ref(GTK_WIDGET(treeview)); } else { treeview = GTK_TREE_VIEW(spec_info->display_widget); update = 1; } itr = list_iterator_create(block_list); while ((block_ptr = (sview_block_info_t*) list_next(itr))) { if (!xstrcmp(block_ptr->bg_block_name, name) || !xstrcmp(block_ptr->mp_str, name)) { /* we want to over ride any subgrp in error state */ enum node_states state = NODE_STATE_UNKNOWN; if (block_ptr->state & BG_BLOCK_ERROR_FLAG) state = NODE_STATE_ERROR; else if (list_count(block_ptr->job_list)) state = NODE_STATE_ALLOCATED; else state = NODE_STATE_IDLE; j = 0; while (block_ptr->mp_inx[j] >= 0) { change_grid_color( popup_win->grid_button_list, block_ptr->mp_inx[j], block_ptr->mp_inx[j+1], block_ptr->color_inx, true, state); j += 2; } _layout_block_record(treeview, block_ptr, update); found = 1; break; } } list_iterator_destroy(itr); post_setup_popup_grid_list(popup_win); if (!found) { if (!popup_win->not_found) { char *temp = "BLOCK DOESN'T EXSIST\n"; GtkTreeIter iter; GtkTreeModel *model = NULL; /* only time this will be run so no update */ model = gtk_tree_view_get_model(treeview); add_display_treestore_line(0, GTK_TREE_STORE(model), &iter, temp, ""); } popup_win->not_found = true; } else { if (popup_win->not_found) { popup_win->not_found = false; gtk_widget_destroy(spec_info->display_widget); goto need_refresh; } } gtk_widget_show(spec_info->display_widget); finished: return; }
extern spawn_req_t * client_req_parse_spawn_req(client_req_t *req) { spawn_req_t *spawn_req = NULL; spawn_subcmd_t *subcmd = NULL; int i = 0, j = 0, pi = 0; /* req body already parsed */ pi = 0; if (req->pairs_cnt - pi < 5) { /* NCMDS, PREPUTCOUNT, SUBCMD, MAXPROCS, ARGC */ error("mpi/pmi2: wrong number of key-val pairs in spawn cmd"); return NULL; } spawn_req = spawn_req_new(); /* ncmds */ if (xstrcmp(MP_KEY(req, pi), NCMDS_KEY)) { error("mpi/pmi2: '" NCMDS_KEY "' expected in spawn cmd"); goto req_err; } spawn_req->subcmd_cnt = atoi(MP_VAL(req, pi)); spawn_req->subcmds = xmalloc(spawn_req->subcmd_cnt * sizeof(spawn_subcmd_t *)); pi ++; /* preputcount */ if (xstrcmp(MP_KEY(req, pi), PREPUTCOUNT_KEY)) { error("mpi/pmi2: '" PREPUTCOUNT_KEY "' expected in spawn cmd"); goto req_err; } spawn_req->preput_cnt = atoi(MP_VAL(req, pi)); pi ++; if (req->pairs_cnt - pi < ( (2 * spawn_req->preput_cnt) + (3 * spawn_req->subcmd_cnt) )) { /* <PPKEY, PPVAL>, <SUBCMD, MAXPROCS, ARGC> */ error("mpi/pmi2: wrong number of key-val pairs in spawn cmd"); goto req_err; } spawn_req->pp_keys = xmalloc(spawn_req->preput_cnt * sizeof(char *)); spawn_req->pp_vals = xmalloc(spawn_req->preput_cnt * sizeof(char *)); /* ppkey,ppval */ for (i = 0; i < spawn_req->preput_cnt; i ++) { /* ppkey */ if (xstrncmp(MP_KEY(req, pi), PPKEY_KEY, strlen(PPKEY_KEY)) || atoi((MP_KEY(req, pi) + strlen(PPKEY_KEY))) != i) { error("mpi/pmi2: '" PPKEY_KEY "%d' expected in spawn cmd", i); goto req_err; } spawn_req->pp_keys[i] = xstrdup(MP_VAL(req, pi)); pi ++; /* ppval */ if (xstrncmp(MP_KEY(req, pi), PPVAL_KEY, strlen(PPVAL_KEY)) || atoi((MP_KEY(req, pi) + strlen(PPVAL_KEY))) != i) { error("mpi/pmi2: '" PPVAL_KEY "%d' expected in spawn cmd", i); goto req_err; } spawn_req->pp_vals[i] = xstrdup(MP_VAL(req, pi)); pi ++; } /* subcmd */ for (i = 0; i < spawn_req->subcmd_cnt; i ++) { spawn_req->subcmds[i] = spawn_subcmd_new(); subcmd = spawn_req->subcmds[i]; /* subcmd */ if (xstrcmp(MP_KEY(req, pi), SUBCMD_KEY)) { error("mpi/pmi2: '" SUBCMD_KEY "' expected in spawn cmd"); goto req_err; } subcmd->cmd = xstrdup(MP_VAL(req, pi)); pi ++; /* maxprocs */ if (xstrcmp(MP_KEY(req, pi), MAXPROCS_KEY)) { error("mpi/pmi2: '" MAXPROCS_KEY "' expected in spawn cmd"); goto req_err; } subcmd->max_procs = atoi(MP_VAL(req, pi)); pi ++; /* argc */ if (xstrcmp(MP_KEY(req, pi), ARGC_KEY)) { error("mpi/pmi2: '" ARGC_KEY "' expected in spawn cmd"); goto req_err; } subcmd->argc = atoi(MP_VAL(req, pi)); pi ++; if (req->pairs_cnt - pi < ( subcmd->argc + (3 * (spawn_req->subcmd_cnt - i - 1))) ) { /* <ARGV>, <SUBCMD, MAXPROCS, ARGC> */ error("mpi/pmi2: wrong number of key-val pairs" " in spawn cmd"); goto req_err; } debug("mpi/pmi2: argc = %d", subcmd->argc); if (subcmd->argc > 0) { subcmd->argv = xmalloc(subcmd->argc * sizeof(char *)); } /* argv */ for (j = 0; j < subcmd->argc; j ++) { if (xstrncmp(MP_KEY(req, pi), ARGV_KEY, strlen(ARGV_KEY)) || atoi((MP_KEY(req, pi) + strlen(ARGV_KEY))) != j) { error("mpi/pmi2: '" ARGV_KEY "%d' expected in spawn cmd", j); goto req_err; } subcmd->argv[j] = xstrdup(MP_VAL(req, pi)); pi ++; } debug("mpi/pmi2: got argv"); /* infokeycount, optional */ if (pi == req->pairs_cnt) { if (i != spawn_req->subcmd_cnt - 1) { error("mpi/pmi2: wrong number of key-val pairs" "in spawn cmd"); goto req_err; } break; } else if (xstrcmp(MP_KEY(req, pi), INFOKEYCOUNT_KEY)) { subcmd->info_cnt = 0; continue; } subcmd->info_cnt = atoi(MP_VAL(req, pi)); pi ++; if (req->pairs_cnt - pi < ( (2 * subcmd->info_cnt) + (3 * (spawn_req->subcmd_cnt - i - 1)) )) { /* <INFOKEY, INFOVAL>, <SUBCMD, MAXPROCS, ARGC> */ error("mpi/pmi2: wrong number of key-val pairs" " in spawn cmd"); goto req_err; } if (subcmd->info_cnt > 0) { subcmd->info_keys = xmalloc(subcmd->info_cnt * sizeof(char *)); subcmd->info_vals = xmalloc(subcmd->info_cnt * sizeof(char *)); } /* infokey,infoval */ for (j = 0; j < subcmd->info_cnt; j ++) { /* infokey */ if (xstrncmp(MP_KEY(req, pi), INFOKEY_KEY, strlen(INFOKEY_KEY)) || atoi((MP_KEY(req, pi) + strlen(INFOKEY_KEY))) != j) { error("mpi/pmi2: '" INFOKEY_KEY "%d' expected in spawn cmd", j); goto req_err; } subcmd->info_keys[j] = xstrdup(MP_VAL(req, pi)); pi ++; /* infoval */ if (xstrncmp(MP_KEY(req, pi), INFOVAL_KEY, strlen(INFOVAL_KEY)) || atoi((MP_KEY(req, pi) + strlen(INFOVAL_KEY))) != j) { error("mpi/pmi2: '" INFOVAL_KEY "%d' expected in spawn cmd", j); goto req_err; } subcmd->info_vals[j] = xstrdup(MP_VAL(req, pi)); pi ++; } } debug("mpi/pmi2: out client_req_parse_spawn"); return spawn_req; req_err: spawn_req_free(spawn_req); return NULL; }
/* * _get_command - get a command from the user * OUT argc - location to store count of arguments * OUT argv - location to store the argument list */ static int _get_command (int *argc, char **argv) { char *in_line; static char *last_in_line = NULL; int i, in_line_size; static int last_in_line_size = 0; *argc = 0; #if HAVE_READLINE in_line = readline ("sreport: "); #else in_line = _getline("sreport: "); #endif if (in_line == NULL) { exit_flag = 2; return 0; } else if (xstrncmp (in_line, "#", 1) == 0) { free (in_line); return 0; } else if (xstrcmp (in_line, "!!") == 0) { free (in_line); in_line = last_in_line; in_line_size = last_in_line_size; } else { if (last_in_line) free (last_in_line); last_in_line = in_line; last_in_line_size = in_line_size = strlen (in_line); } #if HAVE_READLINE add_history(in_line); #endif /* break in_line into tokens */ for (i = 0; i < in_line_size; i++) { bool double_quote = false, single_quote = false; if (in_line[i] == '\0') break; if (isspace ((int) in_line[i])) continue; if (((*argc) + 1) > MAX_INPUT_FIELDS) { /* bogus input line */ exit_code = 1; fprintf (stderr, "%s: can not process over %d words\n", command_name, input_words); return E2BIG; } argv[(*argc)++] = &in_line[i]; for (i++; i < in_line_size; i++) { if (in_line[i] == '\042') { double_quote = !double_quote; continue; } if (in_line[i] == '\047') { single_quote = !single_quote; continue; } if (in_line[i] == '\0') break; if (double_quote || single_quote) continue; if (isspace ((int) in_line[i])) { in_line[i] = '\0'; break; } } } return 0; }
/* returns 1 if job and nodes are ready for job to begin, 0 otherwise */ static int _wait_nodes_ready(resource_allocation_response_msg_t *alloc) { int is_ready = 0, i, rc; double cur_delay = 0; double cur_sleep = 0; int suspend_time, resume_time, max_delay; bool job_killed = false; suspend_time = slurm_get_suspend_timeout(); resume_time = slurm_get_resume_timeout(); if ((suspend_time == 0) || (resume_time == 0)) return 1; /* Power save mode disabled */ max_delay = suspend_time + resume_time; max_delay *= 5; /* Allow for ResumeRate support */ pending_job_id = alloc->job_id; for (i = 0; cur_delay < max_delay; i++) { if (i) { cur_sleep = POLL_SLEEP * i; if (i == 1) { verbose("Waiting for nodes to boot (delay looping %d times @ %f secs x index)", max_delay, POLL_SLEEP); } else { debug("Waited %f sec and still waiting: next sleep for %f sec", cur_delay, cur_sleep); } usleep(1000000 * cur_sleep); cur_delay += cur_sleep; } rc = slurm_job_node_ready(alloc->job_id); if (rc == READY_JOB_FATAL) break; /* fatal error */ if ((rc == READY_JOB_ERROR) || (rc == EAGAIN)) continue; /* retry */ if ((rc & READY_JOB_STATE) == 0) { /* job killed */ job_killed = true; break; } if (rc & READY_NODE_STATE) { /* job and node ready */ is_ready = 1; break; } if (destroy_job) break; } if (is_ready) { resource_allocation_response_msg_t *resp; char *tmp_str; if (i > 0) verbose("Nodes %s are ready for job", alloc->node_list); if (alloc->alias_list && !xstrcmp(alloc->alias_list, "TBD") && (slurm_allocation_lookup(pending_job_id, &resp) == SLURM_SUCCESS)) { tmp_str = alloc->alias_list; alloc->alias_list = resp->alias_list; resp->alias_list = tmp_str; slurm_free_resource_allocation_response_msg(resp); } } else if (!destroy_job) { if (job_killed) { error("Job allocation %u has been revoked", alloc->job_id); destroy_job = true; } else error("Nodes %s are still not ready", alloc->node_list); } else /* allocation_interrupted and slurmctld not responing */ is_ready = 0; pending_job_id = 0; return is_ready; }
/* _filter_job_records - filtering job information per user specification * RET Count of job's filtered out OTHER than for job ID value */ static int _filter_job_records (void) { int filter_cnt = 0; int i; job_info_t *job_ptr = NULL; uint32_t job_base_state; job_ptr = job_buffer_ptr->job_array; for (i = 0; i < job_buffer_ptr->record_count; i++, job_ptr++) { if (IS_JOB_FINISHED(job_ptr)) job_ptr->job_id = 0; if (job_ptr->job_id == 0) continue; job_base_state = job_ptr->job_state & JOB_STATE_BASE; if ((job_base_state != JOB_PENDING) && (job_base_state != JOB_RUNNING) && (job_base_state != JOB_SUSPENDED)) { job_ptr->job_id = 0; filter_cnt++; continue; } if (opt.account != NULL && xstrcmp(job_ptr->account, opt.account)) { job_ptr->job_id = 0; filter_cnt++; continue; } if (opt.job_name != NULL && xstrcmp(job_ptr->name, opt.job_name)) { job_ptr->job_id = 0; filter_cnt++; continue; } if ((opt.partition != NULL) && xstrcmp(job_ptr->partition, opt.partition)) { job_ptr->job_id = 0; filter_cnt++; continue; } if ((opt.qos != NULL) && xstrcmp(job_ptr->qos, opt.qos)) { job_ptr->job_id = 0; filter_cnt++; continue; } if ((opt.reservation != NULL) && xstrcmp(job_ptr->resv_name, opt.reservation)) { job_ptr->job_id = 0; filter_cnt++; continue; } if ((opt.state != JOB_END) && (job_ptr->job_state != opt.state)) { job_ptr->job_id = 0; filter_cnt++; continue; } if ((opt.user_name != NULL) && (job_ptr->user_id != opt.user_id)) { job_ptr->job_id = 0; filter_cnt++; continue; } if (opt.nodelist != NULL) { /* If nodelist contains a '/', treat it as a file name */ if (strchr(opt.nodelist, '/') != NULL) { char *reallist; reallist = slurm_read_hostfile(opt.nodelist, NO_VAL); if (reallist) { xfree(opt.nodelist); opt.nodelist = reallist; } } hostset_t hs = hostset_create(job_ptr->nodes); if (!hostset_intersects(hs, opt.nodelist)) { job_ptr->job_id = 0; filter_cnt++; hostset_destroy(hs); continue; } else { hostset_destroy(hs); } } if (opt.wckey != NULL) { char *job_key = job_ptr->wckey; /* * A wckey that begins with '*' indicates that the wckey * was applied by default. When the --wckey option does * not begin with a '*', act on all wckeys with the same * name, default or not. */ if ((opt.wckey[0] != '*') && (job_key[0] == '*')) job_key++; if (xstrcmp(job_key, opt.wckey) != 0) { job_ptr->job_id = 0; filter_cnt++; continue; } } } return filter_cnt; }
static int _lic_cmp(const void *lic1, const void *lic2) { char *name1 = (*((slurm_license_info_t **)lic1))->name; char *name2 = (*((slurm_license_info_t **)lic2))->name; return xstrcmp(name1, name2); }
/* * read_slurmdbd_conf - load the SlurmDBD configuration from the slurmdbd.conf * file. Store result into global variable slurmdbd_conf. * This function can be called more than once. * RET SLURM_SUCCESS if no error, otherwise an error code */ extern int read_slurmdbd_conf(void) { s_p_options_t options[] = { {"ArchiveDir", S_P_STRING}, {"ArchiveEvents", S_P_BOOLEAN}, {"ArchiveJobs", S_P_BOOLEAN}, {"ArchiveResvs", S_P_BOOLEAN}, {"ArchiveScript", S_P_STRING}, {"ArchiveSteps", S_P_BOOLEAN}, {"ArchiveSuspend", S_P_BOOLEAN}, {"AuthInfo", S_P_STRING}, {"AuthType", S_P_STRING}, {"CommitDelay", S_P_UINT16}, {"DbdAddr", S_P_STRING}, {"DbdBackupHost", S_P_STRING}, {"DbdHost", S_P_STRING}, {"DbdPort", S_P_UINT16}, {"DebugFlags", S_P_STRING}, {"DebugLevel", S_P_STRING}, {"DefaultQOS", S_P_STRING}, {"JobPurge", S_P_UINT32}, {"LogFile", S_P_STRING}, {"LogTimeFormat", S_P_STRING}, {"MessageTimeout", S_P_UINT16}, {"PidFile", S_P_STRING}, {"PluginDir", S_P_STRING}, {"PrivateData", S_P_STRING}, {"PurgeEventAfter", S_P_STRING}, {"PurgeJobAfter", S_P_STRING}, {"PurgeResvAfter", S_P_STRING}, {"PurgeStepAfter", S_P_STRING}, {"PurgeSuspendAfter", S_P_STRING}, {"PurgeEventMonths", S_P_UINT32}, {"PurgeJobMonths", S_P_UINT32}, {"PurgeStepMonths", S_P_UINT32}, {"PurgeSuspendMonths", S_P_UINT32}, {"SlurmUser", S_P_STRING}, {"StepPurge", S_P_UINT32}, {"StorageBackupHost", S_P_STRING}, {"StorageHost", S_P_STRING}, {"StorageLoc", S_P_STRING}, {"StoragePass", S_P_STRING}, {"StoragePort", S_P_UINT16}, {"StorageType", S_P_STRING}, {"StorageUser", S_P_STRING}, {"TCPTimeout", S_P_UINT16}, {"TrackWCKey", S_P_BOOLEAN}, {"TrackSlurmctldDown", S_P_BOOLEAN}, {NULL} }; s_p_hashtbl_t *tbl = NULL; char *conf_path = NULL; char *temp_str = NULL; struct stat buf; /* Set initial values */ slurm_mutex_lock(&conf_mutex); if (slurmdbd_conf == NULL) { slurmdbd_conf = xmalloc(sizeof(slurm_dbd_conf_t)); boot_time = time(NULL); } slurmdbd_conf->debug_level = LOG_LEVEL_INFO; _clear_slurmdbd_conf(); /* Get the slurmdbd.conf path and validate the file */ conf_path = get_extra_conf_path("slurmdbd.conf"); if ((conf_path == NULL) || (stat(conf_path, &buf) == -1)) { info("No slurmdbd.conf file (%s)", conf_path); } else { bool a_events = 0, a_jobs = 0, a_resv = 0, a_steps = 0, a_suspend = 0; debug("Reading slurmdbd.conf file %s", conf_path); tbl = s_p_hashtbl_create(options); if (s_p_parse_file(tbl, NULL, conf_path, false) == SLURM_ERROR) { fatal("Could not open/read/parse slurmdbd.conf file %s", conf_path); } if (!s_p_get_string(&slurmdbd_conf->archive_dir, "ArchiveDir", tbl)) slurmdbd_conf->archive_dir = xstrdup(DEFAULT_SLURMDBD_ARCHIVE_DIR); s_p_get_boolean(&a_events, "ArchiveEvents", tbl); s_p_get_boolean(&a_jobs, "ArchiveJobs", tbl); s_p_get_boolean(&a_resv, "ArchiveResvs", tbl); s_p_get_string(&slurmdbd_conf->archive_script, "ArchiveScript", tbl); s_p_get_boolean(&a_steps, "ArchiveSteps", tbl); s_p_get_boolean(&a_suspend, "ArchiveSuspend", tbl); s_p_get_string(&slurmdbd_conf->auth_info, "AuthInfo", tbl); s_p_get_string(&slurmdbd_conf->auth_type, "AuthType", tbl); s_p_get_uint16(&slurmdbd_conf->commit_delay, "CommitDelay", tbl); s_p_get_string(&slurmdbd_conf->dbd_backup, "DbdBackupHost", tbl); s_p_get_string(&slurmdbd_conf->dbd_host, "DbdHost", tbl); s_p_get_string(&slurmdbd_conf->dbd_addr, "DbdAddr", tbl); s_p_get_uint16(&slurmdbd_conf->dbd_port, "DbdPort", tbl); if (s_p_get_string(&temp_str, "DebugFlags", tbl)) { if (debug_str2flags(temp_str, &slurmdbd_conf->debug_flags) != SLURM_SUCCESS) fatal("DebugFlags invalid: %s", temp_str); xfree(temp_str); } else /* Default: no DebugFlags */ slurmdbd_conf->debug_flags = 0; if (s_p_get_string(&temp_str, "DebugLevel", tbl)) { slurmdbd_conf->debug_level = log_string2num(temp_str); if (slurmdbd_conf->debug_level == (uint16_t) NO_VAL) fatal("Invalid DebugLevel %s", temp_str); xfree(temp_str); } s_p_get_string(&slurmdbd_conf->default_qos, "DefaultQOS", tbl); if (s_p_get_uint32(&slurmdbd_conf->purge_job, "JobPurge", tbl)) { if (!slurmdbd_conf->purge_job) slurmdbd_conf->purge_job = NO_VAL; else slurmdbd_conf->purge_job |= SLURMDB_PURGE_MONTHS; } s_p_get_string(&slurmdbd_conf->log_file, "LogFile", tbl); if (s_p_get_string(&temp_str, "LogTimeFormat", tbl)) { if (xstrcasestr(temp_str, "iso8601_ms")) slurmdbd_conf->log_fmt = LOG_FMT_ISO8601_MS; else if (xstrcasestr(temp_str, "iso8601")) slurmdbd_conf->log_fmt = LOG_FMT_ISO8601; else if (xstrcasestr(temp_str, "rfc5424_ms")) slurmdbd_conf->log_fmt = LOG_FMT_RFC5424_MS; else if (xstrcasestr(temp_str, "rfc5424")) slurmdbd_conf->log_fmt = LOG_FMT_RFC5424; else if (xstrcasestr(temp_str, "clock")) slurmdbd_conf->log_fmt = LOG_FMT_CLOCK; else if (xstrcasestr(temp_str, "short")) slurmdbd_conf->log_fmt = LOG_FMT_SHORT; else if (xstrcasestr(temp_str, "thread_id")) slurmdbd_conf->log_fmt = LOG_FMT_THREAD_ID; xfree(temp_str); } else slurmdbd_conf->log_fmt = LOG_FMT_ISO8601_MS; if (!s_p_get_uint16(&slurmdbd_conf->msg_timeout, "MessageTimeout", tbl)) slurmdbd_conf->msg_timeout = DEFAULT_MSG_TIMEOUT; else if (slurmdbd_conf->msg_timeout > 100) { info("WARNING: MessageTimeout is too high for " "effective fault-tolerance"); } s_p_get_string(&slurmdbd_conf->pid_file, "PidFile", tbl); s_p_get_string(&slurmdbd_conf->plugindir, "PluginDir", tbl); slurmdbd_conf->private_data = 0; /* default visible to all */ if (s_p_get_string(&temp_str, "PrivateData", tbl)) { if (xstrcasestr(temp_str, "account")) slurmdbd_conf->private_data |= PRIVATE_DATA_ACCOUNTS; if (xstrcasestr(temp_str, "job")) slurmdbd_conf->private_data |= PRIVATE_DATA_JOBS; if (xstrcasestr(temp_str, "node")) slurmdbd_conf->private_data |= PRIVATE_DATA_NODES; if (xstrcasestr(temp_str, "partition")) slurmdbd_conf->private_data |= PRIVATE_DATA_PARTITIONS; if (xstrcasestr(temp_str, "reservation")) slurmdbd_conf->private_data |= PRIVATE_DATA_RESERVATIONS; if (xstrcasestr(temp_str, "usage")) slurmdbd_conf->private_data |= PRIVATE_DATA_USAGE; if (xstrcasestr(temp_str, "user")) slurmdbd_conf->private_data |= PRIVATE_DATA_USERS; if (xstrcasestr(temp_str, "all")) slurmdbd_conf->private_data = 0xffff; xfree(temp_str); } if (s_p_get_string(&temp_str, "PurgeEventAfter", tbl)) { /* slurmdb_parse_purge will set SLURMDB_PURGE_FLAGS */ if ((slurmdbd_conf->purge_event = slurmdb_parse_purge(temp_str)) == NO_VAL) { fatal("Bad value \"%s\" for PurgeEventAfter", temp_str); } xfree(temp_str); } if (s_p_get_string(&temp_str, "PurgeJobAfter", tbl)) { /* slurmdb_parse_purge will set SLURMDB_PURGE_FLAGS */ if ((slurmdbd_conf->purge_job = slurmdb_parse_purge(temp_str)) == NO_VAL) { fatal("Bad value \"%s\" for PurgeJobAfter", temp_str); } xfree(temp_str); } if (s_p_get_string(&temp_str, "PurgeResvAfter", tbl)) { /* slurmdb_parse_purge will set SLURMDB_PURGE_FLAGS */ if ((slurmdbd_conf->purge_resv = slurmdb_parse_purge(temp_str)) == NO_VAL) { fatal("Bad value \"%s\" for PurgeResvAfter", temp_str); } xfree(temp_str); } if (s_p_get_string(&temp_str, "PurgeStepAfter", tbl)) { /* slurmdb_parse_purge will set SLURMDB_PURGE_FLAGS */ if ((slurmdbd_conf->purge_step = slurmdb_parse_purge(temp_str)) == NO_VAL) { fatal("Bad value \"%s\" for PurgeStepAfter", temp_str); } xfree(temp_str); } if (s_p_get_string(&temp_str, "PurgeSuspendAfter", tbl)) { /* slurmdb_parse_purge will set SLURMDB_PURGE_FLAGS */ if ((slurmdbd_conf->purge_suspend = slurmdb_parse_purge(temp_str)) == NO_VAL) { fatal("Bad value \"%s\" for PurgeSuspendAfter", temp_str); } xfree(temp_str); } if (s_p_get_uint32(&slurmdbd_conf->purge_event, "PurgeEventMonths", tbl)) { if (!slurmdbd_conf->purge_event) slurmdbd_conf->purge_event = NO_VAL; else slurmdbd_conf->purge_event |= SLURMDB_PURGE_MONTHS; } if (s_p_get_uint32(&slurmdbd_conf->purge_job, "PurgeJobMonths", tbl)) { if (!slurmdbd_conf->purge_job) slurmdbd_conf->purge_job = NO_VAL; else slurmdbd_conf->purge_job |= SLURMDB_PURGE_MONTHS; } if (s_p_get_uint32(&slurmdbd_conf->purge_step, "PurgeStepMonths", tbl)) { if (!slurmdbd_conf->purge_step) slurmdbd_conf->purge_step = NO_VAL; else slurmdbd_conf->purge_step |= SLURMDB_PURGE_MONTHS; } if (s_p_get_uint32(&slurmdbd_conf->purge_suspend, "PurgeSuspendMonths", tbl)) { if (!slurmdbd_conf->purge_suspend) slurmdbd_conf->purge_suspend = NO_VAL; else slurmdbd_conf->purge_suspend |= SLURMDB_PURGE_MONTHS; } s_p_get_string(&slurmdbd_conf->slurm_user_name, "SlurmUser", tbl); if (s_p_get_uint32(&slurmdbd_conf->purge_step, "StepPurge", tbl)) { if (!slurmdbd_conf->purge_step) slurmdbd_conf->purge_step = NO_VAL; else slurmdbd_conf->purge_step |= SLURMDB_PURGE_MONTHS; } s_p_get_string(&slurmdbd_conf->storage_backup_host, "StorageBackupHost", tbl); s_p_get_string(&slurmdbd_conf->storage_host, "StorageHost", tbl); s_p_get_string(&slurmdbd_conf->storage_loc, "StorageLoc", tbl); s_p_get_string(&slurmdbd_conf->storage_pass, "StoragePass", tbl); s_p_get_uint16(&slurmdbd_conf->storage_port, "StoragePort", tbl); s_p_get_string(&slurmdbd_conf->storage_type, "StorageType", tbl); s_p_get_string(&slurmdbd_conf->storage_user, "StorageUser", tbl); if (!s_p_get_uint16(&slurmdbd_conf->tcp_timeout, "TCPTimeout", tbl)) slurmdbd_conf->tcp_timeout = DEFAULT_TCP_TIMEOUT; if (!s_p_get_boolean((bool *)&slurmdbd_conf->track_wckey, "TrackWCKey", tbl)) slurmdbd_conf->track_wckey = false; if (!s_p_get_boolean((bool *)&slurmdbd_conf->track_ctld, "TrackSlurmctldDown", tbl)) slurmdbd_conf->track_ctld = false; if (a_events && slurmdbd_conf->purge_event) slurmdbd_conf->purge_event |= SLURMDB_PURGE_ARCHIVE; if (a_jobs && slurmdbd_conf->purge_job) slurmdbd_conf->purge_job |= SLURMDB_PURGE_ARCHIVE; if (a_resv && slurmdbd_conf->purge_resv) slurmdbd_conf->purge_resv |= SLURMDB_PURGE_ARCHIVE; if (a_steps && slurmdbd_conf->purge_step) slurmdbd_conf->purge_step |= SLURMDB_PURGE_ARCHIVE; if (a_suspend && slurmdbd_conf->purge_suspend) slurmdbd_conf->purge_suspend |= SLURMDB_PURGE_ARCHIVE; s_p_hashtbl_destroy(tbl); } xfree(conf_path); if (slurmdbd_conf->auth_type == NULL) slurmdbd_conf->auth_type = xstrdup(DEFAULT_SLURMDBD_AUTHTYPE); if (slurmdbd_conf->dbd_host == NULL) { error("slurmdbd.conf lacks DbdHost parameter, " "using 'localhost'"); slurmdbd_conf->dbd_host = xstrdup("localhost"); } if (slurmdbd_conf->dbd_addr == NULL) slurmdbd_conf->dbd_addr = xstrdup(slurmdbd_conf->dbd_host); if (slurmdbd_conf->pid_file == NULL) slurmdbd_conf->pid_file = xstrdup(DEFAULT_SLURMDBD_PIDFILE); if (slurmdbd_conf->dbd_port == 0) slurmdbd_conf->dbd_port = SLURMDBD_PORT; if (slurmdbd_conf->plugindir == NULL) slurmdbd_conf->plugindir = xstrdup(default_plugin_path); if (slurmdbd_conf->slurm_user_name) { uid_t pw_uid; if (uid_from_string (slurmdbd_conf->slurm_user_name, &pw_uid) < 0) fatal("Invalid user for SlurmUser %s, ignored", slurmdbd_conf->slurm_user_name); else slurmdbd_conf->slurm_user_id = pw_uid; } else { slurmdbd_conf->slurm_user_name = xstrdup("root"); slurmdbd_conf->slurm_user_id = 0; } if (slurmdbd_conf->storage_type == NULL) fatal("StorageType must be specified"); if (!xstrcmp(slurmdbd_conf->storage_type, "accounting_storage/slurmdbd")) { fatal("StorageType=%s is invalid in slurmdbd.conf", slurmdbd_conf->storage_type); } if (!slurmdbd_conf->storage_host) slurmdbd_conf->storage_host = xstrdup(DEFAULT_STORAGE_HOST); if (!slurmdbd_conf->storage_user) slurmdbd_conf->storage_user = xstrdup(getlogin()); if (!xstrcmp(slurmdbd_conf->storage_type, "accounting_storage/mysql")) { if (!slurmdbd_conf->storage_port) slurmdbd_conf->storage_port = DEFAULT_MYSQL_PORT; if (!slurmdbd_conf->storage_loc) slurmdbd_conf->storage_loc = xstrdup(DEFAULT_ACCOUNTING_DB); } else { if (!slurmdbd_conf->storage_port) slurmdbd_conf->storage_port = DEFAULT_STORAGE_PORT; if (!slurmdbd_conf->storage_loc) slurmdbd_conf->storage_loc = xstrdup(DEFAULT_STORAGE_LOC); } if (slurmdbd_conf->archive_dir) { if (stat(slurmdbd_conf->archive_dir, &buf) < 0) fatal("Failed to stat the archive directory %s: %m", slurmdbd_conf->archive_dir); if (!(buf.st_mode & S_IFDIR)) fatal("archive directory %s isn't a directory", slurmdbd_conf->archive_dir); if (access(slurmdbd_conf->archive_dir, W_OK) < 0) fatal("archive directory %s is not writable", slurmdbd_conf->archive_dir); } if (slurmdbd_conf->archive_script) { if (stat(slurmdbd_conf->archive_script, &buf) < 0) fatal("Failed to stat the archive script %s: %m", slurmdbd_conf->archive_dir); if (!(buf.st_mode & S_IFREG)) fatal("archive script %s isn't a regular file", slurmdbd_conf->archive_script); if (access(slurmdbd_conf->archive_script, X_OK) < 0) fatal("archive script %s is not executable", slurmdbd_conf->archive_script); } if (!slurmdbd_conf->purge_event) slurmdbd_conf->purge_event = NO_VAL; if (!slurmdbd_conf->purge_job) slurmdbd_conf->purge_job = NO_VAL; if (!slurmdbd_conf->purge_resv) slurmdbd_conf->purge_resv = NO_VAL; if (!slurmdbd_conf->purge_step) slurmdbd_conf->purge_step = NO_VAL; if (!slurmdbd_conf->purge_suspend) slurmdbd_conf->purge_suspend = NO_VAL; slurm_mutex_unlock(&conf_mutex); return SLURM_SUCCESS; }
/* * slurm_sprint_node_table - output information about a specific Slurm nodes * based upon message as loaded using slurm_load_node * IN node_ptr - an individual node information record pointer * IN one_liner - print as a single line if true * RET out - char * containing formatted output (must be freed after call) * NULL is returned on failure. */ char *slurm_sprint_node_table(node_info_t *node_ptr, int one_liner) { uint32_t my_state = node_ptr->node_state; char *cloud_str = "", *comp_str = "", *drain_str = "", *power_str = ""; char time_str[32]; char *out = NULL, *reason_str = NULL; uint16_t alloc_cpus = 0; int idle_cpus; uint64_t alloc_memory; char *node_alloc_tres = NULL; char *line_end = (one_liner) ? " " : "\n "; slurm_ctl_conf_info_msg_t *slurm_ctl_conf_ptr = NULL; if (slurm_load_ctl_conf((time_t) NULL, &slurm_ctl_conf_ptr) != SLURM_SUCCESS) fatal("Cannot load slurmctld conf file"); if (my_state & NODE_STATE_CLOUD) { my_state &= (~NODE_STATE_CLOUD); cloud_str = "+CLOUD"; } if (my_state & NODE_STATE_COMPLETING) { my_state &= (~NODE_STATE_COMPLETING); comp_str = "+COMPLETING"; } if (my_state & NODE_STATE_DRAIN) { my_state &= (~NODE_STATE_DRAIN); drain_str = "+DRAIN"; } if (my_state & NODE_STATE_FAIL) { my_state &= (~NODE_STATE_FAIL); drain_str = "+FAIL"; } if (my_state & NODE_STATE_POWER_SAVE) { my_state &= (~NODE_STATE_POWER_SAVE); power_str = "+POWER"; } if (my_state & NODE_STATE_POWERING_DOWN) { my_state &= (~NODE_STATE_POWERING_DOWN); power_str = "+POWERING_DOWN"; } slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); idle_cpus = node_ptr->cpus - alloc_cpus; if (idle_cpus && (idle_cpus != node_ptr->cpus)) { my_state &= NODE_STATE_FLAGS; my_state |= NODE_STATE_MIXED; } /****** Line 1 ******/ xstrfmtcat(out, "NodeName=%s ", node_ptr->name); if (node_ptr->arch) xstrfmtcat(out, "Arch=%s ", node_ptr->arch); if (node_ptr->cpu_bind) { char tmp_str[128]; slurm_sprint_cpu_bind_type(tmp_str, node_ptr->cpu_bind); xstrfmtcat(out, "CpuBind=%s ", tmp_str); } xstrfmtcat(out, "CoresPerSocket=%u ", node_ptr->cores); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "CPUAlloc=%u CPUTot=%u ", alloc_cpus, node_ptr->cpus); if (node_ptr->cpu_load == NO_VAL) xstrcat(out, "CPULoad=N/A"); else xstrfmtcat(out, "CPULoad=%.2f", (node_ptr->cpu_load / 100.0)); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "AvailableFeatures=%s", node_ptr->features); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "ActiveFeatures=%s", node_ptr->features_act); xstrcat(out, line_end); /****** Line ******/ xstrfmtcat(out, "Gres=%s", node_ptr->gres); xstrcat(out, line_end); /****** Line (optional) ******/ if (node_ptr->gres_drain) { xstrfmtcat(out, "GresDrain=%s", node_ptr->gres_drain); xstrcat(out, line_end); } /****** Line (optional) ******/ if (node_ptr->gres_used) { xstrfmtcat(out, "GresUsed=%s", node_ptr->gres_used); xstrcat(out, line_end); } /****** Line (optional) ******/ { bool line_used = false; if (node_ptr->node_addr) { xstrfmtcat(out, "NodeAddr=%s ", node_ptr->node_addr); line_used = true; } if (node_ptr->node_hostname) { xstrfmtcat(out, "NodeHostName=%s ", node_ptr->node_hostname); line_used = true; } if (node_ptr->port != slurm_get_slurmd_port()) { xstrfmtcat(out, "Port=%u ", node_ptr->port); line_used = true; } if (node_ptr->version && xstrcmp(node_ptr->version, slurm_ctl_conf_ptr->version)) { xstrfmtcat(out, "Version=%s", node_ptr->version); line_used = true; } if (line_used) xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->os) { xstrfmtcat(out, "OS=%s ", node_ptr->os); xstrcat(out, line_end); } /****** Line ******/ slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_MEM_ALLOC, NODE_STATE_ALLOCATED, &alloc_memory); xstrfmtcat(out, "RealMemory=%"PRIu64" AllocMem=%"PRIu64" ", node_ptr->real_memory, alloc_memory); if (node_ptr->free_mem == NO_VAL64) xstrcat(out, "FreeMem=N/A "); else xstrfmtcat(out, "FreeMem=%"PRIu64" ", node_ptr->free_mem); xstrfmtcat(out, "Sockets=%u Boards=%u", node_ptr->sockets, node_ptr->boards); xstrcat(out, line_end); /****** core & memory specialization Line (optional) ******/ if (node_ptr->core_spec_cnt || node_ptr->cpu_spec_list || node_ptr->mem_spec_limit) { if (node_ptr->core_spec_cnt) { xstrfmtcat(out, "CoreSpecCount=%u ", node_ptr->core_spec_cnt); } if (node_ptr->cpu_spec_list) { xstrfmtcat(out, "CPUSpecList=%s ", node_ptr->cpu_spec_list); } if (node_ptr->mem_spec_limit) { xstrfmtcat(out, "MemSpecLimit=%"PRIu64"", node_ptr->mem_spec_limit); } xstrcat(out, line_end); } /****** Line ******/ xstrfmtcat(out, "State=%s%s%s%s%s ThreadsPerCore=%u TmpDisk=%u Weight=%u ", node_state_string(my_state), cloud_str, comp_str, drain_str, power_str, node_ptr->threads, node_ptr->tmp_disk, node_ptr->weight); if (node_ptr->owner == NO_VAL) { xstrcat(out, "Owner=N/A "); } else { char *user_name = uid_to_string((uid_t) node_ptr->owner); xstrfmtcat(out, "Owner=%s(%u) ", user_name, node_ptr->owner); xfree(user_name); } xstrfmtcat(out, "MCS_label=%s", (node_ptr->mcs_label == NULL) ? "N/A" : node_ptr->mcs_label); xstrcat(out, line_end); /****** Line ******/ if ((node_ptr->next_state != NO_VAL) && (my_state & NODE_STATE_REBOOT)) { xstrfmtcat(out, "NextState=%s", node_state_string(node_ptr->next_state)); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->partitions) { xstrfmtcat(out, "Partitions=%s ", node_ptr->partitions); xstrcat(out, line_end); } /****** Line ******/ if (node_ptr->boot_time) { slurm_make_time_str((time_t *)&node_ptr->boot_time, time_str, sizeof(time_str)); xstrfmtcat(out, "BootTime=%s ", time_str); } else { xstrcat(out, "BootTime=None "); } if (node_ptr->slurmd_start_time) { slurm_make_time_str ((time_t *)&node_ptr->slurmd_start_time, time_str, sizeof(time_str)); xstrfmtcat(out, "SlurmdStartTime=%s", time_str); } else { xstrcat(out, "SlurmdStartTime=None"); } xstrcat(out, line_end); /****** TRES Line ******/ select_g_select_nodeinfo_get(node_ptr->select_nodeinfo, SELECT_NODEDATA_TRES_ALLOC_FMT_STR, NODE_STATE_ALLOCATED, &node_alloc_tres); xstrfmtcat(out, "CfgTRES=%s", node_ptr->tres_fmt_str); xstrcat(out, line_end); xstrfmtcat(out, "AllocTRES=%s", (node_alloc_tres) ? node_alloc_tres : ""); xfree(node_alloc_tres); xstrcat(out, line_end); /****** Power Management Line ******/ if (!node_ptr->power || (node_ptr->power->cap_watts == NO_VAL)) xstrcat(out, "CapWatts=n/a"); else xstrfmtcat(out, "CapWatts=%u", node_ptr->power->cap_watts); xstrcat(out, line_end); /****** Power Consumption Line ******/ if (!node_ptr->energy || node_ptr->energy->current_watts == NO_VAL) xstrcat(out, "CurrentWatts=n/s AveWatts=n/s"); else xstrfmtcat(out, "CurrentWatts=%u AveWatts=%u", node_ptr->energy->current_watts, node_ptr->energy->ave_watts); xstrcat(out, line_end); /****** external sensors Line ******/ if (!node_ptr->ext_sensors || node_ptr->ext_sensors->consumed_energy == NO_VAL64) xstrcat(out, "ExtSensorsJoules=n/s "); else xstrfmtcat(out, "ExtSensorsJoules=%"PRIu64" ", node_ptr->ext_sensors->consumed_energy); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->current_watts == NO_VAL) xstrcat(out, "ExtSensorsWatts=n/s "); else xstrfmtcat(out, "ExtSensorsWatts=%u ", node_ptr->ext_sensors->current_watts); if (!node_ptr->ext_sensors || node_ptr->ext_sensors->temperature == NO_VAL) xstrcat(out, "ExtSensorsTemp=n/s"); else xstrfmtcat(out, "ExtSensorsTemp=%u", node_ptr->ext_sensors->temperature); xstrcat(out, line_end); /****** Line ******/ if (node_ptr->reason && node_ptr->reason[0]) xstrcat(reason_str, node_ptr->reason); if (reason_str) { int inx = 1; char *save_ptr = NULL, *tok, *user_name; tok = strtok_r(reason_str, "\n", &save_ptr); while (tok) { if (inx == 1) { xstrcat(out, "Reason="); } else { xstrcat(out, line_end); xstrcat(out, " "); } xstrfmtcat(out, "%s", tok); if ((inx++ == 1) && node_ptr->reason_time) { user_name = uid_to_string(node_ptr->reason_uid); slurm_make_time_str((time_t *)&node_ptr->reason_time, time_str, sizeof(time_str)); xstrfmtcat(out, " [%s@%s]", user_name, time_str); xfree(user_name); } tok = strtok_r(NULL, "\n", &save_ptr); } xfree(reason_str); } if (one_liner) xstrcat(out, "\n"); else xstrcat(out, "\n\n"); slurm_free_ctl_conf(slurm_ctl_conf_ptr); return out; }
/* * Process TaskProlog output * "export NAME=value" adds environment variables * "unset NAME" clears an environment variable * "print <whatever>" writes that to the job's stdout */ static void _proc_stdout(char *buf, stepd_step_rec_t *job) { bool end_buf = false; int len; char *buf_ptr, *name_ptr, *val_ptr; char *end_line, *equal_ptr; char ***env = &job->env; buf_ptr = buf; while (buf_ptr[0]) { end_line = strchr(buf_ptr, '\n'); if (!end_line) { end_line = buf_ptr + strlen(buf_ptr); end_buf = true; } if (!xstrncmp(buf_ptr, "print ", 6)) { buf_ptr += 6; while (isspace(buf_ptr[0])) buf_ptr++; len = end_line - buf_ptr + 1; safe_write(1, buf_ptr, len); } else if (!xstrncmp(buf_ptr, "export ",7)) { name_ptr = buf_ptr + 7; while (isspace(name_ptr[0])) name_ptr++; equal_ptr = strchr(name_ptr, '='); if (!equal_ptr || (equal_ptr > end_line)) goto rwfail; val_ptr = equal_ptr + 1; while (isspace(equal_ptr[-1])) equal_ptr--; equal_ptr[0] = '\0'; end_line[0] = '\0'; if (!xstrcmp(name_ptr, "SLURM_PROLOG_CPU_MASK")) { job->cpu_bind_type = CPU_BIND_MASK; xfree(job->cpu_bind); job->cpu_bind = xstrdup(val_ptr); if (task_g_pre_launch(job)) { error("Failed SLURM_PROLOG_CPU_MASK " "setup"); exit(1); } } debug("export name:%s:val:%s:", name_ptr, val_ptr); if (setenvf(env, name_ptr, "%s", val_ptr)) { error("Unable to set %s environment variable", buf_ptr); } equal_ptr[0] = '='; if (end_buf) end_line[0] = '\0'; else end_line[0] = '\n'; } else if (!xstrncmp(buf_ptr, "unset ", 6)) { name_ptr = buf_ptr + 6; while (isspace(name_ptr[0])) name_ptr++; if ((name_ptr[0] == '\n') || (name_ptr[0] == '\0')) goto rwfail; while (isspace(end_line[-1])) end_line--; end_line[0] = '\0'; debug(" unset name:%s:", name_ptr); unsetenvp(*env, name_ptr); if (end_buf) end_line[0] = '\0'; else end_line[0] = '\n'; } rwfail: /* process rest of script output */ if (end_buf) break; buf_ptr = end_line + 1; } return; }
extern void specific_info_block(popup_info_t *popup_win) { int part_error_code = SLURM_SUCCESS; int block_error_code = SLURM_SUCCESS; static partition_info_msg_t *part_info_ptr = NULL; static block_info_msg_t *block_info_ptr = NULL; specific_info_t *spec_info = popup_win->spec_info; sview_search_info_t *search_info = spec_info->search_info; char error_char[100]; GtkWidget *label = NULL; GtkTreeView *tree_view = NULL; List block_list = NULL; List send_block_list = NULL; sview_block_info_t *block_ptr = NULL; int j=0, i=-1; hostset_t hostset = NULL; ListIterator itr = NULL; if (!spec_info->display_widget) { setup_popup_info(popup_win, display_data_block, SORTID_CNT); } if (spec_info->display_widget && popup_win->toggled) { gtk_widget_destroy(spec_info->display_widget); spec_info->display_widget = NULL; goto display_it; } if ((part_error_code = get_new_info_part(&part_info_ptr, popup_win->force_refresh)) == SLURM_NO_CHANGE_IN_DATA) { } else if (part_error_code != SLURM_SUCCESS) { if (spec_info->view == ERROR_VIEW) goto end_it; spec_info->view = ERROR_VIEW; if (spec_info->display_widget) gtk_widget_destroy(spec_info->display_widget); sprintf(error_char, "slurm_load_partitions: %s", slurm_strerror(slurm_get_errno())); label = gtk_label_new(error_char); gtk_table_attach_defaults(popup_win->table, label, 0, 1, 0, 1); gtk_widget_show(label); spec_info->display_widget = gtk_widget_ref(label); goto end_it; } if ((block_error_code = get_new_info_block(&block_info_ptr, popup_win->force_refresh)) == SLURM_NO_CHANGE_IN_DATA) { if ((!spec_info->display_widget || spec_info->view == ERROR_VIEW) || (part_error_code != SLURM_NO_CHANGE_IN_DATA)) { goto display_it; } } else if (block_error_code != SLURM_SUCCESS) { if (spec_info->view == ERROR_VIEW) goto end_it; spec_info->view = ERROR_VIEW; if (spec_info->display_widget) gtk_widget_destroy(spec_info->display_widget); sprintf(error_char, "slurm_load_block: %s", slurm_strerror(slurm_get_errno())); label = gtk_label_new(error_char); gtk_table_attach_defaults(popup_win->table, label, 0, 1, 0, 1); gtk_widget_show(label); spec_info->display_widget = gtk_widget_ref(label); goto end_it; } display_it: block_list = _create_block_list(part_info_ptr, block_info_ptr); if (!block_list) return; if (spec_info->view == ERROR_VIEW && spec_info->display_widget) { gtk_widget_destroy(spec_info->display_widget); spec_info->display_widget = NULL; } if (spec_info->type != INFO_PAGE && !spec_info->display_widget) { tree_view = create_treeview(local_display_data, &popup_win->grid_button_list); gtk_tree_selection_set_mode( gtk_tree_view_get_selection(tree_view), GTK_SELECTION_MULTIPLE); spec_info->display_widget = gtk_widget_ref(GTK_WIDGET(tree_view)); gtk_table_attach_defaults(popup_win->table, GTK_WIDGET(tree_view), 0, 1, 0, 1); /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ create_treestore(tree_view, popup_win->display_data, SORTID_CNT, SORTID_BLOCK, SORTID_COLOR); } setup_popup_grid_list(popup_win); spec_info->view = INFO_VIEW; if (spec_info->type == INFO_PAGE) { _display_info_block(block_list, popup_win); goto end_it; } /* just linking to another list, don't free the inside, just the list */ send_block_list = list_create(NULL); itr = list_iterator_create(block_list); i = -1; while ((block_ptr = list_next(itr))) { /* we want to over ride any subgrp in error state */ enum node_states state = NODE_STATE_UNKNOWN; char *name = NULL; i++; switch(spec_info->type) { case PART_PAGE: if (xstrcmp(block_ptr->slurm_part_name, search_info->gchar_data)) continue; break; case RESV_PAGE: case NODE_PAGE: if (!block_ptr->mp_str) continue; if (!(hostset = hostset_create( search_info->gchar_data))) continue; name = block_ptr->mp_str; if (block_ptr->small_block) { int j=0; /* strip off the ionodes part */ while (name[j]) { if (name[j] == '[') { name[j] = '\0'; break; } j++; } } if (!hostset_intersects(hostset, name)) { hostset_destroy(hostset); continue; } hostset_destroy(hostset); break; case BLOCK_PAGE: switch(search_info->search_type) { case SEARCH_BLOCK_NAME: if (!search_info->gchar_data) continue; if (xstrcmp(block_ptr->bg_block_name, search_info->gchar_data)) continue; break; case SEARCH_BLOCK_SIZE: if (search_info->int_data == NO_VAL) continue; if (block_ptr->cnode_cnt != search_info->int_data) continue; break; case SEARCH_BLOCK_STATE: if (search_info->int_data == NO_VAL) continue; if (block_ptr->state != search_info->int_data) continue; break; default: continue; break; } break; case JOB_PAGE: if (xstrcmp(block_ptr->bg_block_name, search_info->gchar_data)) continue; break; default: g_print("Unknown type %d\n", spec_info->type); continue; } list_push(send_block_list, block_ptr); if (block_ptr->state & BG_BLOCK_ERROR_FLAG) state = NODE_STATE_ERROR; else if (list_count(block_ptr->job_list)) state = NODE_STATE_ALLOCATED; else state = NODE_STATE_IDLE; j=0; while (block_ptr->mp_inx[j] >= 0) { change_grid_color( popup_win->grid_button_list, block_ptr->mp_inx[j], block_ptr->mp_inx[j+1], block_ptr->color_inx, true, state); j += 2; } } list_iterator_destroy(itr); post_setup_popup_grid_list(popup_win); _update_info_block(send_block_list, GTK_TREE_VIEW(spec_info->display_widget)); FREE_NULL_LIST(send_block_list); end_it: popup_win->toggled = 0; popup_win->force_refresh = 0; return; }
/* Function to setup popup windows for Burst Buffer */ extern void popup_all_bb(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); switch(id) { case INFO_PAGE: snprintf(title, 100, "Full info for Burst Buffer %s", name); break; default: g_print("Burst Buffer got %d\n", id); } itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { if (id == INFO_PAGE) { popup_win = create_popup_info(id, BB_PAGE, title); } else { popup_win = create_popup_info(BB_PAGE, id, title); } } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; /* Sets up right click information */ switch(id) { case JOB_PAGE: case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; specific_info_bb(popup_win); break; case BLOCK_PAGE: case NODE_PAGE: case PART_PAGE: case SUBMIT_PAGE: break; default: g_print("Burst Buffer got unknown type %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, false, &error)) { g_printerr ("Failed to create burst buffer popup thread: %s\n", error->message); return; } }
extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; int i=0; gtk_tree_model_get(model, iter, SORTID_BLOCK, &name, -1); switch(id) { case JOB_PAGE: snprintf(title, 100, "Jobs(s) in block %s", name); break; case PART_PAGE: snprintf(title, 100, "Partition(s) containing block %s", name); break; case RESV_PAGE: snprintf(title, 100, "Reservations(s) containing block %s", name); break; case NODE_PAGE: snprintf(title, 100, "Midplane(s) in block %s", name); break; case SUBMIT_PAGE: snprintf(title, 100, "Submit job on %s", name); break; case INFO_PAGE: snprintf(title, 100, "Full info for block %s", name); break; default: g_print("Block got %d\n", id); } itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { if (id == INFO_PAGE) popup_win = create_popup_info(id, BLOCK_PAGE, title); else popup_win = create_popup_info(BLOCK_PAGE, id, title); } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; popup_win->node_inx_id = SORTID_NODE_INX; switch(id) { case JOB_PAGE: popup_win->spec_info->search_info->gchar_data = name; break; case PART_PAGE: g_free(name); gtk_tree_model_get(model, iter, SORTID_PARTITION, &name, -1); popup_win->spec_info->search_info->gchar_data = name; break; case RESV_PAGE: case NODE_PAGE: g_free(name); gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1); gtk_tree_model_get(model, iter, SORTID_SMALL_BLOCK, &i, -1); if (i) { i=0; /* strip off the ionodes part */ while (name[i]) { if (name[i] == '[') { name[i] = '\0'; break; } i++; } } popup_win->spec_info->search_info->gchar_data = name; break; case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; break; default: g_print("block got %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) { g_printerr ("Failed to create part popup thread: %s\n", error->message); return; } }
void put_chars(struct part *p, unsigned char *c, int l) { static struct text_attrib_beginning ta_cache = { -1, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; static int bg_cache; static int fg_cache; int bg, fg; int i; struct link *link; struct point *pt; if (l < 0) overalloc(); /*printf("%d-", p->cx);for (i=0; i<l; i++) printf("%c", c[i]); printf("-\n");sleep(1);*/ while (par_format.align != AL_NO && p->cx == -1 && l && *c == ' ') c++, l--; if (!l) return; if (c[0] != ' ' || (c[1] && c[1] != ' ')) { last_tag_for_newline = (void *)&p->data->tags; } if (p->cx < par_format.leftmargin) p->cx = par_format.leftmargin; if (last_link || last_image || last_form || format.link || format.image || format.form) goto process_link; no_l: /*printf("%d %d\n",p->cx, p->cy);*/ if (memcmp(&ta_cache, &format, sizeof(struct text_attrib_beginning))) goto format_change; bg = bg_cache, fg = fg_cache; end_format_change: if (p->cx == par_format.leftmargin && *c == ' ' && par_format.align != AL_NO) c++, l--; if (p->y < p->cy + 1) p->y = p->cy + 1; if (nowrap && p->cx + l > rm(par_format)) return; set_hline(p, p->cx, p->cy, l, c, (((fg&0x08)<<3)|(bg<<3)|(fg&0x07))<<8, 1); p->cx += l; nobreak = 0; if (par_format.align != AL_NO) while (p->cx > rm(par_format) && p->cx > par_format.leftmargin) { int x; /*if (p->cx > p->x) { p->x = p->cx + par_format.rightmargin; if (c[l - 1] == ' ') p->x--; }*/ if (!(x = split_line(p))) break; /*if (LEN(p->cy-1) > p->x) p->x = LEN(p->cy-1);*/ align_line(p, p->cy - 1); nobreak = x - 1; } if ((p->xa += l) - (c[l-1] == ' ' && par_format.align != AL_NO) + par_format.leftmargin + par_format.rightmargin > p->xmax) p->xmax = p->xa - (c[l-1] == ' ' && par_format.align != AL_NO) + par_format.leftmargin + par_format.rightmargin; return; process_link: if ((last_link /*|| last_target*/ || last_image || last_form) && !xstrcmp(format.link, last_link) && !xstrcmp(format.target, last_target) && !xstrcmp(format.image, last_image) && format.form == last_form) { if (!p->data) goto x; link = &p->data->links[p->data->nlinks - 1]; if (!p->data->nlinks) { internal("no link"); goto no_l; } goto set_link; x:; } else { if (last_link) mem_free(last_link); /* !!! FIXME: optimize */ if (last_target) mem_free(last_target); if (last_image) mem_free(last_image); last_link = last_target = last_image = NULL; last_form = NULL; if (!(format.link || format.image || format.form)) goto no_l; if (d_opt->num_links) { unsigned char s[64]; unsigned char *fl = format.link, *ft = format.target, *fi = format.image; struct form_control *ff = format.form; format.link = format.target = format.image = NULL; format.form = NULL; s[0] = '['; snzprint(s + 1, 62, p->link_num); strcat(s, "]"); put_chars(p, s, strlen(s)); if (ff && ff->type == FC_TEXTAREA) line_break(p); if (p->cx == -1) p->cx = par_format.leftmargin; format.link = fl, format.target = ft, format.image = fi; format.form = ff; } p->link_num++; last_link = stracpy(format.link); last_target = stracpy(format.target); last_image = stracpy(format.image); last_form = format.form; if (!p->data) goto no_l; if (!(link = new_link(p->data))) goto no_l; link->num = p->link_num - 1; link->pos = DUMMY; if (!last_form) { link->type = L_LINK; link->where = stracpy(last_link); link->target = stracpy(last_target); } else { link->type = last_form->type == FC_TEXT || last_form->type == FC_PASSWORD || last_form->type == FC_FILE ? L_FIELD : last_form->type == FC_TEXTAREA ? L_AREA : last_form->type == FC_CHECKBOX || last_form->type == FC_RADIO ? L_CHECKBOX : last_form->type == FC_SELECT ? L_SELECT : L_BUTTON; link->form = last_form; link->target = stracpy(last_form->target); } link->where_img = stracpy(last_image); if (link->type != L_FIELD && link->type != L_AREA) { bg = find_nearest_color(&format.clink, 8); fg = find_nearest_color(&format.bg, 8); fg = fg_color(fg, bg); } else { fg = find_nearest_color(&format.fg, 8); bg = find_nearest_color(&format.bg, 8); fg = fg_color(fg, bg); } link->sel_color = ((fg & 8) << 3) | (fg & 7) | (bg << 3); link->n = 0; set_link: if ((unsigned)link->n + (unsigned)l > MAXINT / sizeof(struct point)) overalloc(); pt = mem_realloc(link->pos, (link->n + l) * sizeof(struct point)); link->pos = pt; for (i = 0; i < l; i++) pt[link->n + i].x = X(p->cx) + i, pt[link->n + i].y = Y(p->cy); link->n += l; } goto no_l; format_change: bg = find_nearest_color(&format.bg, 8); fg = find_nearest_color(&format.fg, 16); fg = fg_color(fg, bg); if (format.attr & AT_ITALIC) fg = fg ^ 0x01; if (format.attr & AT_UNDERLINE) fg = (fg ^ 0x04) | 0x08; if (format.attr & AT_BOLD) fg = fg | 0x08; fg = fg_color(fg, bg); if (format.attr & AT_GRAPHICS) bg = bg | 0x10; memcpy(&ta_cache, &format, sizeof(struct text_attrib_beginning)); fg_cache = fg; bg_cache = bg; goto end_format_change; }
static int _handle_suspend(int fd, stepd_step_rec_t *job, uid_t uid) { static int launch_poe = -1; int rc = SLURM_SUCCESS; int errnum = 0; uint16_t job_core_spec = (uint16_t) NO_VAL; safe_read(fd, &job_core_spec, sizeof(uint16_t)); debug("_handle_suspend for step:%u.%u uid:%ld core_spec:%u", job->jobid, job->stepid, (long)uid, job_core_spec); if (!_slurm_authorized_user(uid)) { debug("job step suspend request from uid %ld for job %u.%u ", (long)uid, job->jobid, job->stepid); rc = -1; errnum = EPERM; goto done; } _wait_for_job_init(job); if (job->cont_id == 0) { debug ("step %u.%u invalid container [cont_id:%"PRIu64"]", job->jobid, job->stepid, job->cont_id); rc = -1; errnum = ESLURMD_JOB_NOTRUNNING; goto done; } acct_gather_suspend_poll(); if (launch_poe == -1) { char *launch_type = slurm_get_launch_type(); if (!xstrcmp(launch_type, "launch/poe")) launch_poe = 1; else launch_poe = 0; xfree(launch_type); } /* * Signal the container */ slurm_mutex_lock(&suspend_mutex); if (suspended) { rc = -1; errnum = ESLURMD_STEP_SUSPENDED; slurm_mutex_unlock(&suspend_mutex); goto done; } else { if (!job->batch && switch_g_job_step_pre_suspend(job)) error("switch_g_job_step_pre_suspend: %m"); /* SIGTSTP is sent first to let MPI daemons stop their tasks, * then wait 2 seconds, then send SIGSTOP to the spawned * process's container to stop everything else. * * In some cases, 1 second has proven insufficient. Longer * delays may help insure that all MPI tasks have been stopped * (that depends upon the MPI implementaiton used), but will * also permit longer time periods when more than one job can * be running on each resource (not good). */ if (launch_poe == 0) { /* IBM MPI seens to periodically hang upon receipt * of SIGTSTP. */ if (proctrack_g_signal(job->cont_id, SIGTSTP) < 0) { verbose("Error suspending %u.%u (SIGTSTP): %m", job->jobid, job->stepid); } else sleep(2); } if (proctrack_g_signal(job->cont_id, SIGSTOP) < 0) { verbose("Error suspending %u.%u (SIGSTOP): %m", job->jobid, job->stepid); } else { verbose("Suspended %u.%u", job->jobid, job->stepid); } suspended = true; } if (!job->batch && switch_g_job_step_post_suspend(job)) error("switch_g_job_step_post_suspend: %m"); if (!job->batch && core_spec_g_suspend(job->cont_id, job_core_spec)) error("core_spec_g_suspend: %m"); slurm_mutex_unlock(&suspend_mutex); done: /* Send the return code and errno */ safe_write(fd, &rc, sizeof(int)); safe_write(fd, &errnum, sizeof(int)); return SLURM_SUCCESS; rwfail: return SLURM_FAILURE; }