Module: kamailio Branch: master Commit: b06d969cf00d816182a639acb7de191c763c9d73 URL: https://github.com/kamailio/kamailio/commit/b06d969cf00d816182a639acb7de191c763c9d73
Author: Ovidiu Sas <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-05-20T11:11:24+02:00 core: re-attempt the lock if EINTR occurs (POSIX_SEM) --- Modified: src/core/lock_ops.h --- Diff: https://github.com/kamailio/kamailio/commit/b06d969cf00d816182a639acb7de191c763c9d73.diff Patch: https://github.com/kamailio/kamailio/commit/b06d969cf00d816182a639acb7de191c763c9d73.patch --- diff --git a/src/core/lock_ops.h b/src/core/lock_ops.h index 1d3af914fd7..f4ad602ca78 100644 --- a/src/core/lock_ops.h +++ b/src/core/lock_ops.h @@ -136,6 +136,8 @@ inline static gen_lock_t *lock_init(gen_lock_t *lock) #elif defined USE_POSIX_SEM #include <semaphore.h> +#include <errno.h> +#include "dprint.h" typedef sem_t gen_lock_t; @@ -148,8 +150,30 @@ inline static gen_lock_t *lock_init(gen_lock_t *lock) return lock; } -#define lock_try(lock) sem_trywait(lock) -#define lock_get(lock) sem_wait(lock) +inline static int lock_try(gen_lock_t *lock) +{ + int ret; + + do { + ret = sem_trywait(lock); + if(ret == -1 && errno != EINTR && errno != EAGAIN) + LM_CRIT("posix: %s (%d)\n", strerror(errno), errno); + } while(ret == -1 && errno == EINTR); + + return ret; +} + +inline static void lock_get(gen_lock_t *lock) +{ + while(sem_wait(lock) == -1) { + if(errno == EINTR) { + continue; + } else { + LM_CRIT("posix: %s (%d)\n", strerror(errno), errno); + } + } +} + #define lock_release(lock) sem_post(lock) _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
