summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.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_tmpfile.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_tmpfile.cc')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
index ffe2a3d2c..7a02fe2de 100644
--- a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
@@ -51,6 +51,7 @@ namespace gr {
fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: mmap or mkstemp is not available\n");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
#else
+ gr::thread::scoped_lock guard(s_vm_mutex);
if(size <= 0 || (size % gr::pagesize ()) != 0) {
fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: invalid size = %d\n", size);
@@ -155,6 +156,8 @@ namespace gr {
vmcircbuf_mmap_tmpfile::~vmcircbuf_mmap_tmpfile()
{
#if defined(HAVE_MMAP)
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
if(munmap(d_base, 2 * d_size) == -1) {
perror("gr::vmcircbuf_mmap_tmpfile: munmap(2)");
}