Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ned14/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2022-05-16 18:44:24 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2022-05-16 18:44:24 +0300
commitdc6d416b1e4312ba289425bed2940f8c883b707c (patch)
tree43af044d267c24efc3304b286dcf0482e6648333
parent74205665529ac4e6ea0059ef1f4c87e4be19f258 (diff)
Add cmake option LLFIO_FORCE_SIGNAL_DETECTION_OFF to disable any use of signal_guard, which is currently unreliable on recent Linux glibc's.
-rw-r--r--CMakeLists.txt4
-rw-r--r--include/llfio/revision.hpp6
-rw-r--r--include/llfio/v2.0/detail/impl/posix/byte_io_handle.ipp16
-rw-r--r--include/llfio/v2.0/detail/impl/posix/map_handle.ipp83
-rw-r--r--include/llfio/v2.0/detail/impl/windows/map_handle.ipp71
5 files changed, 108 insertions, 72 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25bdc34b..5f7939e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ option(LLFIO_FORCE_DYNAMIC_THREAD_POOL_GROUP_OFF "Whether to disable dynamic thr
option(LLFIO_FORCE_NETWORKING_OFF "Whether to disable networking support in LLFIO" OFF)
option(LLFIO_FORCE_MAPPED_FILES_OFF "Whether to disable memory mapped files support in LLFIO" OFF)
option(LLFIO_FORCE_OPENSSL_OFF "Whether to disable use of OpenSSL in LLFIO" OFF)
+option(LLFIO_FORCE_SIGNAL_DETECTION_OFF "Whether to disable detection of signal raises in LLFIO" OFF)
option(UNIT_TESTS_BUILD_ALL "Whether to run all of the unit test suite." OFF)
set(UNIT_TESTS_CXX_VERSION "latest" CACHE STRING "The version of C++ to use in the header-only unit tests")
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
@@ -204,6 +205,9 @@ else()
target_link_libraries(llfio_hl INTERFACE OpenSSL::Crypto OpenSSL::SSL $<$<PLATFORM_ID:Windows>:Crypt32>)
endif()
endif()
+if(LLFIO_FORCE_SIGNAL_DETECTION_OFF)
+ all_compile_definitions(PRIVATE LLFIO_DISABLE_SIGNAL_GUARD=1)
+endif()
if(TARGET outcome::hl)
all_link_libraries(PUBLIC outcome::hl)
endif()
diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index 7eb59194..677d8997 100644
--- a/include/llfio/revision.hpp
+++ b/include/llfio/revision.hpp
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
-#define LLFIO_PREVIOUS_COMMIT_REF d06bf6d6c2e1a23fb9eee3cb0c1056abc52de471
-#define LLFIO_PREVIOUS_COMMIT_DATE "2022-05-06 10:05:54 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE d06bf6d6
+#define LLFIO_PREVIOUS_COMMIT_REF 74205665529ac4e6ea0059ef1f4c87e4be19f258
+#define LLFIO_PREVIOUS_COMMIT_DATE "2022-05-11 20:34:33 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE 74205665
diff --git a/include/llfio/v2.0/detail/impl/posix/byte_io_handle.ipp b/include/llfio/v2.0/detail/impl/posix/byte_io_handle.ipp
index 026bded2..849e988c 100644
--- a/include/llfio/v2.0/detail/impl/posix/byte_io_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/posix/byte_io_handle.ipp
@@ -36,7 +36,9 @@ Distributed under the Boost Software License, Version 1.0.
#include <poll.h>
#endif
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
#include "quickcpplib/signal_guard.hpp"
+#endif
LLFIO_V2_NAMESPACE_BEGIN
@@ -231,13 +233,23 @@ byte_io_handle::io_result<byte_io_handle::const_buffers_type> byte_io_handle::_d
do
{
// Can't guarantee that user code hasn't enabled SIGPIPE
- byteswritten = QUICKCPPLIB_NAMESPACE::signal_guard::signal_guard(
- QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::broken_pipe, [&] { return ::writev(_v.fd, iov, reqs.buffers.size()); },
+ byteswritten =
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
+ QUICKCPPLIB_NAMESPACE::signal_guard::signal_guard(
+ QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::broken_pipe,
+ [&]
+ {
+ return
+#endif
+ ::writev(_v.fd, iov, reqs.buffers.size());
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
+ },
[&](const QUICKCPPLIB_NAMESPACE::signal_guard::raised_signal_info * /*unused*/)
{
errno = EPIPE;
return -1;
});
+#endif
if(byteswritten <= 0)
{
if(byteswritten == 0 && is_socket())
diff --git a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp
index 98d1e4cc..c4b94a13 100644
--- a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp
@@ -25,7 +25,9 @@ Distributed under the Boost Software License, Version 1.0.
#include "../../../map_handle.hpp"
#include "../../../utils.hpp"
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
#include "quickcpplib/signal_guard.hpp"
+#endif
#include <sys/mman.h>
@@ -397,7 +399,8 @@ static inline result<void *> do_mmap(native_handle_type &nativeh, void *ataddr,
}
auto _offset = offset & ~(pagesize - 1);
auto _bytes = bytes + (offset & (pagesize - 1));
-// printf("mmap(%p, %u (%u), %d, %d, %d, %u (%u))\n", ataddr, (unsigned) _bytes, (unsigned) bytes, prot, flags, have_backing ? section->native_handle().fd : -1, (unsigned) _offset, (unsigned) offset);
+// printf("mmap(%p, %u (%u), %d, %d, %d, %u (%u))\n", ataddr, (unsigned) _bytes, (unsigned) bytes, prot, flags, have_backing ? section->native_handle().fd : -1,
+// (unsigned) _offset, (unsigned) offset);
#ifdef MAP_SYNC // Linux kernel 4.15 or later only
// If backed by a file into persistent shared memory, ask the kernel to use persistent memory safe semantics
if(have_backing && (_flag & section_handle::flag::nvram) && (flags & MAP_SHARED) != 0)
@@ -585,7 +588,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi
_reservation = _newsize;
_length = length;
return newsize;
-#else // generic POSIX, inefficient
+#else // generic POSIX, inefficient
byte *addrafter = _addr + _reservation;
size_type bytes = newsize - _reservation;
extent_type offset = _offset + _reservation;
@@ -766,44 +769,52 @@ map_handle::io_result<map_handle::const_buffers_type> map_handle::_do_write(io_r
}
byte *addr = _addr + reqs.offset + (_offset & (_pagesize - 1));
size_type togo = reqs.offset < _length ? static_cast<size_type>(_length - reqs.offset) : 0;
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
if(QUICKCPPLIB_NAMESPACE::signal_guard::signal_guard(
QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::undefined_memory_access | QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::segmentation_fault,
- [&] {
- for(size_t i = 0; i < reqs.buffers.size(); i++)
- {
- const_buffer_type &req = reqs.buffers[i];
- if(req.size() > togo)
- {
- assert(req.data() != nullptr);
- memcpy(addr, req.data(), togo);
- req = {addr, togo};
- reqs.buffers = {reqs.buffers.data(), i + 1};
- return false;
- }
- else
- {
- assert(req.data() != nullptr);
- memcpy(addr, req.data(), req.size());
- req = {addr, req.size()};
- addr += req.size();
- togo -= req.size();
- }
- }
- return false;
+#endif
+ [&]
+ {
+ for(size_t i = 0; i < reqs.buffers.size(); i++)
+ {
+ const_buffer_type &req = reqs.buffers[i];
+ if(req.size() > togo)
+ {
+ assert(req.data() != nullptr);
+ memcpy(addr, req.data(), togo);
+ req = {addr, togo};
+ reqs.buffers = {reqs.buffers.data(), i + 1};
+ return false;
+ }
+ else
+ {
+ assert(req.data() != nullptr);
+ memcpy(addr, req.data(), req.size());
+ req = {addr, req.size()};
+ addr += req.size();
+ togo -= req.size();
+ }
+ }
+ return false;
+#ifdef LLFIO_DISABLE_SIGNAL_GUARD
+ }();
+#else
},
- [&](const QUICKCPPLIB_NAMESPACE::signal_guard::raised_signal_info *info) {
- auto *causingaddr = (byte *) info->addr;
- if(causingaddr < _addr || causingaddr >= (_addr + _reservation))
- {
- // Not caused by this map
- thrd_raise_signal(info->signo, info->raw_info, info->raw_context);
- abort();
- }
- return true;
+ [&](const QUICKCPPLIB_NAMESPACE::signal_guard::raised_signal_info *info)
+ {
+ auto *causingaddr = (byte *) info->addr;
+ if(causingaddr < _addr || causingaddr >= (_addr + _reservation))
+ {
+ // Not caused by this map
+ thrd_raise_signal(info->signo, info->raw_info, info->raw_context);
+ abort();
+ }
+ return true;
}))
- {
- return errc::no_space_on_device;
- }
+ {
+ return errc::no_space_on_device;
+ }
+#endif
return reqs.buffers;
}
diff --git a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
index f3366d5c..fcdee58a 100644
--- a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
@@ -27,7 +27,10 @@ Distributed under the Boost Software License, Version 1.0.
#include "import.hpp"
#include "quickcpplib/algorithm/hash.hpp"
+
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
#include "quickcpplib/signal_guard.hpp"
+#endif
LLFIO_V2_NAMESPACE_BEGIN
@@ -1076,45 +1079,51 @@ map_handle::io_result<map_handle::const_buffers_type> map_handle::_do_write(io_r
}
byte *addr = _addr + reqs.offset + (_offset & 65535);
size_type togo = reqs.offset < _length ? static_cast<size_type>(_length - reqs.offset) : 0;
+#ifndef LLFIO_DISABLE_SIGNAL_GUARD
if(QUICKCPPLIB_NAMESPACE::signal_guard::signal_guard(
QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::undefined_memory_access | QUICKCPPLIB_NAMESPACE::signal_guard::signalc_set::segmentation_fault,
+#endif
[&]
{
- for(size_t i = 0; i < reqs.buffers.size(); i++)
- {
- const_buffer_type &req = reqs.buffers[i];
- if(req.size() > togo)
- {
- assert(req.data() != nullptr);
- memcpy(addr, req.data(), togo);
- req = {addr, togo};
- reqs.buffers = {reqs.buffers.data(), i + 1};
- return false;
- }
- else
- {
- assert(req.data() != nullptr);
- memcpy(addr, req.data(), req.size());
- req = {addr, req.size()};
- addr += req.size();
- togo -= req.size();
- }
- }
- return false;
+ for(size_t i = 0; i < reqs.buffers.size(); i++)
+ {
+ const_buffer_type &req = reqs.buffers[i];
+ if(req.size() > togo)
+ {
+ assert(req.data() != nullptr);
+ memcpy(addr, req.data(), togo);
+ req = {addr, togo};
+ reqs.buffers = {reqs.buffers.data(), i + 1};
+ return false;
+ }
+ else
+ {
+ assert(req.data() != nullptr);
+ memcpy(addr, req.data(), req.size());
+ req = {addr, req.size()};
+ addr += req.size();
+ togo -= req.size();
+ }
+ }
+ return false;
+#ifdef LLFIO_DISABLE_SIGNAL_GUARD
+ }();
+#else
},
[&](const QUICKCPPLIB_NAMESPACE::signal_guard::raised_signal_info *info)
{
- auto *causingaddr = (byte *) info->addr;
- if(causingaddr < _addr || causingaddr >= (_addr + _length))
- {
- // Not caused by this map
- thrd_raise_signal(info->signo, info->raw_info, info->raw_context);
- }
- return true;
+ auto *causingaddr = (byte *) info->addr;
+ if(causingaddr < _addr || causingaddr >= (_addr + _length))
+ {
+ // Not caused by this map
+ thrd_raise_signal(info->signo, info->raw_info, info->raw_context);
+ }
+ return true;
}))
- {
- return errc::no_space_on_device;
- }
+ {
+ return errc::no_space_on_device;
+ }
+#endif
return reqs.buffers;
}