Skip to content

Commit

Permalink
shm: throw TransportError if could not lock region
Browse files Browse the repository at this point in the history
  • Loading branch information
rbx committed Jun 15, 2021
1 parent 37c0591 commit a8bdb91
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fairmq/shmem/Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#define FAIR_MQ_SHMEM_MANAGER_H_

#include "Common.h"
#include "Region.h"
#include "Monitor.h"
#include "Region.h"

#include <fairmq/ProgOptions.h>
#include <fairmq/tools/Strings.h>
Expand All @@ -34,18 +34,18 @@
#include <boost/process.hpp>
#include <boost/variant.hpp>

#include <cstdlib> // getenv
#include <condition_variable>
#include <cstdlib> // getenv
#include <memory> // make_unique
#include <mutex>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <utility> // pair
#include <tuple>
#include <vector>

#include <unistd.h> // getuid
Expand Down Expand Up @@ -194,6 +194,7 @@ class Manager
LOG(debug) << "Locking the managed segment memory pages...";
if (mlock(boost::apply_visitor(SegmentAddress(), fSegments.at(fSegmentId)), boost::apply_visitor(SegmentSize(), fSegments.at(fSegmentId))) == -1) {
LOG(error) << "Could not lock the managed segment memory. Code: " << errno << ", reason: " << strerror(errno);
throw TransportError(tools::ToString("Could not lock the managed segment memory: ", strerror(errno)));
}
LOG(debug) << "Successfully locked the managed segment memory pages.";
}
Expand Down Expand Up @@ -323,6 +324,7 @@ class Manager
LOG(debug) << "Locking region " << id << "...";
if (mlock(r.first->second->fRegion.get_address(), r.first->second->fRegion.get_size()) == -1) {
LOG(error) << "Could not lock region " << id << ". Code: " << errno << ", reason: " << strerror(errno);
throw TransportError(tools::ToString("Could not lock region ", id, ": ", strerror(errno)));
}
LOG(debug) << "Successfully locked region " << id << ".";
}
Expand Down

0 comments on commit a8bdb91

Please sign in to comment.