Skip to content

Commit

Permalink
JTASK-1062: always retry connection to master
Browse files Browse the repository at this point in the history
  • Loading branch information
nojima committed Jul 9, 2024
1 parent 77e85be commit 96c581b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/memcache/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,19 @@ void handler::on_master_end() {
}

bool handler::on_slave_start() {
using logger = cybozu::logger;

auto master_host = g_config.master_host();
int fd = cybozu::tcp_connect(master_host.c_str(),
g_config.repl_port());
int fd;
try {
fd = cybozu::tcp_connect(master_host.c_str(), g_config.repl_port());
} catch( std::runtime_error& err ) {
logger::error() << "Failed to connect to the master (" << master_host << "): " << err.what();
m_reactor.run_once();
return false;
}
if( fd == -1 ) {
logger::error() << "Failed to connect to the master (" << master_host << ")";
m_reactor.run_once();
return false;
}
Expand Down

0 comments on commit 96c581b

Please sign in to comment.