// The rule is that a module releases its internal locks before it
// upcalls, but can keep its locks when calling down.
-#include <fstream>
-#include <iostream>
-#include <algorithm>
#include <sys/types.h>
#include <unistd.h>
+#include "types.h"
#include "handle.h"
#include "rsm.h"
-#include "threaded_log.h"
-#include "lang/verify.h"
#include "rsm_client.h"
-#include "lock.h"
rsm::rsm(std::string _first, std::string _me) :
stf(0), primary(_first), insync (false), inviewchange (true), vid_commit(0),
insync = true;
cfg->get_view(vid_insync, backups);
backups.erase(find(backups.begin(), backups.end(), cfg->myaddr()));
- LOG("rsm::sync_with_backups " << make_iterator_pair(backups.begin(), backups.end()));
+ LOG("rsm::sync_with_backups " << backups);
sync_cond.wait(rsm_mutex_lock);
insync = false;
return true;
bool rsm::join(std::string m, lock & rsm_mutex_lock) {
handle h(m);
int ret = 0;
- rsm_protocol::joinres r;
+ string log;
LOG("rsm::join: " << m << " mylast (" << last_myvs.vid << "," << last_myvs.seqno << ")");
rpcc *cl;
rsm_mutex_lock.unlock();
cl = h.safebind();
if (cl != 0) {
- ret = cl->call_timeout(rsm_protocol::joinreq, rpcc::to(120000), r,
+ ret = cl->call_timeout(rsm_protocol::joinreq, rpcc::to(120000), log,
cfg->myaddr(), last_myvs);
}
rsm_mutex_lock.lock();
LOG("rsm::join: couldn't reach " << m << " " << std::hex << cl << " " << std::dec << ret);
return false;
}
- LOG("rsm::join: succeeded " << r.log);
- cfg->restore(r.log);
+ LOG("rsm::join: succeeded " << log);
+ cfg->restore(log);
return true;
}
// a node that wants to join an RSM as a server sends a
// joinreq to the RSM's current primary; this is the
// handler for that RPC.
-rsm_protocol::status rsm::joinreq(rsm_protocol::joinres &r, std::string m, viewstamp last) {
+rsm_protocol::status rsm::joinreq(string & log, std::string m, viewstamp last) {
auto ret = rsm_protocol::OK;
lock ml(rsm_mutex);
last_myvs.vid << "," << last_myvs.seqno << ")");
if (cfg->ismember(m, vid_commit)) {
LOG("joinreq: is still a member");
- r.log = cfg->dump();
+ log = cfg->dump();
} else if (cfg->myaddr() != primary) {
LOG("joinreq: busy");
ret = rsm_protocol::BUSY;
ml.lock();
}
if (cfg->ismember(m, cfg->view_id())) {
- r.log = cfg->dump();
- LOG("joinreq: ret " << ret << " log " << r.log);
+ log = cfg->dump();
+ LOG("joinreq: ret " << ret << " log " << log);
} else {
LOG("joinreq: failed; proposer couldn't add " << succ);
ret = rsm_protocol::BUSY;