stf(0), primary(_first), insync (false), inviewchange (true), vid_commit(0),
partitioned (false), dopartition(false), break1(false), break2(false)
{
- cfg = new config(_first, _me, this);
+ cfg = unique_ptr<config>(new config(_first, _me, this));
if (_first == _me) {
// Commit the first view here. We can not have acceptor::acceptor
rsmrpc->reg(rsm_protocol::joinreq, &rsm::joinreq, this);
// tester must be on different port, otherwise it may partition itself
- testsvr = new rpcs((in_port_t)stoi(_me) + 1);
+ testsvr = unique_ptr<rpcs>(new rpcs((in_port_t)stoi(_me) + 1));
testsvr->reg(rsm_test_protocol::net_repair, &rsm::test_net_repairreq, this);
testsvr->reg(rsm_test_protocol::breakpoint, &rsm::breakpointreq, this);
+}
- {
- lock ml(rsm_mutex);
- thread(&rsm::recovery, this).detach();
- }
+void rsm::start() {
+ lock ml(rsm_mutex);
+ rsmrpc->start();
+ testsvr->start();
+ thread(&rsm::recovery, this).detach();
}
void rsm::reg1(int proc, handler *h) {
commit_change(cfg->view_id(), ml);
} else {
ml.unlock();
- this_thread::sleep_for(seconds(30)); // XXX make another node in cfg primary?
+ this_thread::sleep_for(seconds(3)); // XXX make another node in cfg primary?
ml.lock();
}
}
rsm_mutex_lock.unlock();
cl = h.safebind();
if (cl) {
- ret = cl->call_timeout(rsm_protocol::transferreq, rpcc::to(1000),
+ ret = cl->call_timeout(rsm_protocol::transferreq, milliseconds(100),
r, cfg->myaddr(), last_myvs, vid_insync);
}
rsm_mutex_lock.lock();
rsm_mutex_lock.unlock();
cl = h.safebind();
if (cl != 0) {
- ret = cl->call_timeout(rsm_protocol::joinreq, rpcc::to(120000), log,
+ ret = cl->call_timeout(rsm_protocol::joinreq, milliseconds(12000), log,
cfg->myaddr(), last_myvs);
}
rsm_mutex_lock.lock();
if (!cl)
return rsm_client_protocol::BUSY;
int ignored_rval;
- auto ret = (rsm_protocol::status)cl->call_timeout(rsm_protocol::invoke, rpcc::to(1000), ignored_rval, procno, vs, req);
+ auto ret = (rsm_protocol::status)cl->call_timeout(rsm_protocol::invoke, milliseconds(100), ignored_rval, procno, vs, req);
LOG("Invoke returned " << ret);
if (ret != rsm_protocol::OK)
return rsm_client_protocol::BUSY;