--- freem/src/jobtab.c 2025/04/17 00:34:04 1.7 +++ freem/src/jobtab.c 2025/05/12 18:18:00 1.10 @@ -1,5 +1,5 @@ /* - * $Id: jobtab.c,v 1.7 2025/04/17 00:34:04 snw Exp $ + * $Id: jobtab.c,v 1.10 2025/05/12 18:18:00 snw Exp $ * job table implementation * * @@ -24,6 +24,15 @@ * along with FreeM. If not, see . * * $Log: jobtab.c,v $ + * Revision 1.10 2025/05/12 18:18:00 snw + * Further work on shared memory + * + * Revision 1.9 2025/05/01 21:02:31 snw + * Documentation updates + * + * Revision 1.8 2025/04/30 20:03:09 snw + * Work on entryref parser + * * Revision 1.7 2025/04/17 00:34:04 snw * More logging improvements * @@ -120,7 +129,7 @@ short jobtab_get_sem(void) return TRUE; } - logprintf (FM_LOG_WARNING, "jobtab_get_sem: sleeping for retry [tries = %d]", tries); + logprintf (FM_LOG_INFO, "jobtab_get_sem: sleeping for retry [tries = %d]", tries); sleep (1); } @@ -149,7 +158,7 @@ job_slot_t *job_init(short is_fmadm) logprintf (FM_LOG_FATAL, "job_init: failed to get job table semaphore"); } - for (s = shm_config->hdr->jobtab_head; s != NULL; s = s->next) { + for (s = SOA(shm_config->hdr->jobtab_head); s != NULL; s = SOA(s->next)) { if (((s->flags & JFLG_DEFUNCT) == JFLG_DEFUNCT) || (s->pid == pid)) { goto skip_alloc; @@ -181,8 +190,8 @@ skip_alloc: } } - s->next = shm_config->hdr->jobtab_head; - shm_config->hdr->jobtab_head = s; + s->next = SBM(shm_config->hdr->jobtab_head); + shm_config->hdr->jobtab_head = SBM(s); jobtab_release_sem (); @@ -193,17 +202,16 @@ skip_alloc: void job_remove(const pid_t pid) { - job_slot_t *t = shm_config->hdr->jobtab_head; + job_slot_t *t = SOM(shm_config->hdr->jobtab_head); job_slot_t *p = NULL; if (jobtab_get_sem () == FALSE) { logprintf (FM_LOG_FATAL, "job_remove: failed to get job table semaphore"); - exit (1); } if ((t != (job_slot_t *) NULL) && (t->pid == pid)) { - shm_config->hdr->jobtab_head = t->next; + shm_config->hdr->jobtab_head = SBM(t->next); shm_free (t); jobtab_release_sem (); @@ -214,7 +222,7 @@ void job_remove(const pid_t pid) while ((t != NULL) && (t->pid != pid)) { p = t; - t = t->next; + t = SBA(t->next); } if (t == NULL) { @@ -222,11 +230,12 @@ void job_remove(const pid_t pid) return; } - p->next = t->next; + p->next = SBA(t->next); shm_free (t); jobtab_release_sem (); + locktab_unlock_all_by_pid (pid); } void job_request_stop(const pid_t target_pid) @@ -238,7 +247,7 @@ void job_request_stop(const pid_t target logprintf (FM_LOG_FATAL, "job_request_stop: failed to get job table semaphore"); } - for (s = shm_config->hdr->jobtab_head; s != NULL; s = s->next) { + for (s = SOA(shm_config->hdr->jobtab_head); s != NULL; s = SOA(s->next)) { if (s->pid == target_pid) { s->stop_requested = pid;