MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / process_lock_claim_mode

Function process_lock_claim_mode

src/daemon/ipc.c:644–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642static bool posix_socket_status_secure_transport(const struct stat *status);
643
644static int process_lock_claim_mode(const cbm_daemon_ipc_endpoint_t *endpoint, const char *lock_name,
645 bool shared, process_lock_entry_t **entry_out) {
646 *entry_out = NULL;
647 if (!endpoint || !lock_name || pthread_mutex_lock(&process_locks_mutex) != 0) {
648 return -1;
649 }
650 for (process_lock_entry_t *entry = process_locks; entry; entry = entry->next) {
651 if (entry->directory_device == endpoint->dir_device &&
652 entry->directory_inode == endpoint->dir_inode &&
653 strcmp(entry->lock_name, lock_name) == 0 && (!shared || !entry->shared)) {
654 (void)pthread_mutex_unlock(&process_locks_mutex);
655 return 0;
656 }
657 }
658 process_lock_entry_t *entry = calloc(1, sizeof(*entry));
659 if (entry) {
660 entry->lock_name = string_copy(lock_name);
661 }
662 if (!entry || !entry->lock_name) {
663 free(entry);
664 (void)pthread_mutex_unlock(&process_locks_mutex);
665 return -1;
666 }
667 entry->directory_device = endpoint->dir_device;
668 entry->directory_inode = endpoint->dir_inode;
669 entry->shared = shared;
670 entry->next = process_locks;
671 process_locks = entry;
672 *entry_out = entry;
673 (void)pthread_mutex_unlock(&process_locks_mutex);
674 return 1;
675}
676
677static int process_lock_claim(const cbm_daemon_ipc_endpoint_t *endpoint, const char *lock_name,
678 process_lock_entry_t **entry_out) {

Callers 2

process_lock_claimFunction · 0.85

Calls 2

pthread_mutex_lockFunction · 0.85
string_copyFunction · 0.85

Tested by

no test coverage detected