void dispatch_request(int sfds, struct batch_request *request) { conn_t *conn = NULL; int rpp = request->isrpp; if (!rpp) { if (sfds != PBS_LOCAL_CONNECTION) { conn = get_conn(sfds); if (!conn) { log_event(PBSEVENT_SYSTEM, PBS_EVENTCLASS_REQUEST, LOG_ERR, "dispatch_request", "did not find socket in connection table"); req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } } } switch (request->rq_type) { case PBS_BATCH_QueueJob: if (rpp) { request->rpp_ack = 0; rpp_add_close_func(sfds, close_quejob); } else net_add_close_func(sfds, close_quejob); req_quejob(request); break; case PBS_BATCH_JobCred: #ifndef PBS_MOM /* Reject if a user client (qsub -Wpwd) and not a */ /* server (qmove) enqueued a job with JobCredential */ if ( !request->rq_fromsvr && \ (server.sv_attr[SRV_ATR_ssignon_enable].at_flags \ & ATR_VFLAG_SET) && \ (server.sv_attr[SRV_ATR_ssignon_enable].at_val.at_long == 1) ) { req_reject(PBSE_SSIGNON_SET_REJECT, 0, request); close_client(sfds); break; } #endif if (rpp) request->rpp_ack = 0; req_jobcredential(request); break; case PBS_BATCH_UserCred: #ifdef PBS_MOM #ifdef WIN32 req_reject(PBSE_NOSUP, 0, request); #else req_reject(PBSE_UNKREQ, 0, request); #endif close_client(sfds); #else req_usercredential(request); #endif break; case PBS_BATCH_UserMigrate: #ifdef PBS_MOM #ifdef WIN32 req_reject(PBSE_NOSUP, 0, request); #else req_reject(PBSE_UNKREQ, 0, request); #endif /* WIN32 */ close_client(sfds); #else req_user_migrate(request); #endif /* PBS_MOM */ break; case PBS_BATCH_GSS_Context: req_gsscontext(request); break; case PBS_BATCH_jobscript: if (rpp) request->rpp_ack = 0; req_jobscript(request); break; /* * The PBS_BATCH_Rdytocommit message is deprecated. * The server does not do anything with it anymore, but * simply acks the request (in case some client makes this call) */ case PBS_BATCH_RdytoCommit: if (request->isrpp) request->rpp_ack = 0; reply_ack(request); break; case PBS_BATCH_Commit: if (rpp) request->rpp_ack = 0; req_commit(request); if (rpp) rpp_add_close_func(sfds, (void (*)(int))0); else net_add_close_func(sfds, (void (*)(int))0); break; case PBS_BATCH_DeleteJob: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_delete.rq_objname, "delete job request received"); req_deletejob(request); break; #ifndef PBS_MOM case PBS_BATCH_SubmitResv: req_resvSub(request); break; case PBS_BATCH_DeleteResv: req_deleteReservation(request); break; case PBS_BATCH_ModifyResv: req_modifyReservation(request); break; case PBS_BATCH_ResvOccurEnd: req_reservationOccurrenceEnd(request); break; #endif case PBS_BATCH_HoldJob: if (sfds != PBS_LOCAL_CONNECTION && !rpp) conn->cn_authen |= PBS_NET_CONN_NOTIMEOUT; req_holdjob(request); break; #ifndef PBS_MOM case PBS_BATCH_LocateJob: req_locatejob(request); break; case PBS_BATCH_Manager: req_manager(request); break; case PBS_BATCH_RelnodesJob: req_relnodesjob(request); break; #endif case PBS_BATCH_MessJob: req_messagejob(request); break; case PBS_BATCH_PySpawn: if (sfds != PBS_LOCAL_CONNECTION && !rpp) conn->cn_authen |= PBS_NET_CONN_NOTIMEOUT; req_py_spawn(request); break; case PBS_BATCH_ModifyJob: req_modifyjob(request); break; case PBS_BATCH_Rerun: req_rerunjob(request); break; #ifndef PBS_MOM case PBS_BATCH_MoveJob: req_movejob(request); break; case PBS_BATCH_OrderJob: req_orderjob(request); break; case PBS_BATCH_Rescq: req_reject(PBSE_NOSUP, 0, request); break; case PBS_BATCH_ReserveResc: req_reject(PBSE_NOSUP, 0, request); break; case PBS_BATCH_ReleaseResc: req_reject(PBSE_NOSUP, 0, request); break; case PBS_BATCH_ReleaseJob: if (sfds != PBS_LOCAL_CONNECTION && !rpp) conn->cn_authen |= PBS_NET_CONN_NOTIMEOUT; req_releasejob(request); break; case PBS_BATCH_RunJob: case PBS_BATCH_AsyrunJob: req_runjob(request); break; case PBS_BATCH_DefSchReply: req_defschedreply(request); break; case PBS_BATCH_ConfirmResv: req_confirmresv(request); break; case PBS_BATCH_SelectJobs: case PBS_BATCH_SelStat: req_selectjobs(request); break; #endif /* !PBS_MOM */ case PBS_BATCH_Shutdown: req_shutdown(request); break; case PBS_BATCH_SignalJob: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_signal.rq_jid, "signal job request received"); req_signaljob(request); break; case PBS_BATCH_MvJobFile: req_mvjobfile(request); break; #ifndef PBS_MOM /* Server Only Functions */ case PBS_BATCH_StatusJob: if (set_to_non_blocking(conn) == -1) { req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } req_stat_job(request); clear_non_blocking(conn); break; case PBS_BATCH_StatusQue: if (set_to_non_blocking(conn) == -1) { req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } req_stat_que(request); clear_non_blocking(conn); break; case PBS_BATCH_StatusNode: if (set_to_non_blocking(conn) == -1) { req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } req_stat_node(request); clear_non_blocking(conn); break; case PBS_BATCH_StatusResv: if (set_to_non_blocking(conn) == -1) { req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } req_stat_resv(request); clear_non_blocking(conn); break; case PBS_BATCH_StatusSvr: req_stat_svr(request); break; case PBS_BATCH_StatusSched: req_stat_sched(request); break; case PBS_BATCH_StatusHook: if (!is_local_root(request->rq_user, request->rq_host)) { sprintf(log_buffer, "%s@%s is unauthorized to " "access hooks data from server %s", request->rq_user, request->rq_host, server_host); reply_text(request, PBSE_HOOKERROR, log_buffer); log_event(PBSEVENT_ADMIN, PBS_EVENTCLASS_HOOK, LOG_INFO, "", log_buffer); /* don't call close_client() to allow other */ /* non-hook related requests to continue */ break; } if (set_to_non_blocking(conn) == -1) { req_reject(PBSE_SYSTEM, 0, request); close_client(sfds); return; } req_stat_hook(request); clear_non_blocking(conn); break; case PBS_BATCH_TrackJob: req_track(request); break; case PBS_BATCH_RegistDep: req_register(request); break; case PBS_BATCH_AuthenResvPort: if (pbs_conf.auth_method == AUTH_MUNGE) { req_reject(PBSE_BADCRED, 0, request); close_client(sfds); return; } req_authenResvPort(request); break; case PBS_BATCH_StageIn: req_stagein(request); break; case PBS_BATCH_FailOver: req_failover(request); break; case PBS_BATCH_StatusRsc: req_stat_resc(request); break; case PBS_BATCH_MomRestart: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_NODE, LOG_INFO, request->rq_ind.rq_momrestart.rq_momhost, "Mom restarted on host"); req_momrestart(request); break; #else /* MOM only functions */ case PBS_BATCH_CopyFiles: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_cpyfile.rq_jobid, "copy file request received"); /* don't time-out as copy may take long time */ if (sfds != PBS_LOCAL_CONNECTION && !rpp) conn->cn_authen |= PBS_NET_CONN_NOTIMEOUT; req_cpyfile(request); break; case PBS_BATCH_CopyFiles_Cred: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_cpyfile_cred.rq_copyfile.rq_jobid, "copy file cred request received"); /* don't time-out as copy may take long time */ if (sfds != PBS_LOCAL_CONNECTION && !rpp) conn->cn_authen |= PBS_NET_CONN_NOTIMEOUT; req_cpyfile(request); break; case PBS_BATCH_DelFiles: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_cpyfile.rq_jobid, "delete file request received"); req_delfile(request); break; case PBS_BATCH_DelFiles_Cred: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB, LOG_INFO, request->rq_ind.rq_cpyfile_cred.rq_copyfile.rq_jobid, "delete file cred request received"); req_delfile(request); break; case PBS_BATCH_CopyHookFile: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_HOOK, LOG_INFO, request->rq_ind.rq_hookfile.rq_filename, "copy hook-related file request received"); req_copy_hookfile(request); break; case PBS_BATCH_DelHookFile: log_event(PBSEVENT_DEBUG, PBS_EVENTCLASS_HOOK, LOG_INFO, request->rq_ind.rq_hookfile.rq_filename, "delete hook-related file request received"); req_del_hookfile(request); break; #endif default: req_reject(PBSE_UNKREQ, 0, request); close_client(sfds); break; } return; }
void dispatch_request( int sfds, /* I */ struct batch_request *request) /* I */ { char *id = "dispatch_request"; if (LOGLEVEL >= 5) { sprintf(log_buffer,"dispatching request %s on sd=%d", reqtype_to_txt(request->rq_type), sfds); log_record( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, id, log_buffer); } switch (request->rq_type) { case PBS_BATCH_QueueJob: net_add_close_func(sfds, close_quejob); req_quejob(request); break; case PBS_BATCH_JobCred: req_jobcredential(request); break; case PBS_BATCH_jobscript: req_jobscript(request); break; case PBS_BATCH_RdytoCommit: req_rdytocommit(request); break; case PBS_BATCH_Commit: req_commit(request); net_add_close_func(sfds, (void (*)())0); break; case PBS_BATCH_DeleteJob: #ifdef PBS_MOM req_deletejob(request); #else /* if this is a server size job delete request, then the request could also be * for an entire array. we check to see if the request object name is an array id. * if so we hand off the the req_deletearray() function. If not we pass along to the * normal req_deltejob() function. */ if (is_array(request->rq_ind.rq_delete.rq_objname)) { req_deletearray(request); } else { req_deletejob(request); } #endif break; case PBS_BATCH_HoldJob: #ifdef PBS_MOM req_holdjob(request); #else if (is_array(request->rq_ind.rq_hold.rq_orig.rq_objname)) { req_holdarray(request); } else { req_holdjob(request); } #endif break; case PBS_BATCH_CheckpointJob: req_checkpointjob(request); break; #ifndef PBS_MOM case PBS_BATCH_LocateJob: req_locatejob(request); break; case PBS_BATCH_Manager: req_manager(request); break; #endif /* END !PBS_MOM */ case PBS_BATCH_MessJob: req_messagejob(request); break; case PBS_BATCH_AsyModifyJob: case PBS_BATCH_ModifyJob: #ifndef PBS_MOM if (is_array(request->rq_ind.rq_delete.rq_objname)) { req_modifyarray(request); } else { req_modifyjob(request); } #else /* END ifndef PBS_MOM */ req_modifyjob(request); #endif /* PBS_MOM */ break; case PBS_BATCH_Rerun: req_rerunjob(request); break; #ifndef PBS_MOM case PBS_BATCH_MoveJob: req_movejob(request); break; case PBS_BATCH_OrderJob: req_orderjob(request); break; case PBS_BATCH_Rescq: req_rescq(request); break; case PBS_BATCH_ReserveResc: req_rescreserve(request); break; case PBS_BATCH_ReleaseResc: req_rescfree(request); break; case PBS_BATCH_ReleaseJob: if (is_array(request->rq_ind.rq_delete.rq_objname)) { req_releasearray(request); } else { req_releasejob(request); } break; case PBS_BATCH_RunJob: case PBS_BATCH_AsyrunJob: req_runjob(request); break; case PBS_BATCH_SelectJobs: case PBS_BATCH_SelStat: /* handle special 'truncated' keyword */ if (!strncasecmp(request->rq_ind.rq_status.rq_id, "truncated", strlen("truncated"))) req_stat_job(request); else req_selectjobs(request); break; #endif /* !PBS_MOM */ case PBS_BATCH_Shutdown: req_shutdown(request); break; case PBS_BATCH_SignalJob: case PBS_BATCH_AsySignalJob: req_signaljob(request); break; case PBS_BATCH_GpuCtrl: req_gpuctrl(request); break; case PBS_BATCH_StatusJob: req_stat_job(request); break; case PBS_BATCH_MvJobFile: req_mvjobfile(request); break; #ifndef PBS_MOM /* server only functions */ case PBS_BATCH_StatusQue: req_stat_que(request); break; case PBS_BATCH_StatusNode: req_stat_node(request); break; case PBS_BATCH_StatusSvr: req_stat_svr(request); break; /* DIAGTODO: handle PBS_BATCH_StatusDiag and define req_stat_diag() */ case PBS_BATCH_TrackJob: req_track(request); break; case PBS_BATCH_RegistDep: if (is_array(request->rq_ind.rq_register.rq_parent)) { req_registerarray(request); } else { req_register(request); } break; case PBS_BATCH_AuthenUser: /* determine if user is valid */ req_authenuser(request); break; case PBS_BATCH_AltAuthenUser: break; case PBS_BATCH_JobObit: req_jobobit(request); break; case PBS_BATCH_StageIn: req_stagein(request); break; #else /* MOM only functions */ case PBS_BATCH_ReturnFiles: req_returnfiles(request); break; case PBS_BATCH_CopyFiles: req_cpyfile(request); break; case PBS_BATCH_DelFiles: req_delfile(request); break; #endif /* !PBS_MOM */ default: req_reject(PBSE_UNKREQ, 0, request, NULL, NULL); close_client(sfds); break; } /* END switch (request->rq_type) */ return; } /* END dispatch_request() */
int dispatch_request( int sfds, /* I */ struct batch_request *request) /* I */ { int rc = PBSE_NONE; char log_buf[LOCAL_LOG_BUF_SIZE]; char *job_id = NULL; if (LOGLEVEL >= 5) { sprintf(log_buf,"dispatching request %s on sd=%d", reqtype_to_txt(request->rq_type), sfds); log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); } switch (request->rq_type) { case PBS_BATCH_QueueJob: rc = req_quejob(request, &job_id); if ((rc != PBSE_NONE) && (job_id != NULL)) close_quejob_by_jobid(job_id); if (job_id != NULL) free(job_id); break; case PBS_BATCH_JobCred: rc = req_jobcredential(request); break; case PBS_BATCH_jobscript: job_id = strdup(request->rq_ind.rq_jobfile.rq_jobid); rc = req_jobscript(request); if ((rc != PBSE_NONE) && (job_id != NULL)) close_quejob_by_jobid(job_id); if (job_id != NULL) free(job_id); break; case PBS_BATCH_RdytoCommit: job_id = strdup(request->rq_ind.rq_rdytocommit); rc = req_rdytocommit(request); if ((rc != PBSE_NONE) && (job_id != NULL)) close_quejob_by_jobid(job_id); if (job_id != NULL) free(job_id); break; case PBS_BATCH_Commit: job_id = strdup(request->rq_ind.rq_commit); rc = req_commit(request); if ((rc != PBSE_NONE) && (job_id != NULL)) close_quejob_by_jobid(job_id); if (job_id != NULL) free(job_id); break; case PBS_BATCH_DeleteJob: /* if this is a server size job delete request, then the request * could also be for an entire array. we check to see if the * request object name is an array id. If so we hand off the the * req_deletearray() function. If not we pass along to the normal * req_deletejob() function. */ if (is_array(request->rq_ind.rq_delete.rq_objname)) rc = req_deletearray(request); else rc = req_deletejob(request); break; case PBS_BATCH_HoldJob: if (is_array(request->rq_ind.rq_hold.rq_orig.rq_objname)) rc = req_holdarray(request); else rc = req_holdjob(request); break; case PBS_BATCH_CheckpointJob: rc = req_checkpointjob(request); break; case PBS_BATCH_LocateJob: rc = req_locatejob(request); break; case PBS_BATCH_Manager: rc = req_manager(request); break; case PBS_BATCH_MessJob: rc = req_messagejob(request); break; case PBS_BATCH_AsyModifyJob: case PBS_BATCH_ModifyJob: if (is_array(request->rq_ind.rq_delete.rq_objname)) rc = req_modifyarray(request); else req_modifyjob(request); break; case PBS_BATCH_Rerun: rc = req_rerunjob(request); break; case PBS_BATCH_MoveJob: rc = req_movejob(request); break; case PBS_BATCH_OrderJob: rc = req_orderjob(request); break; case PBS_BATCH_Rescq: rc = req_rescq(request); break; case PBS_BATCH_ReserveResc: rc = req_rescreserve(request); break; case PBS_BATCH_ReleaseResc: rc = req_rescfree(request); break; case PBS_BATCH_ReleaseJob: if (is_array(request->rq_ind.rq_delete.rq_objname)) rc = req_releasearray(request); else rc = req_releasejob(request); break; case PBS_BATCH_RunJob: case PBS_BATCH_AsyrunJob: globalset_del_sock(request->rq_conn); rc = req_runjob(request); break; case PBS_BATCH_SelectJobs: case PBS_BATCH_SelStat: /* handle special 'truncated' keyword */ if (!strncasecmp(request->rq_ind.rq_status.rq_id, "truncated", strlen("truncated"))) rc =req_stat_job(request); else rc = req_selectjobs(request); break; case PBS_BATCH_Shutdown: req_shutdown(request); break; case PBS_BATCH_SignalJob: case PBS_BATCH_AsySignalJob: rc = req_signaljob(request); break; case PBS_BATCH_GpuCtrl: rc = req_gpuctrl_svr(request); break; case PBS_BATCH_MvJobFile: rc = req_mvjobfile(request); break; case PBS_BATCH_StatusQue: rc = req_stat_que(request); break; case PBS_BATCH_StatusNode: rc = req_stat_node(request); break; case PBS_BATCH_StatusSvr: rc = req_stat_svr(request); break; /* DIAGTODO: handle PBS_BATCH_StatusDiag and define req_stat_diag() */ case PBS_BATCH_TrackJob: rc = req_track(request); break; case PBS_BATCH_RegistDep: if (is_array(request->rq_ind.rq_register.rq_parent)) { rc = req_registerarray(request); } else { rc = req_register(request); } break; case PBS_BATCH_AuthenUser: /* determine if user is valid */ rc = req_authenuser( request); break; case PBS_BATCH_AltAuthenUser: break; case PBS_BATCH_JobObit: rc = req_jobobit(request); break; case PBS_BATCH_StageIn: rc = req_stagein(request); break; case PBS_BATCH_StatusJob: rc = req_stat_job(request); break; default: req_reject(PBSE_UNKREQ, 0, request, NULL, NULL); if (sfds != PBS_LOCAL_CONNECTION) close_conn(sfds, FALSE); break; } /* END switch (request->rq_type) */ return(rc); } /* END dispatch_request() */
void mom_dispatch_request( int sfds, /* I */ struct batch_request *request) /* I */ { if (LOGLEVEL >= 5) { sprintf(log_buffer,"dispatching request %s on sd=%d", reqtype_to_txt(request->rq_type), sfds); log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buffer); } switch (request->rq_type) { case PBS_BATCH_QueueJob: net_add_close_func(sfds, close_quejob); req_quejob(request); break; case PBS_BATCH_JobCred: req_jobcredential(request); break; case PBS_BATCH_jobscript: req_jobscript(request); break; case PBS_BATCH_RdytoCommit: req_rdytocommit(request); break; case PBS_BATCH_Commit: req_commit(request); net_add_close_func(sfds, NULL); break; case PBS_BATCH_DeleteJob: req_deletejob(request); break; case PBS_BATCH_HoldJob: mom_req_holdjob(request); break; case PBS_BATCH_CheckpointJob: req_checkpointjob(request); break; case PBS_BATCH_MessJob: req_messagejob(request); break; case PBS_BATCH_AsyModifyJob: case PBS_BATCH_ModifyJob: req_modifyjob(request); break; case PBS_BATCH_Rerun: req_rerunjob(request); break; case PBS_BATCH_Shutdown: req_shutdown(request); break; case PBS_BATCH_SignalJob: case PBS_BATCH_AsySignalJob: req_signaljob(request); break; case PBS_BATCH_MvJobFile: req_mvjobfile(request); break; case PBS_BATCH_StatusJob: req_stat_job(request); break; case PBS_BATCH_ReturnFiles: req_returnfiles(request); break; case PBS_BATCH_CopyFiles: req_cpyfile(request); break; case PBS_BATCH_DelFiles: req_delfile(request); break; case PBS_BATCH_DeleteReservation: req_delete_reservation(request); break; default: req_reject(PBSE_UNKREQ, 0, request, NULL, NULL); mom_close_client(sfds); break; } /* END switch (request->rq_type) */ return; } /* END dispatch_request() */