[sr-dev] git:master:51e263de: mem: add a multiprocess-safe shm_available()

Camille Oudot camille.oudot at orange.com
Wed Apr 15 11:19:15 CEST 2015


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

Author: Camille Oudot <camille.oudot at orange.com>
Committer: Camille Oudot <camille.oudot at orange.com>
Date: 2015-04-14T19:38:14+02:00

mem: add a multiprocess-safe shm_available()

new safe_shm_available() function secured with shm_lock()

---

Modified: mem/shm_mem.c
Modified: mem/shm_mem.h

---

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

---

diff --git a/mem/shm_mem.c b/mem/shm_mem.c
index de78213..5b6a0cf 100644
--- a/mem/shm_mem.c
+++ b/mem/shm_mem.c
@@ -254,5 +254,13 @@ void shm_mem_destroy(void)
 #endif
 }
 
+inline unsigned long safe_shm_available()
+{
+	unsigned long ret;
+	shm_lock();
+	ret = shm_available();
+	shm_unlock();
+	return ret;
+}
 
 #endif
diff --git a/mem/shm_mem.h b/mem/shm_mem.h
index eadccb5..97032d4 100644
--- a/mem/shm_mem.h
+++ b/mem/shm_mem.h
@@ -312,6 +312,11 @@ do{\
 
 #endif /* ! SHM_SAFE_MALLOC */
 
+/* multi-process safe version of shm_available()
+ */
+inline unsigned long safe_shm_available();
+
+
 #endif /* shm_mem_h */
 
 #endif /* SHM_MEM */




More information about the sr-dev mailing list