--- freem/src/locktab.c 2025/04/13 04:22:43 1.6 +++ freem/src/locktab.c 2025/05/01 21:02:31 1.7 @@ -1,5 +1,5 @@ /* - * $Id: locktab.c,v 1.6 2025/04/13 04:22:43 snw Exp $ + * $Id: locktab.c,v 1.7 2025/05/01 21:02:31 snw Exp $ * lock table implementation * * @@ -24,6 +24,9 @@ * along with FreeM. If not, see . * * $Log: locktab.c,v $ + * Revision 1.7 2025/05/01 21:02:31 snw + * Documentation updates + * * Revision 1.6 2025/04/13 04:22:43 snw * Fix snprintf calls * @@ -49,6 +52,7 @@ #include "shmmgr.h" #include "mref.h" #include "transact.h" +#include "log.h" #if !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__OS2__) union semun { @@ -110,7 +114,7 @@ short locktab_get_sem(void) if (semop (semid_locktab, &s, 1) != -1) { return TRUE; } - + printf ("jibjaw\r\n"); sleep (1); } @@ -237,6 +241,8 @@ void locktab_increment(char *key, long l } else { + int sigint_ct = 0; + for (;;) { if (locktab_insert (key) != NULL) { @@ -244,6 +250,18 @@ void locktab_increment(char *key, long l return; } else { + if (merr () == INRPT) { + sigint_ct++; + + if (sigint_ct == 1) { + printf ("\r\nlocktab_insert: got Ctrl-C in blocking LOCK; Ctrl-C again to force the process to halt\r\n"); + merr_clear (); + } + else { + printf ("\r\n"); + logprintf (FM_LOG_FATAL, "locktab_insert: blocking LOCK was interrupted; forcing halt"); + } + } sleep (1); } @@ -409,12 +427,25 @@ void locktab_decrement(char *key, long l void locktab_unlock_all(void) { + locktab_unlock_all_by_pid (pid); +} + +void locktab_unlock_all_by_pid(const pid_t target_pid) +{ locktab_ent_t *lck; + int remove_ct; + + remove_ct = 0; + if (target_pid != pid) { + logprintf (FM_LOG_INFO, "locktab_unlock_all_by_pid: removing all locks for pid %ld", target_pid); + } + for (lck = shm_config->hdr->locktab_head; lck != NULL; lck = lck->next) { - if (lck->owner_job == pid) { - + if (lck->owner_job == target_pid) { + remove_ct++; + if (tp_level > lck->tp_level) { merr_raise (M41); return; @@ -428,7 +459,12 @@ void locktab_unlock_all(void) } - } + } + + if (target_pid != pid) { + logprintf (FM_LOG_INFO, "locktab_unlock_all_by_pid: removed %ld lock(s) for pid %ld", remove_ct, target_pid); + } + }