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