- void get_refconn(shared_ptr<connection> & ch);
- void update_xid_rep(xid_t xid);
+ void get_latest_connection(shared_ptr<connection> & ch);
+ void update_xid_rep(xid_t xid, lock & m_lock);
- int call1(proc_id_t proc, marshall &req, string &rep, milliseconds to);
+ int call1(proc_id_t proc, milliseconds to, string & rep, marshall & req);
- int call_m(proc_id_t proc, marshall &req, R & r, milliseconds to) {
+ inline int call_m(proc_id_t proc, milliseconds to, R & r, marshall && req) {
- int intret = call1(proc, req, rep, to);
- unmarshall u(rep, true);
+ int intret = call1(proc, to, rep, req);
if (u.okdone() != true) {
LOG("rpcc::call_m: failed to unmarshall the reply. You are probably " <<
"calling RPC 0x" << hex << proc << " with the wrong return type.");
VERIFY(0);
if (u.okdone() != true) {
LOG("rpcc::call_m: failed to unmarshall the reply. You are probably " <<
"calling RPC 0x" << hex << proc << " with the wrong return type.");
VERIFY(0);
return call_timeout(proc, rpc::to_max, r, args...);
}
template<class P, class R, typename ...Args>
return call_timeout(proc, rpc::to_max, r, args...);
}
template<class P, class R, typename ...Args>
- inline int call_timeout(proc_t<P> proc, milliseconds to, R & r, const Args&... args) {
+ inline int call_timeout(proc_t<P> proc, milliseconds to, R & r, const Args & ... args) {
static_assert(is_valid_call<P, R, Args...>::value, "RPC called with incorrect argument types");
static_assert(is_valid_call<P, R, Args...>::value, "RPC called with incorrect argument types");
- marshall m{args...};
- return call_m(proc.id, m, r, to);
+ return call_m(proc.id, to, r, forward<marshall>(marshall(args...)));
// indexed by client nonce.
map<nonce_t, list<reply_t>> reply_window_;
// indexed by client nonce.
map<nonce_t, list<reply_t>> reply_window_;
xid_t rep_xid, string & b);
// latest connection to the client
map<nonce_t, shared_ptr<connection>> conns_;
xid_t rep_xid, string & b);
// latest connection to the client
map<nonce_t, shared_ptr<connection>> conns_;
// map proc # to function
map<proc_id_t, handler *> procs_;
// map proc # to function
map<proc_id_t, handler *> procs_;
- // internal handler registration
- void reg1(proc_id_t proc, handler *);
-
- unique_ptr<thread_pool> dispatchpool_;
+ unique_ptr<thread_pool> dispatchpool_{new thread_pool(6, false)};
static_assert(is_valid_registration<P, F>::value, "RPC handler registered with incorrect argument types");
struct ReturnOnFailure {
static inline int unmarshall_args_failure() {
static_assert(is_valid_registration<P, F>::value, "RPC handler registered with incorrect argument types");
struct ReturnOnFailure {
static inline int unmarshall_args_failure() {
- reg1(proc.id, marshalled_func<F, ReturnOnFailure>::wrap(f, c));
+ lock pl(procs_m_);
+ VERIFY(procs_.count(proc.id) == 0);
+ procs_[proc.id] = marshalled_func<F, ReturnOnFailure>::wrap(f, c);
+ VERIFY(procs_.count(proc.id) >= 1);