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

Function process_lock_claim_mode

src/daemon/ipc.c:472–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470static bool posix_socket_status_secure_transport(const struct stat *status);
471
472static int process_lock_claim_mode(const cbm_daemon_ipc_endpoint_t *endpoint, const char *lock_name,
473 bool shared, process_lock_entry_t **entry_out) {
474 *entry_out = NULL;
475 if (!endpoint || !lock_name || pthread_mutex_lock(&process_locks_mutex) != 0) {
476 return -1;
477 }
478 for (process_lock_entry_t *entry = process_locks; entry; entry = entry->next) {
479 if (entry->directory_device == endpoint->dir_device &&
480 entry->directory_inode == endpoint->dir_inode &&
481 strcmp(entry->lock_name, lock_name) == 0 && (!shared || !entry->shared)) {
482 (void)pthread_mutex_unlock(&process_locks_mutex);
483 return 0;
484 }
485 }
486 process_lock_entry_t *entry = calloc(1, sizeof(*entry));
487 if (entry) {
488 entry->lock_name = string_copy(lock_name);
489 }
490 if (!entry || !entry->lock_name) {
491 free(entry);
492 (void)pthread_mutex_unlock(&process_locks_mutex);
493 return -1;
494 }
495 entry->directory_device = endpoint->dir_device;
496 entry->directory_inode = endpoint->dir_inode;
497 entry->shared = shared;
498 entry->next = process_locks;
499 process_locks = entry;
500 *entry_out = entry;
501 (void)pthread_mutex_unlock(&process_locks_mutex);
502 return 1;
503}
504
505static int process_lock_claim(const cbm_daemon_ipc_endpoint_t *endpoint, const char *lock_name,
506 process_lock_entry_t **entry_out) {

Callers 2

process_lock_claimFunction · 0.85

Calls 1

string_copyFunction · 0.85

Tested by

no test coverage detected