X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/7312c5fd3b74fd9cad485121bc31fc501accd355..eeab3e6cade87c1fe0a5f3d93522e12ccb9ec2ab:/rsm.cc diff --git a/rsm.cc b/rsm.cc index bdeabaa..65f60c7 100644 --- a/rsm.cc +++ b/rsm.cc @@ -116,7 +116,7 @@ rsm::rsm(std::string _first, std::string _me) : 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); @@ -132,7 +132,7 @@ void rsm::reg1(int proc, handler *h) { } // The recovery thread runs this function -void rsm::recovery() { +void rsm::recovery() [[noreturn]] { bool r = true; lock ml(rsm_mutex); @@ -141,7 +141,7 @@ void rsm::recovery() { // 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(); @@ -150,13 +150,13 @@ void rsm::recovery() { } } 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 @@ -168,7 +168,7 @@ void rsm::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); } } @@ -192,7 +192,7 @@ bool rsm::sync_with_backups() { // 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 @@ -279,8 +279,7 @@ bool rsm::join(std::string m) { 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); @@ -294,11 +293,10 @@ bool rsm::join(std::string m) { } 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; } @@ -356,7 +354,7 @@ rsm_client_protocol::status rsm::client_invoke(std::string &r, int procno, std:: std::string myaddr; viewstamp vs; { - lock ml(rsm_mutex); + lock ml2(rsm_mutex); LOG("Checking for inviewchange"); if (inviewchange) return rsm_client_protocol::BUSY; @@ -382,8 +380,8 @@ rsm_client_protocol::status rsm::client_invoke(std::string &r, int procno, std:: 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; @@ -409,7 +407,7 @@ rsm_protocol::status rsm::invoke(int &, int proc, viewstamp vs, std::string req) std::vector m; std::string myaddr; { - lock ml(rsm_mutex); + lock ml2(rsm_mutex); // check if !inviewchange LOG("Checking for view change"); if (inviewchange) @@ -508,7 +506,7 @@ rsm_protocol::status rsm::joinreq(rsm_protocol::joinres &r, std::string m, views * so the client can switch to a different primary * when it existing primary fails */ -rsm_client_protocol::status rsm::client_members(std::vector &r, int i) { +rsm_client_protocol::status rsm::client_members(std::vector &r, int) { std::vector m; lock ml(rsm_mutex); cfg->get_view(vid_commit, m);