From 5653dcfb4f3a836523921e014d2aa50014514e58 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Fri, 21 Jun 2013 15:35:30 -0400
Subject: runtime: fixed checks on vmcircbuf file and mutex locking for
 creation and usage of vmcrcbuf classes.

---
 gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc')

diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc b/gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc
index 7b461bc26b..919986c608 100644
--- a/gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc
@@ -49,6 +49,8 @@ namespace gr {
     fprintf(stderr, "gr::vmcircbuf_mmap_shm_open: mmap or shm_open is not available\n");
     throw std::runtime_error("gr::vmcircbuf_mmap_shm_open");
 #else
+    gr::thread::scoped_lock guard(s_vm_mutex);
+
     static int s_seg_counter = 0;
 
     if(size <= 0 || (size % gr::pagesize ()) != 0) {
@@ -162,6 +164,8 @@ namespace gr {
   vmcircbuf_mmap_shm_open::~vmcircbuf_mmap_shm_open()
   {
 #if defined(HAVE_MMAP)
+    gr::thread::scoped_lock guard(s_vm_mutex);
+
     if(munmap (d_base, 2 * d_size) == -1) {
       perror("gr::vmcircbuf_mmap_shm_open: munmap (2)");
     }
-- 
cgit v1.2.3