Module: kamailio
Branch: master
Commit: cf7577360ea11ea90848fb69f9f87b4df5ea5735
URL: 
https://github.com/kamailio/kamailio/commit/cf7577360ea11ea90848fb69f9f87b4df5ea5735

Author: Viktor Litvinov <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2025-12-16T13:05:45+01:00

core: use process shared pthread mutexes

Signed-off-by: Daniel-Constantin Mierla <[email protected]>

---

Modified: src/core/lock_ops.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/cf7577360ea11ea90848fb69f9f87b4df5ea5735.diff
Patch: 
https://github.com/kamailio/kamailio/commit/cf7577360ea11ea90848fb69f9f87b4df5ea5735.patch

---

diff --git a/src/core/lock_ops.h b/src/core/lock_ops.h
index d815c5f748b..1d3af914fd7 100644
--- a/src/core/lock_ops.h
+++ b/src/core/lock_ops.h
@@ -116,10 +116,17 @@ typedef pthread_mutex_t gen_lock_t;
 
 inline static gen_lock_t *lock_init(gen_lock_t *lock)
 {
-       if(pthread_mutex_init(lock, 0) == 0)
+       pthread_mutexattr_t attr;
+       if((pthread_mutexattr_init(&attr) == 0)
+                       && (pthread_mutexattr_setpshared(&attr, 
PTHREAD_PROCESS_SHARED)
+                                       == 0)
+                       && (pthread_mutex_init(lock, &attr) == 0)) {
+               pthread_mutexattr_destroy(&attr);
                return lock;
-       else
+       } else {
+               pthread_mutexattr_destroy(&attr);
                return 0;
+       }
 }
 
 #define lock_try(lock) pthread_mutex_trylock(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!

Reply via email to