int remove_array( job_array *pa) { int rc; char arrayid[PBS_MAXSVRJOBID+1]; if (pthread_mutex_trylock(allarrays.allarrays_mutex)) { strcpy(arrayid, pa->ai_qs.parent_id); unlock_ai_mutex(pa, __func__, "1", LOGLEVEL); pthread_mutex_lock(allarrays.allarrays_mutex); pa = (job_array *)get_from_hash_map(allarrays.hm, arrayid); if (pa != NULL) lock_ai_mutex(pa, __func__, "2", LOGLEVEL); } if (pa == NULL) rc = PBSE_NONE; else rc = remove_from_hash_map(allarrays.hm, pa->ai_qs.parent_id); pthread_mutex_unlock(allarrays.allarrays_mutex); return(rc); } /* END remove_array() */
int remove_entry_from_exiting_list( job_exiting_retry_info *jeri) /* I, freed */ { int rc = remove_from_hash_map(exiting_jobs_info, jeri->jobid); free(jeri); return(rc); } /* END remove_entry_from_exiting_list() */
char *get_next_retryable_jobid( int *iter) { job_exiting_retry_info *jeri; job *pjob; time_t time_now = time(NULL); char log_buf[LOCAL_LOG_BUF_SIZE]; pthread_mutex_lock(exiting_jobs_info->hm_mutex); mutex_mgr exit_mgr(exiting_jobs_info->hm_mutex, true); while ((jeri = (job_exiting_retry_info *)next_from_hash_map(exiting_jobs_info, iter, true)) != NULL) { if (time_now - jeri->last_attempt > EXITING_RETRY_TIME) { if (jeri->attempts >= MAX_EXITING_RETRY_ATTEMPTS) { std::string jid(jeri->jobid); remove_from_hash_map(exiting_jobs_info, jeri->jobid, true); free(jeri); exit_mgr.unlock(); //Don't hold on to a mutex when trying to lock another. if ((pjob = svr_find_job((char *)jid.c_str(), TRUE)) != NULL) { snprintf(log_buf, sizeof(log_buf), "Job %s has had its exiting re-tried %d times, purging.", jeri->jobid, MAX_EXITING_RETRY_ATTEMPTS); log_event(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); force_purge_work(pjob); } exit_mgr.lock(); } else { jeri->attempts++; jeri->last_attempt = time_now; char *jobid = strdup(jeri->jobid); return(jobid); } } } return(NULL); } /* END get_next_retryable_jobid() */