summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf.cc4
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_createfilemapping.cc4
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_mmap_shm_open.cc4
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc3
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_prefs.cc5
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc6
6 files changed, 20 insertions, 6 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf.cc b/gnuradio-runtime/lib/vmcircbuf.cc
index 315d409c5d..ff5093d5c4 100644
--- a/gnuradio-runtime/lib/vmcircbuf.cc
+++ b/gnuradio-runtime/lib/vmcircbuf.cc
@@ -66,15 +66,13 @@ namespace gr {
bool verbose = false;
- gr::thread::scoped_lock guard(s_vm_mutex);
-
std::vector<gr::vmcircbuf_factory *> all = all_factories ();
const char *name = gr::vmcircbuf_prefs::get(FACTORY_PREF_KEY);
if(name) {
for(unsigned int i = 0; i < all.size (); i++) {
- if(strcmp(name, all[i]->name ()) == 0) {
+ if(strncmp(name, all[i]->name(), strlen(all[i]->name())) == 0) {
s_default_factory = all[i];
if(verbose)
fprintf(stderr, "gr::vmcircbuf_sysconfig: using %s\n",
diff --git a/gnuradio-runtime/lib/vmcircbuf_createfilemapping.cc b/gnuradio-runtime/lib/vmcircbuf_createfilemapping.cc
index 2d345a29b1..8d4de28a13 100644
--- a/gnuradio-runtime/lib/vmcircbuf_createfilemapping.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_createfilemapping.cc
@@ -69,6 +69,8 @@ namespace gr {
fprintf(stderr, "%s: createfilemapping is not available\n", __FUNCTION__);
throw std::runtime_error("gr::vmcircbuf_createfilemapping");
#else
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
static int s_seg_counter = 0;
if(size <= 0 || (size % gr::pagesize ()) != 0) {
@@ -149,6 +151,8 @@ namespace gr {
vmcircbuf_createfilemapping::~vmcircbuf_createfilemapping()
{
#ifdef HAVE_CREATEFILEMAPPING
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
if(UnmapViewOfFile(d_first_copy) == 0) {
werror("gr::vmcircbuf_createfilemapping: UnmapViewOfFile(d_first_copy)", GetLastError());
}
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)");
}
diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
index ffe2a3d2c2..7a02fe2de8 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)");
}
diff --git a/gnuradio-runtime/lib/vmcircbuf_prefs.cc b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
index 1fa6350385..258605c6be 100644
--- a/gnuradio-runtime/lib/vmcircbuf_prefs.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
@@ -25,6 +25,7 @@
#endif
#include "vmcircbuf_prefs.h"
+#include "vmcircbuf.h"
#include <gnuradio/sys_paths.h>
#include <stdio.h>
#include <stdlib.h>
@@ -69,6 +70,8 @@ namespace gr {
{
static char buf[1024];
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
FILE *fp = fopen(pathname (key), "r");
if(fp == 0) {
perror(pathname (key));
@@ -91,6 +94,8 @@ namespace gr {
void
vmcircbuf_prefs::set(const char *key, const char *value)
{
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
ensure_dir_path();
FILE *fp = fopen(pathname(key), "w");
diff --git a/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc b/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
index 484b1a914e..f26edf44fc 100644
--- a/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_sysv_shm.cc
@@ -46,13 +46,13 @@ namespace gr {
vmcircbuf_sysv_shm::vmcircbuf_sysv_shm(int size)
: gr::vmcircbuf(size)
{
- gr::thread::scoped_lock guard(s_vm_mutex);
-
#if !defined(HAVE_SYS_SHM_H)
fprintf(stderr, "gr::vmcircbuf_sysv_shm: sysv shared memory is not available\n");
throw std::runtime_error("gr::vmcircbuf_sysv_shm");
#else
+ gr::thread::scoped_lock guard(s_vm_mutex);
+
int pagesize = gr::pagesize();
if(size <= 0 || (size % pagesize) != 0) {
@@ -152,9 +152,9 @@ namespace gr {
vmcircbuf_sysv_shm::~vmcircbuf_sysv_shm()
{
+#if defined(HAVE_SYS_SHM_H)
gr::thread::scoped_lock guard(s_vm_mutex);
-#if defined(HAVE_SYS_SHM_H)
if(shmdt(d_base - gr::pagesize()) == -1
|| shmdt(d_base) == -1
|| shmdt(d_base + d_size) == -1