/** * @brief * status_sched - Build the status reply for single scheduler * * @param[in] psched - ptr to sched receiving status query * @param[in] preq - ptr to the decoded request * @param[out] pstathd - head of list to append status to * * @return int * @retval 0 : success * @retval !0 : PBSE error code */ static int status_sched(pbs_sched *psched, struct batch_request *preq, pbs_list_head *pstathd) { int rc = 0; struct brp_status *pstat; svrattrl *pal; pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == NULL) return (PBSE_SYSTEM); pstat->brp_objtype = MGR_OBJ_SCHED; (void)strncpy(pstat->brp_objname, psched->sc_name, (PBS_MAXSVRJOBID > PBS_MAXDEST ? PBS_MAXSVRJOBID : PBS_MAXDEST) -1); pstat->brp_objname[(PBS_MAXSVRJOBID > PBS_MAXDEST ? PBS_MAXSVRJOBID : PBS_MAXDEST) - 1] = '\0'; CLEAR_LINK(pstat->brp_stlink); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); bad = 0; pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib(pal, sched_attr_def, psched->sch_attr, SCHED_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad)) reply_badattr(PBSE_NOATTR, bad, pal, preq); return (rc); }
int status_job( job *pjob, /* ptr to job to status */ struct batch_request *preq, svrattrl *pal, /* specific attributes to status */ tlist_head *pstathd, /* RETURN: head of list to append status to */ int *bad) /* RETURN: index of first bad pbs_attribute */ { struct brp_status *pstat; int IsOwner = 0; long query_others = 0; /* see if the client is authorized to status this job */ if (svr_authorize_jobreq(preq, pjob) == 0) IsOwner = 1; get_svr_attr_l(SRV_ATR_query_others, &query_others); if (!query_others) { if (IsOwner == 0) { return(PBSE_PERM); } } /* allocate reply structure and fill in header portion */ if ((pstat = calloc(1, sizeof(struct brp_status))) == NULL) { return(PBSE_SYSTEM); } CLEAR_LINK(pstat->brp_stlink); pstat->brp_objtype = MGR_OBJ_JOB; strcpy(pstat->brp_objname, pjob->ji_qs.ji_jobid); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ *bad = 0; if (status_attrib( pal, job_attr_def, pjob->ji_wattr, JOB_ATR_LAST, preq->rq_perm, &pstat->brp_attr, bad, IsOwner)) { return(PBSE_NOATTR); } return (0); } /* END status_job() */
void req_stat_svr(struct batch_request *preq) { svrattrl *pal; struct batch_reply *preply; struct brp_status *pstat; /* update count and state counts from sv_numjobs and sv_jobstates */ server.sv_attr[(int)SRV_ATR_TotalJobs].at_val.at_long = server.sv_qs.sv_numjobs; server.sv_attr[(int)SRV_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET|ATR_VFLAG_MODCACHE; update_state_ct(&server.sv_attr[(int)SRV_ATR_JobsByState], server.sv_jobstates, server.sv_jobstbuf); update_license_ct(&server.sv_attr[(int)SRV_ATR_license_count], server.sv_license_ct_buf); /* allocate a reply structure and a status sub-structure */ preply = &preq->rq_reply; preply->brp_choice = BATCH_REPLY_CHOICE_Status; CLEAR_HEAD(preply->brp_un.brp_status); pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == NULL) { reply_free(preply); req_reject(PBSE_SYSTEM, 0, preq); return; } CLEAR_LINK(pstat->brp_stlink); (void)strcpy(pstat->brp_objname, server_name); pstat->brp_objtype = MGR_OBJ_SERVER; CLEAR_HEAD(pstat->brp_attr); append_link(&preply->brp_un.brp_status, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ bad = 0; pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib(pal, svr_attr_def, server.sv_attr, SRV_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad)) reply_badattr(PBSE_NOATTR, bad, pal, preq); else (void)reply_send(preq); }
static int status_que(pbs_queue *pque, struct batch_request *preq, pbs_list_head *pstathd) { struct brp_status *pstat; svrattrl *pal; if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0) return (PBSE_PERM); /* ok going to do status, update count and state counts from qu_qs */ if (!svr_chk_history_conf()) { pque->qu_attr[(int)QA_ATR_TotalJobs].at_val.at_long = pque->qu_numjobs; } else { pque->qu_attr[(int)QA_ATR_TotalJobs].at_val.at_long = pque->qu_numjobs - (pque->qu_njstate[JOB_STATE_MOVED] + pque->qu_njstate[JOB_STATE_FINISHED]); } pque->qu_attr[(int)QA_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET|ATR_VFLAG_MODCACHE; update_state_ct(&pque->qu_attr[(int)QA_ATR_JobsByState], pque->qu_njstate, pque->qu_jobstbuf); /* allocate status sub-structure and fill in header portion */ pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == NULL) return (PBSE_SYSTEM); pstat->brp_objtype = MGR_OBJ_QUEUE; (void)strcpy(pstat->brp_objname, pque->qu_qs.qu_name); CLEAR_LINK(pstat->brp_stlink); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ bad = 0; pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib(pal, que_attr_def, pque->qu_attr, QA_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad)) return (PBSE_NOATTR); return (0); }
static int status_resv(resc_resv *presv, struct batch_request *preq, pbs_list_head *pstathd) { struct brp_status *pstat; svrattrl *pal; if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0) return (PBSE_PERM); /*first do any need update to attributes from *"quick save" area of the resc_resv structure */ /*now allocate status sub-structure and fill header portion*/ pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == NULL) return (PBSE_SYSTEM); pstat->brp_objtype = MGR_OBJ_RESV; (void)strcpy(pstat->brp_objname, presv->ri_qs.ri_resvID); CLEAR_LINK(pstat->brp_stlink); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /*finally, add the requested attributes to the status reply*/ bad = 0; /*global: record ordinal position where got error*/ pal = (svrattrl *) GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib(pal, resv_attr_def, presv->ri_wattr, RESV_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad) == 0) return (0); else return (PBSE_NOATTR); }
int req_stat_svr( struct batch_request *preq) /* ptr to the decoded request */ { svrattrl *pal; struct batch_reply *preply; struct brp_status *pstat; int bad = 0; char nc_buf[128]; int numjobs; int netrates[3]; memset(netrates, 0, sizeof(netrates)); /* update count and state counts from sv_numjobs and sv_jobstates */ lock_sv_qs_mutex(server.sv_qs_mutex, __func__); numjobs = server.sv_qs.sv_numjobs; unlock_sv_qs_mutex(server.sv_qs_mutex, __func__); pthread_mutex_lock(server.sv_attr_mutex); server.sv_attr[SRV_ATR_TotalJobs].at_val.at_long = numjobs; server.sv_attr[SRV_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET; pthread_mutex_lock(server.sv_jobstates_mutex); update_state_ct( &server.sv_attr[SRV_ATR_JobsByState], server.sv_jobstates, server.sv_jobstbuf); pthread_mutex_unlock(server.sv_jobstates_mutex); netcounter_get(netrates); snprintf(nc_buf, 127, "%d %d %d", netrates[0], netrates[1], netrates[2]); if (server.sv_attr[SRV_ATR_NetCounter].at_val.at_str != NULL) free(server.sv_attr[SRV_ATR_NetCounter].at_val.at_str); server.sv_attr[SRV_ATR_NetCounter].at_val.at_str = strdup(nc_buf); if (server.sv_attr[SRV_ATR_NetCounter].at_val.at_str != NULL) server.sv_attr[SRV_ATR_NetCounter].at_flags |= ATR_VFLAG_SET; pthread_mutex_unlock(server.sv_attr_mutex); /* allocate a reply structure and a status sub-structure */ preply = &preq->rq_reply; preply->brp_choice = BATCH_REPLY_CHOICE_Status; CLEAR_HEAD(preply->brp_un.brp_status); pstat = (struct brp_status *)calloc(1, sizeof(struct brp_status)); if (pstat == NULL) { reply_free(preply); req_reject(PBSE_SYSTEM, 0, preq, NULL, NULL); pthread_mutex_unlock(server.sv_attr_mutex); return(PBSE_SYSTEM); } CLEAR_LINK(pstat->brp_stlink); strcpy(pstat->brp_objname, server_name); pstat->brp_objtype = MGR_OBJ_SERVER; CLEAR_HEAD(pstat->brp_attr); append_link(&preply->brp_un.brp_status, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib( pal, svr_attr_def, server.sv_attr, SRV_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad, 1)) /* IsOwner == TRUE */ { reply_badattr(PBSE_NOATTR, bad, pal, preq); } else { reply_send_svr(preq); } return(PBSE_NONE); } /* END req_stat_svr() */
static int status_que( pbs_queue *pque, /* ptr to que to status */ struct batch_request *preq, tlist_head *pstathd) /* head of list to append status to */ { struct brp_status *pstat; svrattrl *pal; int rc = PBSE_NONE; int bad = 0; if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0) { return(PBSE_PERM); } /* ok going to do status, update count and state counts from qu_qs */ pque->qu_attr[QA_ATR_TotalJobs].at_val.at_long = pque->qu_numjobs; pque->qu_attr[QA_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET; update_state_ct( &pque->qu_attr[QA_ATR_JobsByState], pque->qu_njstate, pque->qu_jobstbuf); /* allocate status sub-structure and fill in header portion */ pstat = (struct brp_status *)calloc(1, sizeof(struct brp_status)); if (pstat == NULL) { return(PBSE_SYSTEM); } memset(pstat, 0, sizeof(struct brp_status)); pstat->brp_objtype = MGR_OBJ_QUEUE; strcpy(pstat->brp_objname, pque->qu_qs.qu_name); CLEAR_LINK(pstat->brp_stlink); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if ((rc = status_attrib( pal, que_attr_def, pque->qu_attr, QA_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad, 1)) != PBSE_NONE) /* IsOwner == TRUE */ { return(rc); } return(PBSE_NONE); } /* END status_que() */
int status_job( job *pjob, /* ptr to job to status */ batch_request *preq, svrattrl *pal, /* specific attributes to status */ tlist_head *pstathd, /* RETURN: head of list to append status to */ bool condensed, int *bad) /* RETURN: index of first bad pbs_attribute */ { struct brp_status *pstat; int IsOwner = 0; long query_others = 0; long condensed_timeout = JOB_CONDENSED_TIMEOUT; /* Make sure procct is removed from the job resource attributes */ remove_procct(pjob); /* see if the client is authorized to status this job */ if (svr_authorize_jobreq(preq, pjob) == 0) IsOwner = 1; get_svr_attr_l(SRV_ATR_query_others, &query_others); if (!query_others) { if (IsOwner == 0) { return(PBSE_PERM); } } get_svr_attr_l(SRV_ATR_job_full_report_time, &condensed_timeout); // if the job has been modified within the timeout, send the full output if ((condensed == true) && (time(NULL) < pjob->ji_mod_time + condensed_timeout)) condensed = false; /* allocate reply structure and fill in header portion */ if ((pstat = (struct brp_status *)calloc(1, sizeof(struct brp_status))) == NULL) { return(PBSE_SYSTEM); } CLEAR_LINK(pstat->brp_stlink); pstat->brp_objtype = MGR_OBJ_JOB; strcpy(pstat->brp_objname, pjob->ji_qs.ji_jobid); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ *bad = 0; if (status_attrib( pal, job_attr_def, pjob->ji_wattr, JOB_ATR_LAST, preq->rq_perm, &pstat->brp_attr, condensed, bad, IsOwner)) { return(PBSE_NOATTR); } return (0); } /* END status_job() */
/** * @brief * status_subjob - status a single subjob (of an Array Job) * Works by statusing the parrent unless subjob is actually running. * * @param[in,out] pjob - ptr to parent Array * @param[in] preq - request structure * @param[in] pal - specific attributes to status * @param[in] subj - if not = -1 then include subjob [n] * @param[in,out] pstathd - RETURN: head of list to append status to * @param[out] bad - RETURN: index of first bad attribute * * @return int * @retval 0 : success * @retval PBSE_PERM : client is not authorized to status the job * @retval PBSE_SYSTEM : memory allocation error * @retval PBSE_IVALREQ : something wrong with the flags */ int status_subjob(job *pjob, struct batch_request *preq, svrattrl *pal, int subj, pbs_list_head *pstathd, int *bad) { int limit = (int)JOB_ATR_LAST; struct brp_status *pstat; job *psubjob; /* ptr to job to status */ char realstate; int rc = 0; int oldeligflags = 0; int oldatypflags = 0; int subjob_state = -1; char *old_subjob_comment = NULL; /* see if the client is authorized to status this job */ if (! server.sv_attr[(int)SRV_ATR_query_others].at_val.at_long) if (svr_authorize_jobreq(preq, pjob)) return (PBSE_PERM); if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_ArrayJob) == 0) return PBSE_IVALREQ; /* if subjob is running, use real job structure */ if (get_subjob_state(pjob, subj) == JOB_STATE_RUNNING) { psubjob = find_job(mk_subjob_id(pjob, subj)); if (psubjob) status_job(psubjob, preq, pal, pstathd, bad); return 0; } /* otherwise we fake it with info from the parent */ /* allocate reply structure and fill in header portion */ /* for the general case, we don't want to include the parent's */ /* array related attrbutes as they belong only to the Array */ if (pal == NULL) limit = JOB_ATR_array; pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == (struct brp_status *)0) return (PBSE_SYSTEM); CLEAR_LINK(pstat->brp_stlink); pstat->brp_objtype = MGR_OBJ_JOB; (void)strcpy(pstat->brp_objname, mk_subjob_id(pjob, subj)); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ *bad = 0; /* * fake the job state and comment by setting the parent job's state * and comment to that of the subjob */ subjob_state = get_subjob_state(pjob, subj); realstate = pjob->ji_wattr[(int)JOB_ATR_state].at_val.at_char; pjob->ji_wattr[(int)JOB_ATR_state].at_val.at_char = statechars[subjob_state]; pjob->ji_wattr[(int)JOB_ATR_state].at_flags |= ATR_VFLAG_MODCACHE; if (subjob_state == JOB_STATE_EXPIRED || subjob_state == JOB_STATE_FINISHED) { if (pjob->ji_ajtrk->tkm_tbl[subj].trk_substate == JOB_SUBSTATE_FINISHED) { if (pjob->ji_wattr[(int)JOB_ATR_Comment].at_flags & ATR_VFLAG_SET) { old_subjob_comment = strdup(pjob->ji_wattr[(int)JOB_ATR_Comment].at_val.at_str); if (old_subjob_comment == (char *)0) return (PBSE_SYSTEM); } if (job_attr_def[(int)JOB_ATR_Comment].at_decode(&pjob->ji_wattr[(int)JOB_ATR_Comment], (char *)0, (char *)0, "Subjob finished") == PBSE_SYSTEM) { free(old_subjob_comment); return (PBSE_SYSTEM); } } else if (pjob->ji_ajtrk->tkm_tbl[subj].trk_substate == JOB_SUBSTATE_FAILED) { if (pjob->ji_wattr[(int)JOB_ATR_Comment].at_flags & ATR_VFLAG_SET) { old_subjob_comment = strdup(pjob->ji_wattr[(int)JOB_ATR_Comment].at_val.at_str); if (old_subjob_comment == (char *)0) return (PBSE_SYSTEM); } if (job_attr_def[(int)JOB_ATR_Comment].at_decode(&pjob->ji_wattr[(int)JOB_ATR_Comment], (char *)0, (char *)0, "Subjob failed") == PBSE_SYSTEM) { free(old_subjob_comment); return (PBSE_SYSTEM); } } else if (pjob->ji_ajtrk->tkm_tbl[subj].trk_substate == JOB_SUBSTATE_TERMINATED) { if (pjob->ji_wattr[(int)JOB_ATR_Comment].at_flags & ATR_VFLAG_SET) { old_subjob_comment = strdup(pjob->ji_wattr[(int)JOB_ATR_Comment].at_val.at_str); if (old_subjob_comment == (char *)0) return (PBSE_SYSTEM); } if (job_attr_def[(int)JOB_ATR_Comment].at_decode(&pjob->ji_wattr[(int)JOB_ATR_Comment], (char *)0, (char *)0, "Subjob terminated") == PBSE_SYSTEM) { free(old_subjob_comment); return (PBSE_SYSTEM); } } } /* when eligible_time_enable is off, */ /* clear the set flag so that eligible_time and accrue_type dont show */ if (server.sv_attr[(int)SRV_ATR_EligibleTimeEnable].at_val.at_long == 0) { oldeligflags = pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags &= ~ATR_VFLAG_SET; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags |= ATR_VFLAG_MODCACHE; oldatypflags = pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags &= ~ATR_VFLAG_SET; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags |= ATR_VFLAG_MODCACHE; /* Note: ATR_VFLAG_MODCACHE must be set because of svr_cached() does */ /* not correctly check ATR_VFLAG_SET */ } if (status_attrib(pal, job_attr_def, pjob->ji_wattr, limit, preq->rq_perm, &pstat->brp_attr, bad)) rc = PBSE_NOATTR; /* Set the parent state back to what it really is */ pjob->ji_wattr[(int)JOB_ATR_state].at_val.at_char = realstate; pjob->ji_wattr[(int)JOB_ATR_state].at_flags |= ATR_VFLAG_MODCACHE; /* Set the parent comment back to what it really is */ if (old_subjob_comment != NULL) { if (job_attr_def[(int)JOB_ATR_Comment].at_decode(&pjob->ji_wattr[(int)JOB_ATR_Comment], (char *)0, (char *)0, old_subjob_comment) == PBSE_SYSTEM) { free(old_subjob_comment); return (PBSE_SYSTEM); } free(old_subjob_comment); } /* reset the flags */ if (server.sv_attr[(int)SRV_ATR_EligibleTimeEnable].at_val.at_long == 0) { pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags = oldeligflags; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags = oldatypflags; } return (rc); }
int status_job(job *pjob, struct batch_request *preq, svrattrl *pal, pbs_list_head *pstathd, int *bad) { struct brp_status *pstat; time_t tm; long oldtime = 0; int old_elig_flags = 0; int old_atyp_flags = 0; /* see if the client is authorized to status this job */ if (! server.sv_attr[(int)SRV_ATR_query_others].at_val.at_long) if (svr_authorize_jobreq(preq, pjob)) return (PBSE_PERM); if (pjob->ji_qs.ji_svrflags & JOB_SVFLG_ArrayJob) { /* for Array Job, if array_indices_remaining is modified */ /* then need to recalculate the string value */ char *pnewstr; attribute *premain; premain = &pjob->ji_wattr[(int)JOB_ATR_array_indices_remaining]; if (premain->at_flags & ATR_VFLAG_MODCACHE) { pnewstr = cvt_range(pjob->ji_ajtrk, JOB_STATE_QUEUED); if (pnewstr == NULL) pnewstr = "-"; job_attr_def[JOB_ATR_array_indices_remaining].at_free(premain); job_attr_def[JOB_ATR_array_indices_remaining].at_decode(premain, 0, 0, pnewstr); /* also update value of attribute "array_state_count" */ update_subjob_state_ct(pjob); } } /* calc eligible time on the fly and return, don't save. */ if (server.sv_attr[(int)SRV_ATR_EligibleTimeEnable].at_val.at_long != 0) { if (pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_val.at_long == JOB_ELIGIBLE) { time(&tm); oldtime = pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_val.at_long; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_val.at_long += ((long)tm - pjob->ji_wattr[(int)JOB_ATR_sample_starttime].at_val.at_long); pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags |= ATR_VFLAG_MODCACHE; /* Note: ATR_VFLAG_MODCACHE must be set because of svr_cached() does */ /* not correctly check ATR_VFLAG_SET */ } } else { /* eligible_time_enable is off so, */ /* clear set flag so that eligible_time and accrue type dont show */ old_elig_flags = pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags &= ~ATR_VFLAG_SET; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags |= (ATR_VFLAG_MODCACHE); old_atyp_flags = pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags &= ~ATR_VFLAG_SET; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags |= (ATR_VFLAG_MODCACHE); /* Note: ATR_VFLAG_MODCACHE must be set because of svr_cached() does */ /* not correctly check ATR_VFLAG_SET */ } /* allocate reply structure and fill in header portion */ pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == (struct brp_status *)0) return (PBSE_SYSTEM); CLEAR_LINK(pstat->brp_stlink); pstat->brp_objtype = MGR_OBJ_JOB; (void)strcpy(pstat->brp_objname, pjob->ji_qs.ji_jobid); CLEAR_HEAD(pstat->brp_attr); append_link(pstathd, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ *bad = 0; if (status_attrib(pal, job_attr_def, pjob->ji_wattr, JOB_ATR_LAST, preq->rq_perm, &pstat->brp_attr, bad)) return (PBSE_NOATTR); /* reset eligible time, it was calctd on the fly, real calctn only when accrue_type changes */ if (server.sv_attr[(int)SRV_ATR_EligibleTimeEnable].at_val.at_long != 0) { if (pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_val.at_long == JOB_ELIGIBLE) { pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_val.at_long = oldtime; pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags |= ATR_VFLAG_MODCACHE; /* Note: ATR_VFLAG_MODCACHE must be set because of svr_cached() does */ /* not correctly check ATR_VFLAG_SET */ } } else { /* reset the set flags */ pjob->ji_wattr[(int)JOB_ATR_eligible_time].at_flags = old_elig_flags; pjob->ji_wattr[(int)JOB_ATR_accrue_type].at_flags = old_atyp_flags; } return (0); }
void req_stat_svr( struct batch_request *preq) /* ptr to the decoded request */ { svrattrl *pal; struct batch_reply *preply; struct brp_status *pstat; int *nc; static char nc_buf[128]; /* update count and state counts from sv_numjobs and sv_jobstates */ server.sv_attr[(int)SRV_ATR_TotalJobs].at_val.at_long = server.sv_qs.sv_numjobs; server.sv_attr[(int)SRV_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET; update_state_ct( &server.sv_attr[(int)SRV_ATR_JobsByState], server.sv_jobstates, server.sv_jobstbuf); nc = netcounter_get(); sprintf(nc_buf, "%d %d %d", *nc, *(nc + 1), *(nc + 2)); server.sv_attr[(int)SRV_ATR_NetCounter].at_val.at_str = nc_buf; server.sv_attr[(int)SRV_ATR_NetCounter].at_flags |= ATR_VFLAG_SET; /* allocate a reply structure and a status sub-structure */ preply = &preq->rq_reply; preply->brp_choice = BATCH_REPLY_CHOICE_Status; CLEAR_HEAD(preply->brp_un.brp_status); pstat = (struct brp_status *)malloc(sizeof(struct brp_status)); if (pstat == NULL) { reply_free(preply); req_reject(PBSE_SYSTEM, 0, preq, NULL, NULL); return; } CLEAR_LINK(pstat->brp_stlink); strcpy(pstat->brp_objname, server_name); pstat->brp_objtype = MGR_OBJ_SERVER; CLEAR_HEAD(pstat->brp_attr); append_link(&preply->brp_un.brp_status, &pstat->brp_stlink, pstat); /* add attributes to the status reply */ bad = 0; pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr); if (status_attrib( pal, svr_attr_def, server.sv_attr, SRV_ATR_LAST, preq->rq_perm, &pstat->brp_attr, &bad, 1)) /* IsOwner == TRUE */ { reply_badattr(PBSE_NOATTR, bad, pal, preq); } else { reply_send(preq); } return; } /* END req_stat_svr() */