rsmrpc->reg(rsm_protocol::joinreq, &rsm::joinreq, this);
// tester must be on different port, otherwise it may partition itself
- testsvr = new rpcs(atoi(_me.c_str()) + 1);
+ testsvr = new rpcs((uint32_t)std::stoi(_me) + 1);
testsvr->reg(rsm_test_protocol::net_repair, &rsm::test_net_repairreq, this);
testsvr->reg(rsm_test_protocol::breakpoint, &rsm::breakpointreq, this);
}
// The recovery thread runs this function
-void rsm::recovery() {
+void rsm::recovery() [[noreturn]] {
bool r = true;
lock ml(rsm_mutex);
// XXX iannucci 2013/09/15 -- I don't understand whether accessing
// cfg->view_id in this manner involves a race. I suspect not.
if (join(primary)) {
- tprintf("recovery: joined\n");
+ LOG("recovery: joined");
commit_change_wo(cfg->view_id());
} else {
ml.unlock();
}
}
vid_insync = vid_commit;
- tprintf("recovery: sync vid_insync %d\n", vid_insync);
+ LOG("recovery: sync vid_insync " << vid_insync);
if (primary == cfg->myaddr()) {
r = sync_with_backups();
} else {
r = sync_with_primary();
}
- tprintf("recovery: sync done\n");
+ LOG("recovery: sync done");
// If there was a commited viewchange during the synchronization, restart
// the recovery
myvs.seqno = 1;
inviewchange = false;
}
- tprintf("recovery: go to sleep %d %d\n", insync, inviewchange);
+ LOG("recovery: go to sleep " << insync << " " << inviewchange);
recovery_cond.wait(ml);
}
}
// Make sure that the state of lock_server is stable during
// synchronization; otherwise, the primary's state may be more recent
// than replicas after the synchronization.
- lock ml(invoke_mutex);
+ lock ml2(invoke_mutex);
// By acquiring and releasing the invoke_mutex once, we make sure that
// the state of lock_server will not be changed until all
// replicas are synchronized. The reason is that client_invoke arrives
int ret = 0;
rsm_protocol::joinres r;
- tprintf("rsm::join: %s mylast (%d,%d)\n", m.c_str(), last_myvs.vid,
- last_myvs.seqno);
+ LOG("rsm::join: " << m << " mylast (" << last_myvs.vid << "," << last_myvs.seqno << ")");
rpcc *cl;
{
adopt_lock ml(rsm_mutex);
}
if (cl == 0 || ret != rsm_protocol::OK) {
- tprintf("rsm::join: couldn't reach %s %p %d\n", m.c_str(),
- cl, ret);
+ LOG("rsm::join: couldn't reach " << m << " " << std::hex << cl << " " << std::dec << ret);
return false;
}
- tprintf("rsm::join: succeeded %s\n", r.log.c_str());
+ LOG("rsm::join: succeeded " << r.log);
cfg->restore(r.log);
return true;
}
std::string myaddr;
viewstamp vs;
{
- lock ml(rsm_mutex);
+ lock ml2(rsm_mutex);
LOG("Checking for inviewchange");
if (inviewchange)
return rsm_client_protocol::BUSY;
if (!cl)
return rsm_client_protocol::BUSY;
rsm_protocol::status ret;
- int r;
- ret = cl->call_timeout(rsm_protocol::invoke, rpcc::to(1000), r, procno, vs, req);
+ int ignored_rval;
+ ret = cl->call_timeout(rsm_protocol::invoke, rpcc::to(1000), ignored_rval, procno, vs, req);
LOG("Invoke returned " << ret);
if (ret != rsm_protocol::OK)
return rsm_client_protocol::BUSY;
std::vector<std::string> m;
std::string myaddr;
{
- lock ml(rsm_mutex);
+ lock ml2(rsm_mutex);
// check if !inviewchange
LOG("Checking for view change");
if (inviewchange)
* so the client can switch to a different primary
* when it existing primary fails
*/
-rsm_client_protocol::status rsm::client_members(std::vector<std::string> &r, int i) {
+rsm_client_protocol::status rsm::client_members(std::vector<std::string> &r, int) {
std::vector<std::string> m;
lock ml(rsm_mutex);
cfg->get_view(vid_commit, m);