summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2020-04-11 00:43:39 +0200
committerMarcus Müller <marcus@hostalia.de>2020-04-13 15:55:41 +0200
commit0f88db1ef0569bf6fcd5e9c843da38d487a6f54b (patch)
tree4c9827377c0e98fe223f39edb0c84c8a49c199e9 /gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
parentec8a92846a388cb0d2982822ea1961910cd552f8 (diff)
runtime: replace stderr logging by calls to GR's logging facilties
Diffstat (limited to 'gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
index 6f9d7e4104..3fc03f66c5 100644
--- a/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_mmap_tmpfile.cc
@@ -36,13 +36,15 @@ namespace gr {
vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
{
#if !defined(HAVE_MMAP)
- fprintf(stderr, "gr::vmcircbuf_mmap_tmpfile: mmap or mkstemp is not available\n");
+ GR_LOG_ERROR(d_logger, "mmap or mkstemp is not available");
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);
+ std::stringstream error_msg;
+ error_msg << "invalid size = " << size;
+ GR_LOG_ERROR(d_logger, error_msg.str());
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -62,16 +64,15 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
if (errno == EEXIST) // File already exists (shouldn't happen). Try again
continue;
- static std::string msg =
- str(boost::format("gr::vmcircbuf_mmap_tmpfile: open [%s]") % seg_name);
- perror(msg.c_str());
+ static std::string msg = str(boost::format("open [%s]") % seg_name);
+ GR_LOG_ERROR(d_logger, msg.c_str());
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
break;
}
if (unlink(seg_name.c_str()) == -1) {
- perror("gr::vmcircbuf_mmap_tmpfile: unlink");
+ GR_LOG_ERROR(d_logger, "unlink");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -79,7 +80,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
// Now set it's length to 2x what we really want and mmap it in.
if (ftruncate(seg_fd, (off_t)2 * size) == -1) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (1)");
+ GR_LOG_ERROR(d_logger, "ftruncate (1) failed");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -88,14 +89,14 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
if (first_copy == MAP_FAILED) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: mmap (1)");
+ GR_LOG_ERROR(d_logger, "mmap (1) failed");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
// unmap the 2nd half
if (munmap((char*)first_copy + size, size) == -1) {
close(seg_fd); // cleanup
- perror("gr::vmcircbuf_mmap_tmpfile: munmap (1)");
+ GR_LOG_ERROR(d_logger, "munmap (1) failed");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -111,7 +112,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
if (second_copy == MAP_FAILED) {
munmap(first_copy, size); // cleanup
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: mmap(2)");
+ GR_LOG_ERROR(d_logger, "mmap (2) failed");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -120,7 +121,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
munmap(first_copy, size); // cleanup
munmap(second_copy, size);
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: non-contiguous second copy");
+ GR_LOG_ERROR(d_logger, "non-contiguous second copy");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -129,7 +130,7 @@ vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile(int size) : gr::vmcircbuf(size)
munmap(first_copy, size); // cleanup
munmap(second_copy, size);
close(seg_fd);
- perror("gr::vmcircbuf_mmap_tmpfile: ftruncate (2)");
+ GR_LOG_ERROR(d_logger, "ftruncate (2) failed");
throw std::runtime_error("gr::vmcircbuf_mmap_tmpfile");
}
@@ -148,7 +149,7 @@ vmcircbuf_mmap_tmpfile::~vmcircbuf_mmap_tmpfile()
gr::thread::scoped_lock guard(s_vm_mutex);
if (munmap(d_base, 2 * d_size) == -1) {
- perror("gr::vmcircbuf_mmap_tmpfile: munmap(2)");
+ GR_LOG_ERROR(d_logger, "munmap (2) failed");
}
#endif
}