mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 18:11:49 +00:00
feat(ofi): Require asiofi 0.5
* Modernize some ofi transport code along the way * Replace Boost.Container with `<memory_resource>` * Introduce namespaced headers * `<fairmq/Channel.h>` * `<fairmq/Message.h>` * `<fairmq/Poller.h>` * `<fairmq/Socket.h>` * `<fairmq/TransportFactory.h>` * `<fairmq/UnmanagedRegion.h>` * Compile-firewall Boost.Process in `shmem::Manager` because it conflicts with standalone asio
This commit is contained in:
committed by
Dennis Klein
parent
9585c20b7f
commit
1007de8e49
48
fairmq/shmem/Manager.cxx
Normal file
48
fairmq/shmem/Manager.cxx
Normal file
@@ -0,0 +1,48 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "Manager.h"
|
||||
|
||||
// Needed to compile-firewall the <boost/process/async.hpp> header because it
|
||||
// interferes with the <asio/buffer.hpp> header. So, let's factor
|
||||
// the whole dependency to Boost.Process out of the header.
|
||||
#include <boost/process.hpp>
|
||||
#include <fairlogger/Logger.h>
|
||||
|
||||
namespace fair::mq::shmem {
|
||||
|
||||
bool Manager::SpawnShmMonitor(const std::string& id)
|
||||
{
|
||||
auto const env(boost::this_process::environment());
|
||||
std::string const fairmq_path_key("FAIRMQ_PATH");
|
||||
std::string const shmmonitor_exe_name("fairmq-shmmonitor");
|
||||
std::string const shmmonitor_verbose_key("FAIRMQ_SHMMONITOR_VERBOSE");
|
||||
auto path(boost::this_process::path());
|
||||
|
||||
if (env.count(fairmq_path_key)) {
|
||||
path.emplace(path.begin(), env.at(fairmq_path_key).to_string());
|
||||
}
|
||||
|
||||
auto exe(boost::process::search_path(shmmonitor_exe_name, path));
|
||||
if (exe.empty()) {
|
||||
LOG(warn) << "could not find " << shmmonitor_exe_name << " in \"$" << fairmq_path_key
|
||||
<< ":$PATH\"";
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Move this to fairmq-shmmonitor itself ?
|
||||
bool verbose(env.count(shmmonitor_verbose_key)
|
||||
&& env.at(shmmonitor_verbose_key).to_string() == "true");
|
||||
|
||||
boost::process::spawn(
|
||||
exe, "-x", "-m", "--shmid", id, "-d", "-t", "2000", (verbose ? "--verbose" : ""), env);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace fair::mq::shmem
|
@@ -1,5 +1,5 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||
#include <boost/interprocess/sync/named_condition.hpp>
|
||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <condition_variable>
|
||||
@@ -240,6 +239,10 @@ class Manager
|
||||
LOG(debug) << "Successfully locked the managed segment memory pages.";
|
||||
}
|
||||
|
||||
private:
|
||||
static bool SpawnShmMonitor(const std::string& id);
|
||||
|
||||
public:
|
||||
static void StartMonitor(const std::string& id)
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
@@ -248,25 +251,8 @@ class Manager
|
||||
LOG(debug) << "Found fairmq-shmmonitor for shared memory id " << id;
|
||||
} catch (interprocess_exception&) {
|
||||
LOG(debug) << "no fairmq-shmmonitor found for shared memory id " << id << ", starting...";
|
||||
auto env = boost::this_process::environment();
|
||||
|
||||
std::vector<boost::filesystem::path> ownPath = boost::this_process::path();
|
||||
|
||||
if (const char* fmqp = getenv("FAIRMQ_PATH")) {
|
||||
ownPath.insert(ownPath.begin(), boost::filesystem::path(fmqp));
|
||||
}
|
||||
|
||||
boost::filesystem::path p = boost::process::search_path("fairmq-shmmonitor", ownPath);
|
||||
|
||||
bool verbose = false;
|
||||
if (const char* verboseEnv = getenv("FAIRMQ_SHMMONITOR_VERBOSE")) {
|
||||
if (std::string(verboseEnv) == "true") {
|
||||
verbose = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.empty()) {
|
||||
boost::process::spawn(p, "-x", "-m", "--shmid", id, "-d", "-t", "2000", (verbose ? "--verbose" : ""), env);
|
||||
if (SpawnShmMonitor(id)) {
|
||||
int numTries = 0;
|
||||
do {
|
||||
try {
|
||||
@@ -281,8 +267,6 @@ class Manager
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
} else {
|
||||
LOG(warn) << "could not find fairmq-shmmonitor in the path";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* Region.h
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <fairmq/tools/Strings.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||
#include <boost/interprocess/file_mapping.hpp>
|
||||
|
Reference in New Issue
Block a user