static bool sge_env_state_setup(sge_env_state_class_t *thiz, const char *sge_root, const char *sge_cell, u_long32 sge_qmaster_port, u_long32 sge_execd_port, bool from_services, bool qmaster_internal, sge_error_class_t *eh) { DENTER(TOP_LAYER, "sge_env_state_setup"); thiz->set_sge_qmaster_port(thiz, sge_qmaster_port); thiz->set_sge_execd_port(thiz, sge_execd_port); thiz->set_sge_root(thiz, sge_root); thiz->set_sge_cell(thiz, sge_cell); set_from_services(thiz, from_services); set_qmaster_internal(thiz, qmaster_internal); /*thiz->dprintf(thiz);*/ DEXIT; return true; }
/****** uti/thread_ctrl/sge_thread_wait_for_signal() *************************** * NAME * sge_thread_wait_for_signal() -- block current thread till shutdown * * SYNOPSIS * void sge_thread_wait_for_signal(void) * * FUNCTION * A call of this function will block the executing thread until the * shutdown of the process is triggered via sge_thread_notify_all_waiting() * * INPUTS * void - NONE * * RESULT * void - NONE * * NOTES * MT-NOTE: sge_thread_wait_for_signal() is not MT safe * * SEE ALSO * uti/thread_ctrl/sge_thread_notify_all_waiting() *******************************************************************************/ void sge_thread_wait_for_signal(void) { DENTER(THREAD_LAYER, "sge_thread_wait_for_signal"); sge_mutex_lock(THREAD_CONTROL_MUTEX, SGE_FUNC, __LINE__, &Thread_Control.mutex); while (Thread_Control.shutdown_started == false) { pthread_cond_wait(&Thread_Control.cond_var, &Thread_Control.mutex); } sge_mutex_unlock(THREAD_CONTROL_MUTEX, SGE_FUNC, __LINE__, &Thread_Control.mutex); DEXIT; return; }
/****** test_sge_lock_simple/thread_function() ********************************* * NAME * thread_function() -- Thread function to execute * * SYNOPSIS * static void* thread_function(void *anArg) * * FUNCTION * Lock the global lock in read mode and sleep. Unlock the global lock. * * INPUTS * void *anArg - thread function arguments * * RESULT * static void* - none * * SEE ALSO * test_sge_lock_simple/get_thrd_func() *******************************************************************************/ static void *thread_function(void *anArg) { DENTER(TOP_LAYER, "thread_function"); SGE_LOCK(LOCK_GLOBAL, LOCK_READ); #if 1 DPRINTF(("Thread %u sleeping at %d\n", sge_locker_id(), sge_get_gmt())); #endif sleep(5); SGE_UNLOCK(LOCK_GLOBAL, LOCK_READ); DEXIT; return (void *)NULL; } /* thread_function */
void sge_signaler_initialize(sge_gdi_ctx_class_t *ctx) { cl_thread_settings_t* dummy_thread_p = NULL; dstring thread_name = DSTRING_INIT; DENTER(TOP_LAYER, "sge_signaler_initialize"); sge_dstring_sprintf(&thread_name, "%s%03d", threadnames[SIGNALER_THREAD], 0); cl_thread_list_setup(&(Main_Control.signal_thread_pool), "signal thread pool"); cl_thread_list_create_thread(Main_Control.signal_thread_pool, &dummy_thread_p, cl_com_get_log_list(), sge_dstring_get_string(&thread_name), 0, sge_signaler_main, NULL, NULL, CL_TT_SIGNALER); sge_dstring_free(&thread_name); DRETURN_VOID; }
/****** sgeobj/var/var_list_set_string() ************************************** * NAME * var_list_set_string -- add/change an variable * * SYNOPSIS * void var_list_set_string(lList **varl, * const char *name, * const char *value); * * FUNCTION * If the variable <name> does not already exist in <varl>, * it is created and initialized with <value>. * Otherwise, its value is overwritten with <value> * * INPUTS * lList **varl - VA_Type list * const char *name - the name of the variable * const char *value - the (new) value of the variable * * SEE ALSO * sgeobj/var/var_list_set_int() * sgeobj/var/var_list_set_sge_u32() * sgeobj/var/var_list_set_sharedlib_path() ******************************************************************************/ void var_list_set_string(lList **varl, const char *name, const char *value) { lListElem *elem; DENTER(TOP_LAYER, "var_list_set_string"); if (varl == NULL || name == NULL || value == NULL) { DEXIT; return; } elem = lGetElemStr(*varl, VA_variable, name); if (elem == NULL) { elem = lAddElemStr(varl, VA_variable, name, VA_Type); } lSetString(elem, VA_value, value); DEXIT; }
/****** sgeobj/suser/suser_decrease_job_counter() ***************************** * NAME * suser_decrease_job_counter() -- decrease the users job counter * * SYNOPSIS * void suser_decrease_job_counter(lListElem *suser) * * FUNCTION * The job counter within "suser" will be decreased by one * * INPUTS * lListElem *suser - SU_Type list * * RESULT * void - NONE * * SEE ALSO * sgeobj/suser/SU_Type * sgeobj/suser/Master_SUser_List ******************************************************************************/ void suser_decrease_job_counter(lListElem *suser) { DENTER(TOP_LAYER, "suser_decrease_job_counter"); if (suser != NULL) { u_long32 jobs = lGetUlong(suser, SU_jobs); if (jobs == 0) { ERROR((SGE_EVENT, MSG_SUSERCNTISALREADYZERO_S, lGetString(suser, SU_name))); } else { lAddUlong(suser, SU_jobs, -1); } } DEXIT; }
static inline int irnet_discover_daddr_and_lsap_sel(irnet_socket * self) { int ret; DENTER(IRDA_SR_TRACE, "(self=0x%p)\n", self); self->discoveries = irlmp_get_discoveries(&self->disco_number, self->mask, DISCOVERY_DEFAULT_SLOTS); if(self->discoveries == NULL) { self->disco_number = -1; clear_bit(0, &self->ttp_connect); DRETURN(-ENETUNREACH, IRDA_SR_INFO, "No Cachelog...\n"); } DEBUG(IRDA_SR_INFO, "Got the log (0x%p), size is %d\n", self->discoveries, self->disco_number); self->disco_index = -1; self->daddr = DEV_ADDR_ANY; ret = irnet_discover_next_daddr(self); if(ret) { if(self->iriap) iriap_close(self->iriap); self->iriap = NULL; kfree(self->discoveries); self->discoveries = NULL; clear_bit(0, &self->ttp_connect); DRETURN(-ENETUNREACH, IRDA_SR_INFO, "Cachelog empty...\n"); } DEXIT(IRDA_SR_TRACE, "\n"); return(0); }
static void irnet_post_event(irnet_socket * ap, irnet_event event, __u32 saddr, __u32 daddr, char * name, __u16 hints) { int index; DENTER(CTRL_TRACE, "(ap=0x%p, event=%d, daddr=%08x, name=``%s'')\n", ap, event, daddr, name); spin_lock_bh(&irnet_events.spinlock); index = irnet_events.index; irnet_events.log[index].event = event; irnet_events.log[index].daddr = daddr; irnet_events.log[index].saddr = saddr; if(name) strcpy(irnet_events.log[index].name, name); else irnet_events.log[index].name[0] = '\0'; irnet_events.log[index].hints.word = hints; if((ap != (irnet_socket *) NULL) && (ap->ppp_open)) irnet_events.log[index].unit = ppp_unit_number(&ap->chan); else irnet_events.log[index].unit = -1; irnet_events.index = (index + 1) % IRNET_MAX_EVENTS; DEBUG(CTRL_INFO, "New event index is %d\n", irnet_events.index); spin_unlock_bh(&irnet_events.spinlock); wake_up_interruptible_all(&irnet_events.rwait); DEXIT(CTRL_TRACE, "\n"); }
/*-------------------------------------------------------------------------*/ int sge_send_all_reports(sge_gdi_ctx_class_t *ctx, u_long32 now, int which, report_source *report_sources) { int ret = 0; unsigned long connect_time = 0; DENTER(TOP_LAYER, "sge_send_all_reports"); /* * Send reports only if there is not a communication error. * Don't reset stored communication errors. */ cl_commlib_get_connect_time(ctx->get_com_handle(ctx), (char *)ctx->get_master(ctx, true), (char*)prognames[QMASTER], 1, &connect_time); if (get_last_qmaster_register_time() >= connect_time && connect_time != 0) { if (sge_get_com_error_flag(EXECD, SGE_COM_WAS_COMMUNICATION_ERROR, false) == false) { const char *master_host = NULL; lList *report_list = NULL; int i = 0; master_host = ctx->get_master(ctx, false); DPRINTF(("SENDING LOAD AND REPORTS\n")); report_list = lCreateList("report list", REP_Type); for (i = 0; report_sources[i].type; i++) { if (!which || which == report_sources[i].type) { DPRINTF(("%s\n", report_types[report_sources[i].type - 1])); report_sources[i].func(ctx, report_list, now, &(report_sources[i].next_send)); } } /* send load report asynchron to qmaster */ if (lGetNumberOfElem(report_list) > 0) { /* wrap around */ if (++sge_execd_report_seqno == 10000) { sge_execd_report_seqno = 0; } report_list_send(ctx, report_list, master_host, prognames[QMASTER], 1, 0); } lFreeList(&report_list); } } else { ret = 1; } DRETURN(ret); }
static int fGetHost(FILE *fp, lHost *tp) { int i; char line[READ_LINE_LENGHT + 1]; char sp[READ_LINE_LENGHT + 1]; char *s; DENTER(CULL_LAYER, "fGetHost"); if (!fp) { LERROR(LEFILENULL); DEXIT; return -1; } if (fGetLine(fp, line, READ_LINE_LENGHT)) { LERROR(LEFGETLINE); DEXIT; return -1; } s = line; while (isspace((int) *s)) s++; if (*s++ != '"') { LERROR(LESYNTAX); DEXIT; return -1; } for (i = 0; s[i] != '\0' && s[i] != '"'; i++) sp[i] = s[i]; if (s[i] != '"') { LERROR(LESYNTAX); DEXIT; return -1; } sp[i] = '\0'; if (!(*tp = strdup(sp))) { LERROR(LESTRDUP); DEXIT; return -1; } DEXIT; return 0; }
/****** qmaster/threads/sge_scheduler_terminate() **************************** * NAME * sge_scheduler_terminate() -- terminate the scheduler * * SYNOPSIS * void sge_scheduler_terminate(sge_gdi_ctx_class_t *ctx) * * FUNCTION * Terminates the scheduler if it was started previousely. This * function will return only when it is sure that the pthread canceled. * * 'Master_Scheduler' is accessed by this function. * * INPUTS * sge_gdi_ctx_class_t *ctx - context object * lList **answer_list - answer list * * RESULT * void - None * * NOTES * MT-NOTE: sge_scheduler_terminate() is MT safe * * SEE ALSO * qmaster/threads/sge_scheduler_initialize() * qmaster/threads/sge_scheduler_cleanup_thread() * qmaster/threads/sge_scheduler_terminate() * qmaster/threads/sge_scheduler_main() *******************************************************************************/ void sge_scheduler_terminate(sge_gdi_ctx_class_t *ctx, lList **answer_list) { DENTER(TOP_LAYER, "sge_scheduler_terminate"); sge_mutex_lock("master scheduler struct", SGE_FUNC, __LINE__, &(Master_Scheduler.mutex)); if (Master_Scheduler.is_running) { pthread_t thread_id; cl_thread_settings_t* thread = NULL; /* * store thread id to use it later on */ thread = cl_thread_list_get_first_thread(Main_Control.scheduler_thread_pool); thread_id = *(thread->thread_pointer); /* * send cancel signal */ pthread_cancel(thread_id); /* * wakeup scheduler thread which might be blocked by wait for events */ pthread_cond_signal(&Scheduler_Control.cond_var); /* * cl_thread deletion and cl_thread_pool deletion will be done at * schedulers cancelation point in sge_scheduler_cleanup_thread() ... * ... therefore we have nothing more to do. */ ; sge_mutex_unlock("master scheduler struct", SGE_FUNC, __LINE__, &(Master_Scheduler.mutex)); INFO((SGE_EVENT, MSG_THREAD_XTERMINATED_S, threadnames[SCHEDD_THREAD])); answer_list_add(answer_list, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_INFO); } else { sge_mutex_unlock("master scheduler struct", SGE_FUNC, __LINE__, &(Master_Scheduler.mutex)); ERROR((SGE_EVENT, MSG_THREAD_XNOTRUNNING_S, threadnames[SCHEDD_THREAD])); answer_list_add(answer_list, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR); } DRETURN_VOID; }
/*-------------------------------------------------------------------------*/ static void DeleteLines(Widget w, XtPointer cld, XtPointer cad) { Widget matrix = (Widget) cld; int rows; int i; int rows_to_delete = 0; int rows_old; int max_rows = 7; DENTER(GUI_LAYER, "DeleteLines"); if (!matrix) { DEXIT; return; } /* max_rows = XbaeMatrixVisibleRows(matrix); */ rows = rows_old = XbaeMatrixNumRows(matrix); for (i=0; i<rows; i++) if (XbaeMatrixIsRowSelected(matrix, i)) rows_to_delete++; i = 0; while (i<rows) { if (XbaeMatrixIsRowSelected(matrix, i)) { XbaeMatrixDeleteRows(matrix, i, 1); rows--; } else i++; } if ((rows_old - rows_to_delete) < max_rows) XbaeMatrixAddRows(matrix, rows, NULL, NULL, NULL, (max_rows - rows)); /* reset attribute line */ XbaeMatrixDeselectAll(matrix); /* refresh the matrix */ XbaeMatrixRefresh(matrix); DEXIT; }
void sge_event_master_terminate(void) { cl_thread_settings_t* thread = NULL; DENTER(TOP_LAYER, "sge_event_master_terminate"); thread = cl_thread_list_get_first_thread(Main_Control.event_master_thread_pool); while (thread != NULL) { DPRINTF((SFN" gets canceled\n", thread->thread_name)); cl_thread_list_delete_thread(Main_Control.event_master_thread_pool, thread); thread = cl_thread_list_get_first_thread(Main_Control.event_master_thread_pool); } DPRINTF(("all "SFN" threads terminated\n", threadnames[DELIVERER_THREAD])); DRETURN_VOID; }
lList* qmonReadFile(const char *filename) { char *text = NULL; lList *alp = NULL; DENTER(GUI_LAYER, "qmonReadFile"); text = qmonReadText(filename, &alp); /* insert file contents in browser */ qmonBrowserShow(text); /* free all allocated space and close */ XtFree(text); DRETURN(alp); }
static void sge_error_clear(sge_error_t *et) { DENTER(TOP_LAYER, "sge_error_clear"); if (et != NULL) { sge_error_message_t *elem = et->first; sge_error_message_t *next; while (elem != NULL) { next = elem->next; sge_error_message_destroy(&elem); elem = next; } et->first = NULL; et->last = NULL; } DEXIT; }
/* provide a list of attributes containing all attributes for the given host */ int host_complexes2scheduler( lList **new_centry_list, lListElem *host, lList *exechost_list, lList *centry_list ) { DENTER(TOP_LAYER, "host_comlexes2scheduler"); if (!host) { DPRINTF(("!!missing host!!\n")); } /* build global complex and add it to result */ lFreeList(new_centry_list); *new_centry_list = get_attribute_list(host_list_locate(exechost_list, "global"), host, NULL, centry_list); DRETURN(0); }
static bool sge_error_has_quality(sge_error_class_t* thiz, int error_quality) { bool ret = false; DENTER(TOP_LAYER, "sge_error_has_quality"); if(thiz) { sge_error_t *et = (sge_error_t*)thiz->sge_error_handle; sge_error_message_t *elem = et->first; while(elem) { if(elem->error_quality == error_quality ) { ret = true; break; } } } DEXIT; return ret; }
/****** cull/dump_scan/lUndumpElem() ****************************************** * NAME * lUndumpElem() -- Read element from FILE stream * * SYNOPSIS * lListElem* lUndumpElem(FILE *fp, const lDescr *dp) * * FUNCTION * Read element from FILE stream * * INPUTS * FILE *fp - file stream * const lDescr *dp - descriptor * * RESULT * lListElem* - Read element ******************************************************************************/ lListElem *lUndumpElem(const char *fname, const lDescr *dp) { lListElem *ep = NULL; FILE *fp; DENTER(CULL_LAYER, "lUndumpElemFp"); fp = fopen(fname, "r"); if (fp == NULL) { LERROR(LEOPEN); } else { ep = lUndumpElemFp(fp, dp); } DEXIT; return ep; }
void sge_err_get(sge_err_t *id, char *message, size_t size) { DENTER(ERR_LAYER, "sge_err_get"); if (id != NULL && message != NULL && size > 0) { sge_err_object_t *err_obj = NULL; sge_err_get_object(&err_obj); if (err_obj->id != SGE_ERR_SUCCESS) { *id = err_obj->id; sge_strlcpy(message, err_obj->message, size); } else { *id = SGE_ERR_SUCCESS; message[0] = '\0'; } } DEXIT; }
int pack_ack(sge_pack_buffer *pb, u_long32 type, u_long32 id, u_long32 id2, const char *str) { int ret; lListElem *ack = lCreateElem(ACK_Type); DENTER(TOP_LAYER, "pack_ack"); lSetUlong(ack, ACK_type, type); lSetUlong(ack, ACK_id, id); lSetUlong(ack, ACK_id2, id2); lSetString(ack, ACK_str, str); ret = cull_pack_elem(pb, ack); lFreeElem(&ack); DRETURN(ret); }
/****** gdi/request_internal/sge_gdi_packet_pack() *************************** * NAME * sge_gdi_packet_pack() -- pack a GDI packet * * SYNOPSIS * bool * sge_gdi_packet_pack(sge_gdi_packet_class_t * packet, lList**answer_list, * sge_pack_buffer *pb) * * FUNCTION * This functions packs all data representing a multi GDI request * into "pb". Errors will be reported with a corresponding * "answer_list" message and a negative return value. * * "pb" has to be initialized before this function is called. * init_packbuffer() or a similar function has do be used to * initialize this "pb". The function sge_gdi_packet_get_pb_size() * might be used to calculate the maximum size as if the buffer * would be needed to pack all tasks of a multi GDI request. * Using this size as initial size for the "pb" * will prevent continuous reallocation of memory in this * function. * * INPUTS * sge_gdi_packet_class_t * packet - GDI packet * lList **answer_list - answer list * sge_pack_buffer *pb - backbuffer * * RESULT * bool - error state * true - success * false - error * * NOTES * MT-NOTE: sge_gdi_packet_pack() is MT safe * * SEE ALSO * gdi/request_internal/sge_gdi_packet_get_pb_size() * gdi/request_internal/sge_gdi_packet_pack_task() * gdi/request_internal/sge_gdi_packet_unpack() *******************************************************************************/ bool sge_gdi_packet_pack(sge_gdi_packet_class_t *packet, lList **answer_list, sge_pack_buffer *pb) { bool ret = true; sge_gdi_task_class_t *task = NULL; DENTER(TOP_LAYER, "sge_gdi_packet_pack"); task = packet->first_task; while (ret && task != NULL) { ret |= sge_gdi_packet_pack_task(packet, task, answer_list, pb); task = task->next; } DRETURN(ret); }
int loadvalue_update_num_proc(t_loadvalues *loadvalue) { int ret = 0; SYSTEM_INFO system_info; DWORD local_ret; DENTER("loadvalue_update_num_proc"); local_ret = WaitForSingleObject(loadvalue_mutex, INFINITE); if (local_ret == WAIT_OBJECT_0) { GetSystemInfo(&system_info); loadvalue->num_proc = system_info.dwNumberOfProcessors; ReleaseMutex(loadvalue_mutex); } DEXIT; return ret; }
/*-------------------------------------------------------------------------*/ void qmonPopupCalendarConfig(Widget w, XtPointer cld, XtPointer cad) { Widget shell; lList *alp = NULL; DENTER(GUI_LAYER, "qmonPopupCalendarConfig"); /* set busy cursor */ XmtDisplayBusyCursor(w); if (!qmon_cal) { shell = XmtGetTopLevelShell(w); qmon_cal = qmonCreateCalendarConfig(shell); XmtAddDeleteCallback(shell, XmDO_NOTHING, qmonPopdownCalendarConfig, NULL); /* ** create ask layout */ cal_ask_layout = qmonCreateCalendarAsk(qmon_cal); } XSync(XtDisplay(qmon_cal), 0); XmUpdateDisplay(qmon_cal); qmonMirrorMultiAnswer(CALENDAR_T, &alp); if (alp) { qmonMessageBox(w, alp, 0); lFreeList(&alp); /* set default cursor */ XmtDisplayDefaultCursor(w); DEXIT; return; } qmonTimerAddUpdateProc(CALENDAR_T, "updateCalendarList", updateCalendarList); qmonStartTimer(CALENDAR_T); updateCalendarList(); XmListSelectPos(cal_names, 1, True); XtManageChild(qmon_cal); XRaiseWindow(XtDisplay(XtParent(qmon_cal)), XtWindow(XtParent(qmon_cal))); /* set default cursor */ XmtDisplayDefaultCursor(w); DEXIT; }
/****** sge_resource_utilization/serf_record_entry() *************************** * NAME * serf_record_entry() -- Add a new schedule entry record * * SYNOPSIS * void serf_record_entry(u_long32 job_id, u_long32 ja_taskid, const char * *state, u_long32 start_time, u_long32 end_time, char level_char, const * char *object_name, const char *name, double utilization) * * FUNCTION * The entirety of all information passed to this function describes * the schedule that was created during a scheduling interval of a * Grid Engine scheduler. To reflect multiple resource debitations * of a job multiple calls to serf_record_entry() are required. For * parallel jobs the serf_record_entry() is called one times with a * 'P' as level_char. * * INPUTS * u_long32 job_id - The job id * u_long32 ja_taskid - The task id * const char *type - A string indicating the reason why the * utilization was put into the schedule: * * RUNNING - Job was running before scheduling run * SUSPENDED - Job was suspended before scheduling run * PREEMPTING - Job gets preempted currently * STARTING - Job will be started * RESERVING - Job reserves resources * * u_long32 start_time - Start of the resource utilization * * u_long32 end_time - End of the resource utilization * * char level_char - Q - Queue * H - Host * G - Global * P - Parallel Environment (PE) * * const char *object_name - Name of Queue/Host/Global/PE * * const char *name - Resource name * * double utilization - Utilization amount * * NOTES * MT-NOTE: (1) serf_record_entry() is MT safe if no recording function * MT-NOTE: was registered via serf_init(). * MT-NOTE: (2) Otherwise MT safety of serf_record_entry() depends on * MT-NOTE: MT safety of registered recording function *******************************************************************************/ void serf_record_entry(u_long32 job_id, u_long32 ja_taskid, const char *type, u_long32 start_time, u_long32 end_time, char level_char, const char *object_name, const char *name, double utilization) { DENTER(TOP_LAYER, "serf_record_entry"); /* human readable format */ DPRINTF(("J="sge_U32CFormat"."sge_U32CFormat" T=%s S="sge_U32CFormat" E="sge_U32CFormat" L=%c O=%s R=%s U=%f\n", job_id, ja_taskid, type, start_time, end_time, level_char, object_name, name, utilization)); if (current_serf.record_schedule_entry && serf_get_active()) { (current_serf.record_schedule_entry)(job_id, ja_taskid, type, start_time, end_time, level_char, object_name, name, utilization); } DRETURN_VOID; }
/*-------------------------------------------------------------------------*/ void qmonStopTimer( long type ) { int i; DENTER(GUI_LAYER, "qmonStopTimer"); for (i=0; i<XtNumber(QmonListTimer); i++) { if ( (type&(1<<i)) && QmonListTimer[i].timercount) { QmonListTimer[i].timercount--; DPRINTF(("Timer %s/%d disabled\n", sge_gdi_list_timers[i], (int)QmonListTimer[i].timercount+1)); } } DEXIT; }
/****** sgeobj/var/var_list_set_sharedlib_path() ****************************** * NAME * var_list_set_sharedlib_path -- set shared lib path * * SYNOPSIS * void var_list_set_sharedlib_path(lList **varl); * * FUNCTION * Sets or replaces the shared lib path in the list of variables. * The SGE shared lib path is always set to the beginning of the * resulting shared lib path * (security, see var_get_sharedlib_path_name()) * * INPUTS * lList **varl - list of nment variables * * SEE ALSO * sgeobj/var/var_get_sharedlib_path_name() * sgeobj/var/var_list_set_string() * sgeobj/var/var_list_set_int() * sgeobj/var/var_list_set_sge_u32() ******************************************************************************/ void var_list_set_sharedlib_path(lList **varl) { char *sharedlib_path; char *sge_sharedlib_path; const char *sge_root = sge_get_root_dir(0, NULL, 0, 1); const char *sharedlib_path_name = var_get_sharedlib_path_name(); lListElem *sharedlib_elem = NULL; DENTER(TOP_LAYER, "set_sharedlib_path"); /* this is the SGE sharedlib path */ sge_sharedlib_path = sge_malloc(strlen(sge_root) + strlen("/lib/") + strlen(sge_get_arch()) + 1); sprintf(sge_sharedlib_path, "%s/lib/%s", sge_root, sge_get_arch()); /* if already in environment: extend by SGE sharedlib path, else set */ sharedlib_elem = lGetElemStr(*varl, VA_variable, sharedlib_path_name); if(sharedlib_elem != NULL) { const char *old_value = lGetString(sharedlib_elem, VA_value); if(old_value && strlen(old_value) > 0) { DPRINTF(("sharedlib path %s already set:\n", sharedlib_path_name)); sharedlib_path = sge_malloc(strlen(old_value) + 1 + strlen(sge_sharedlib_path) + 1); strcpy(sharedlib_path, sge_sharedlib_path); strcat(sharedlib_path, ":"); strcat(sharedlib_path, old_value); lSetString(sharedlib_elem, VA_value, sharedlib_path); sge_free(&sharedlib_path); } else { DPRINTF(("overwriting empty sharedlib path %s\n", sharedlib_path_name)); lSetString(sharedlib_elem, VA_value, sge_sharedlib_path); } } else { DPRINTF(("creating new sharedlib path %s\n", sharedlib_path_name)); sharedlib_elem = lAddElemStr(varl, VA_variable, sharedlib_path_name, VA_Type); lSetString(sharedlib_elem, VA_value, sge_sharedlib_path); } sge_free(&sge_sharedlib_path); DEXIT; }
static int shadowd_is_old_master_enrolled(int sge_test_heartbeat, int sge_qmaster_port, char *oldqmaster) { cl_com_handle_t* handle = NULL; cl_com_SIRM_t* status = NULL; int ret; int is_up_and_running = 0; int commlib_error = CL_RETVAL_OK; DENTER(TOP_LAYER, "shadowd_is_old_master_enrolled"); /* * This is for testsuite testing to simulate qmaster outage. * For testing the environment variable SGE_TEST_HEARTBEAT_TIMEOUT * has to be set! */ if (sge_test_heartbeat > 0) { DRETURN(is_up_and_running); } handle=cl_com_create_handle(&commlib_error, CL_CT_TCP, CL_CM_CT_MESSAGE, CL_FALSE, sge_qmaster_port, CL_TCP_DEFAULT,(char*)prognames[SHADOWD] , 0, 1,0 ); if (handle == NULL) { CRITICAL((SGE_EVENT, SFNMAX, cl_get_error_text(commlib_error))); DRETURN(is_up_and_running); } DPRINTF(("Try to send status information message to previous master host "SFQ" to port %ld\n", oldqmaster, sge_qmaster_port)); ret = cl_commlib_get_endpoint_status(handle,oldqmaster ,(char*)prognames[QMASTER] , 1, &status); if (ret != CL_RETVAL_OK) { DPRINTF(("cl_commlib_get_endpoint_status() returned "SFQ"\n", cl_get_error_text(ret))); is_up_and_running = 0; DPRINTF(("old qmaster not responding - No master found\n")); } else { DPRINTF(("old qmaster is still running\n")); is_up_and_running = 1; } if (status != NULL) { DPRINTF(("endpoint is up since %ld seconds and has status %ld\n", status->runtime, status->application_status)); cl_com_free_sirm_message(&status); } cl_commlib_shutdown_handle(handle,CL_FALSE); DRETURN(is_up_and_running); }
/****** qmaster/threads/sge_scheduler_cleanup_thread() ******************** * NAME * sge_scheduler_cleanup_thread() -- cleanup the scheduler thread * * SYNOPSIS * void sge_scheduler_cleanup_thread(void) * * FUNCTION * Cleanup the scheduler thread. * * This function has to be executed only by the scheduler thread. * Ideally it should be the last function executed when the * pthread cancelation point is passed. * * 'Master_Scheduler' is accessed by this function. * * INPUTS * void - None * * RESULT * void - none * * NOTES * MT-NOTE: sge_scheduler_cleanup_thread() is MT safe * * SEE ALSO * qmaster/threads/sge_scheduler_initialize() * qmaster/threads/sge_scheduler_cleanup_thread() * qmaster/threads/sge_scheduler_terminate() * qmaster/threads/sge_scheduler_main() *******************************************************************************/ void sge_scheduler_cleanup_thread(void *ctx_ref) { DENTER(TOP_LAYER, "sge_scheduler_cleanup_thread"); sge_mutex_lock("master scheduler struct", SGE_FUNC, __LINE__, &(Master_Scheduler.mutex)); if (Master_Scheduler.is_running) { cl_thread_settings_t* thread = NULL; /* * The scheduler thread itself executes this function (sge_scheduler_cleanup_thread()) * at the cancelation point as part of the cleanup. * Therefore it has to unset the thread config before the * cl_thread is deleted. Otherwise we might run into a race condition when logging * is used after the call of cl_thread_list_delete_thread_without_join() */ cl_thread_unset_thread_config(); /* * Delete the scheduler thread but don't wait for termination */ thread = cl_thread_list_get_first_thread(Main_Control.scheduler_thread_pool); cl_thread_list_delete_thread_without_join(Main_Control.scheduler_thread_pool, thread); /* * Trash the thread pool */ cl_thread_list_cleanup(&Main_Control.scheduler_thread_pool); /* * now a new scheduler can start */ Master_Scheduler.is_running = false; /* ** free the ctx too */ sge_gdi_ctx_class_destroy((sge_gdi_ctx_class_t **)ctx_ref); } sge_mutex_unlock("master scheduler struct", SGE_FUNC, __LINE__, &(Master_Scheduler.mutex)); DRETURN_VOID; }
static void sge_scheduler_wait_for_event(sge_evc_class_t *evc, lList **event_list) { int wait_ret; bool do_ack = false; DENTER(TOP_LAYER, "sge_scheduler_wait_for_event"); sge_mutex_lock("event_control_mutex", SGE_FUNC, __LINE__, &Scheduler_Control.mutex); if (!Scheduler_Control.triggered) { struct timespec ts; u_long32 current_time = sge_get_gmt(); ts.tv_sec = (long) current_time + SCHEDULER_TIMEOUT_S; ts.tv_nsec = SCHEDULER_TIMEOUT_N; wait_ret = pthread_cond_timedwait(&Scheduler_Control.cond_var, &Scheduler_Control.mutex, &ts); /* * if pthread_cond_timedwait returns 0, we were triggered by event master * otherwise we ran into a timeout or an error */ if (wait_ret != 0) { DPRINTF(("pthread_cond_timedwait for events failed %d\n", wait_ret)); } } if (Scheduler_Control.triggered) { *event_list = Scheduler_Control.new_events; Scheduler_Control.new_events = NULL; Scheduler_Control.triggered = false; do_ack = true; } sge_mutex_unlock("event_control_mutex", SGE_FUNC, __LINE__, &Scheduler_Control.mutex); if (do_ack) { if (lGetElemUlong(*event_list, ET_type, sgeE_ACK_TIMEOUT) != NULL) { evc->ec_mark4registration(evc); } evc->ec_ack(evc); } DRETURN_VOID; }
static bool cqueue_add_qinstances(sge_gdi_ctx_class_t *ctx, lListElem *cqueue, lList **answer_list, lList *add_hosts, monitoring_t *monitor) { bool ret = true; DENTER(TOP_LAYER, "cqueue_add_qinstances"); if (cqueue != NULL && add_hosts != NULL) { lListElem *href = NULL; for_each(href, add_hosts) { const char *hostname = lGetHost(href, HR_name); lList *list = lGetList(cqueue, CQ_qinstances); lListElem* qinstance = lGetElemHost(list, QU_qhostname, hostname); if (qinstance != NULL) { if (qinstance_state_is_orphaned(qinstance)) { sge_qmaster_qinstance_state_set_orphaned(qinstance, false); lSetUlong(qinstance, QU_tag, SGE_QI_TAG_MOD); } else { /* * We might already have this QI if it is in orphaned state. * If this is not true, than there is a bug! */ ERROR((SGE_EVENT, MSG_QINSTANCE_QIALREADYHERE_S, hostname)); answer_list_add(answer_list, SGE_EVENT, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); } } else { bool is_ambiguous = false; if (list == NULL) { list = lCreateList("", QU_Type); lSetList(cqueue, CQ_qinstances, list); } qinstance = qinstance_create(ctx, cqueue, answer_list, hostname, &is_ambiguous, monitor); if (is_ambiguous) { DPRINTF(("qinstance %s has ambiguous conf\n", hostname)); } lSetUlong(qinstance, QU_tag, SGE_QI_TAG_ADD); lAppendElem(list, qinstance); } } }