Skip to content

Commit

Permalink
Worker init clarification; Inform on error thread notification failure
Browse files Browse the repository at this point in the history
  • Loading branch information
VirrageS authored and apaszke committed May 1, 2017
1 parent e7f453b commit 280e2a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion torch/lib/THD/master_worker/common/CommandChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string>
#include <stdexcept>
#include <utility>
#include <iostream>

namespace thd {
namespace {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions torch/lib/THD/master_worker/master/Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 280e2a9

Please sign in to comment.