summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-06-21 15:35:30 -0400
committerTom Rondeau <trondeau@vt.edu>2013-06-21 15:35:30 -0400
commit5653dcfb4f3a836523921e014d2aa50014514e58 (patch)
treebdbe789c59548acf491fe49e490ac188e8aa4276 /gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc
parentad1d52fd9911114ad8c9748e808b55de4e16232b (diff)
runtime: fixed checks on vmcircbuf file and mutex locking for creation and usage of vmcrcbuf classes.
Diffstat (limited to 'gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc4
1 files changed, 4 insertions, 0 deletions
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)");
}