From 280e2a94e50d023f0e34525b8b4e73ae7d542f3e Mon Sep 17 00:00:00 2001 From: Janusz Marcinkiewicz Date: Wed, 5 Apr 2017 19:01:55 +0200 Subject: [PATCH] Worker init clarification; Inform on error thread notification failure --- torch/lib/THD/master_worker/common/CommandChannel.cpp | 5 ++++- torch/lib/THD/master_worker/master/Master.cpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/torch/lib/THD/master_worker/common/CommandChannel.cpp b/torch/lib/THD/master_worker/common/CommandChannel.cpp index 7dff7de98c330e..4b4c4db55f019c 100644 --- a/torch/lib/THD/master_worker/common/CommandChannel.cpp +++ b/torch/lib/THD/master_worker/common/CommandChannel.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace thd { namespace { @@ -55,7 +56,9 @@ MasterCommandChannel::MasterCommandChannel() MasterCommandChannel::~MasterCommandChannel() { if (_error_thread.joinable()) { - ::write(_error_pipe, "exit", 4); + if (::write(_error_pipe, "exit", 4) != 4) { + std::cerr << "Failed to notify error thread" << std::endl; + } _error_thread.join(); ::close(_error_pipe); diff --git a/torch/lib/THD/master_worker/master/Master.cpp b/torch/lib/THD/master_worker/master/Master.cpp index 812fe64d9074d5..63db2c044654f5 100644 --- a/torch/lib/THD/master_worker/master/Master.cpp +++ b/torch/lib/THD/master_worker/master/Master.cpp @@ -20,8 +20,9 @@ bool THDMasterWorkerInit(THDChannelType channel_type) { if (dataChannel->getRank() > 0) { /* - * Worker initialization. If initialization succeeds it goes into - * infinite loop in which waits for commands from master. + * Worker initialization. It goes into infinite loop in which waits + * for commands from master. Returning from `THDWorkerMain` indicates + * a failure so it will `return false`. */ THDWorkerMain(); return false;