| 470 | static bool posix_socket_status_secure_transport(const struct stat *status); |
| 471 | |
| 472 | static 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 | |
| 505 | static int process_lock_claim(const cbm_daemon_ipc_endpoint_t *endpoint, const char *lock_name, |
| 506 | process_lock_entry_t **entry_out) { |
no test coverage detected