Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using native interprocess mechanisms [12670] (backport #2259) #2263

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,21 @@ class SharedMemManager :
};

SharedMemManager(
const std::string& domain_name)
const std::string& domain_name,
uint32_t alloc_extra_size)
: segments_mem_(0)
, global_segment_(domain_name)
, watch_task_(SegmentWrapper::WatchTask::get())
{
static_assert(std::alignment_of<BufferNode>::value % 8 == 0, "SharedMemManager::BufferNode bad alignment");
per_allocation_extra_size_ = alloc_extra_size;
}

public:

static std::shared_ptr<SharedMemManager> create(
const std::string& domain_name)
{
if (domain_name.length() > SharedMemGlobal::MAX_DOMAIN_NAME_LENGTH)
{
throw std::runtime_error(
Expand All @@ -243,17 +251,9 @@ class SharedMemManager :
" characters");
}

per_allocation_extra_size_ =
SharedMemSegment::compute_per_allocation_extra_size(std::alignment_of<BufferNode>::value,
domain_name);
}

public:

static std::shared_ptr<SharedMemManager> create(
const std::string& domain_name)
{
return std::shared_ptr<SharedMemManager>(new SharedMemManager(domain_name));
uint32_t extra_size =
SharedMemSegment::compute_per_allocation_extra_size(std::alignment_of<BufferNode>::value, domain_name);
return std::shared_ptr<SharedMemManager>(new SharedMemManager(domain_name, extra_size));
}

~SharedMemManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define BOOST_INTERPROCESS_WINDOWS
#define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
#if !defined(BOOST_FASTDDS_PATCHES)
#define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
#endif
#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
//Define this to connect with shared memory created with versions < 1.54
//#define BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME
Expand Down
22 changes: 9 additions & 13 deletions thirdparty/boost/include/boostconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
#define BOOST_DATE_TIME_NO_LIB
#define BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING
#define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 1000

// We have patched part of the boost code, protecting all changes with this define
#define BOOST_FASTDDS_PATCHES

#ifdef __APPLE__
#define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
#endif // ifdef __APPLE__
// Starting on boost 1.76.0, this will force native emulation, which is what we want as
// it is more performant
#define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION

#ifdef _MSC_VER

Expand All @@ -31,20 +33,14 @@
#include <sys/stat.h>
#include <stdexcept>

//#define BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME

// TODO(Adolfo): This will fail if windows system without program data in C: drive
#define BOOST_INTERPROCESS_SHARED_DIR_PATH "C:\\ProgramData\\eprosima\\fastrtps_interprocess"

// Check that generic emulation has not been accidentally enabled
#include <boost/interprocess/detail/workaround.hpp>
#define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
/*#if defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION)
#error "BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION must be disabled in boost/interprocess/detail/workarround.hpp"
#endif*/

// Todo(Adolfo): BlackBox.SHMTransportPubSub fail with BOOST_INTERPROCESS_USE_WINDOWS
//#define BOOST_INTERPROCESS_USE_WINDOWS
//#define BOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED
#if defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION)
# error "BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION must be disabled in boost/interprocess/detail/workarround.hpp"
#endif // BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION

#endif // _MSC_VER_

Expand Down