Skip to content
Open
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
14 changes: 12 additions & 2 deletions tensorpipe/transport/shm/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ Connection::~Connection() {
void Connection::start() {
// Create ringbuffer for inbox.
std::shared_ptr<util::ringbuffer::RingBuffer> inboxRingBuffer;
std::tie(inboxHeaderFd_, inboxDataFd_, inboxRingBuffer) =
util::ringbuffer::shm::create(kDefaultSize);
try {
std::tie(inboxHeaderFd_, inboxDataFd_, inboxRingBuffer) =
util::ringbuffer::shm::create(kDefaultSize);
} catch (std::system_error& e) {
state_ = INITIALIZING_ERROR;
// Triggers destructor.
TP_THROW_SYSTEM(errno) << "Error while creating shm with " << kDefaultSize
<< " bytes";
}
inbox_.emplace(std::move(inboxRingBuffer));

// Register method to be called when our peer writes to our inbox.
Expand Down Expand Up @@ -429,6 +436,9 @@ void Connection::close() {
// can't extend its lifetime by capturing a shared_ptr and increasing its
// refcount.
std::unique_lock<std::mutex> guard(mutex_);
if (state_ == INITIALIZING_ERROR) {
return;
}
closeHoldingMutex();
}

Expand Down
1 change: 1 addition & 0 deletions tensorpipe/transport/shm/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Connection final : public transport::Connection,

enum State {
INITIALIZING = 1,
INITIALIZING_ERROR,
SEND_FDS,
RECV_FDS,
ESTABLISHED,
Expand Down