X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/a5f10a497bebfc680bf418193f1fd9f1ad7cc417..c06ef44e7af1571710fd31dd0ab068dd77b1eb2d:/rsm_client.h diff --git a/rsm_client.h b/rsm_client.h index 2a9c8c4..90b5b06 100644 --- a/rsm_client.h +++ b/rsm_client.h @@ -15,18 +15,20 @@ class rsm_client { protected: string primary; - vector known_mems; - mutex rsm_client_mutex; + std::vector known_mems; + std::mutex rsm_client_mutex; void primary_failure(lock & rsm_client_mutex_lock); bool init_members(lock & rsm_client_mutex_lock); + rsm_protocol::status invoke(unsigned int proc, string & rep, const string & req); + template int call_m(unsigned int proc, R & r, const marshall & req); public: rsm_client(string dst); - rsm_protocol::status invoke(unsigned int proc, string &rep, const string &req); - template - int call(unsigned int proc, R & r, const Args & ...a1); - private: - template int call_m(unsigned int proc, R & r, const marshall & req); + template + inline int call(rpc_protocol::proc_t

proc, R & r, const Args & ...a1) { + static_assert(is_valid_call::value, "RSM method invoked with incorrect argument types"); + return call_m(proc.id, r, marshall(a1...)); + } }; inline string hexify(const string & s) { @@ -41,38 +43,30 @@ inline string hexify(const string & s) { template int rsm_client::call_m(unsigned int proc, R & r, const marshall & req) { string rep; - string res; int intret = invoke(proc, rep, req.content()); VERIFY( intret == rsm_client_protocol::OK ); - unmarshall u(rep, false); - u >> intret; + unmarshall u(rep, false, intret); if (intret < 0) return intret; + string res; u >> res; if (!u.okdone()) { - LOG("failed to unmarshall the reply."); - LOG("You probably forgot to set the reply string in " << - "rsm::client_invoke, or you may have called RPC " << - "0x" << hex << proc << " with the wrong return type"); - LOG("here's what I got: \"" << hexify(rep) << "\""); + LOG << "failed to unmarshall the reply."; + LOG << "You probably forgot to set the reply string in " + << "rsm::client_invoke, or you may have called RPC " + << "0x" << std::hex << proc << " with the wrong return type"; + LOG << "here's what I got: \"" << hexify(rep) << "\""; VERIFY(0); - return rpc_const::unmarshal_reply_failure; + return rpc_protocol::unmarshall_reply_failure; } - unmarshall u1(res, false); - u1 >> r; - if(!u1.okdone()) { - LOG("failed to unmarshall the reply."); - LOG("You are probably calling RPC 0x" << hex << proc << - " with the wrong return type."); - LOG("here's what I got: \"" << hexify(res) << "\""); + if(!unmarshall(res, false, r).okdone()) { + LOG << "failed to unmarshall the reply."; + LOG << "You are probably calling RPC 0x" << std::hex << proc + << " with the wrong return type."; + LOG << "here's what I got: \"" << hexify(res) << "\""; VERIFY(0); - return rpc_const::unmarshal_reply_failure; + return rpc_protocol::unmarshall_reply_failure; } return intret; } -template -int rsm_client::call(unsigned int proc, R & r, const Args & ...a1) { - return call_m(proc, r, marshall{a1...}); -} - #endif