}
int rpcc::bind(milliseconds to) {
- nonce_t r;
+ nonce_t r = 0;
rpc_protocol::status ret = call_timeout(rpc_protocol::bind, to, r);
if (ret == 0) {
lock ml(m_);
ca.xid = xid_++;
calls_[ca.xid] = &ca;
- req.pack_header(rpc_protocol::request_header{
+ req.write_header(rpc_protocol::request_header{
ca.xid, proc, clt_nonce_, srv_nonce_, xid_rep_window_.front()
});
xid_rep = xid_rep_window_.front();
ch->send(req);
}
else IF_LEVEL(1) LOG << "not reachable";
- IF_LEVEL(2) LOG << clt_nonce_ << " just sent req proc " << hex << proc
- << " xid " << dec << ca.xid << " clt_nonce " << clt_nonce_;
+ IF_LEVEL(2) LOG << clt_nonce_ << " just sent req proc " << std::hex << proc
+ << " xid " << std::dec << ca.xid << " clt_nonce " << clt_nonce_;
}
transmit = false; // only send once on a given channel
}
- auto nextdeadline = min(steady_clock::now() + curr_to, finaldeadline);
+ auto nextdeadline = std::min(steady_clock::now() + curr_to, finaldeadline);
curr_to *= 2;
{
lock cal(ca.m);
- IF_LEVEL(2) LOG << clt_nonce_ << " call done for req proc " << hex << proc
- << " xid " << dec << ca.xid << " " << inet_ntoa(dst_.sin_addr) << ":"
+ IF_LEVEL(2) LOG << clt_nonce_ << " call done for req proc " << std::hex << proc
+ << " xid " << std::dec << ca.xid << " " << inet_ntoa(dst_.sin_addr) << ":"
<< ntoh(dst_.sin_port) << " done? " << ca.done << " ret " << ca.intret;
// destruction of req automatically frees its buffer
{
unmarshall rep(b, true);
rpc_protocol::reply_header h;
- rep.unpack_header(h);
+ rep.read_header(h);
if (!rep.ok()) {
IF_LEVEL(1) LOG << "unmarshall header failed!!!";
unmarshall req(buf, true);
rpc_protocol::request_header h;
- req.unpack_header(h);
+ req.read_header(h);
proc_id_t proc = h.proc;
if (!req.ok()) {
return;
}
- IF_LEVEL(2) LOG << "rpc " << h.xid << " (proc " << hex << proc << ", last_rep "
- << dec << h.xid_rep << ") from clt " << h.clt_nonce << " for srv instance " << h.srv_nonce;
+ IF_LEVEL(2) LOG << "rpc " << h.xid << " (proc " << std::hex << proc << ", last_rep "
+ << std::dec << h.xid_rep << ") from clt " << h.clt_nonce << " for srv instance " << h.srv_nonce;
marshall rep;
rpc_protocol::reply_header rh{h.xid,0};
// is client sending to an old instance of server?
if (h.srv_nonce != 0 && h.srv_nonce != nonce_) {
IF_LEVEL(2) LOG << "rpc for an old server instance " << h.srv_nonce
- << " (current " << nonce_ << ") proc " << hex << h.proc;
+ << " (current " << nonce_ << ") proc " << std::hex << h.proc;
rh.ret = rpc_protocol::oldsrv_failure;
- rep.pack_header(rh);
+ rep.write_header(rh);
c->send(rep);
return;
}
{
lock pl(procs_m_);
if (procs_.count(proc) < 1) {
- LOG << "unknown proc 0x" << hex << proc << " with h.srv_nonce=" << h.srv_nonce << ", my srv_nonce=" << nonce_;
+ LOG << "unknown proc 0x" << std::hex << proc << " with h.srv_nonce=" << h.srv_nonce << ", my srv_nonce=" << nonce_;
VERIFY(0);
return;
}
rh.ret = (*f)(forward<unmarshall>(req), rep);
if (rh.ret == rpc_protocol::unmarshall_args_failure) {
LOG << "failed to unmarshall the arguments. You are "
- << "probably calling RPC 0x" << hex << proc << " with the wrong "
+ << "probably calling RPC 0x" << std::hex << proc << " with the wrong "
<< "types of arguments.";
VERIFY(0);
}
VERIFY(rh.ret >= 0);
- rep.pack_header(rh);
+ rep.write_header(rh);
b1 = rep;
IF_LEVEL(2) LOG << "sending and saving reply of size " << b1.size() << " for rpc "
- << h.xid << ", proc " << hex << proc << " ret " << dec << rh.ret << ", clt " << h.clt_nonce;
+ << h.xid << ", proc " << std::hex << proc << " ret " << std::dec
+ << rh.ret << ", clt " << h.clt_nonce;
add_reply(h.clt_nonce, h.xid, b1);
case FORGOTTEN: // very old request and we don't have the response anymore
IF_LEVEL(2) LOG << "very old request " << h.xid << " from " << h.clt_nonce;
rh.ret = rpc_protocol::atmostonce_failure;
- rep.pack_header(rh);
+ rep.write_header(rh);
c->send(rep);
break;
}