#ifndef rsm_client_h
#define rsm_client_h
-#include "rpc/rpc.h"
+#include "types.h"
#include "rsm_protocol.h"
-#include <string>
-#include <vector>
-
//
// rsm client interface.
std::string primary;
std::vector<std::string> known_mems;
std::mutex rsm_client_mutex;
- void primary_failure();
- bool init_members();
+ void primary_failure(lock & rsm_client_mutex_lock);
+ bool init_members(lock & rsm_client_mutex_lock);
public:
rsm_client(std::string dst);
- rsm_protocol::status invoke(int proc, std::string &rep, const std::string &req);
+ rsm_protocol::status invoke(unsigned int proc, std::string &rep, const std::string &req);
template<class R, class ...Args>
int call(unsigned int proc, R & r, const Args & ...a1);
template<class R>
int rsm_client::call_m(unsigned int proc, R & r, const marshall & req) {
- std::string rep;
- std::string res;
- int intret = invoke(proc, rep, req.cstr());
- VERIFY( intret == rsm_client_protocol::OK );
- unmarshall u(rep);
- u >> intret;
- if (intret < 0) return intret;
- u >> res;
- if (!u.okdone()) {
- fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
- "You probably forgot to set the reply string in "
- "rsm::client_invoke, or you may call RPC 0x%x with wrong return "
- "type\n", proc);
- VERIFY(0);
- return rpc_const::unmarshal_reply_failure;
- }
- unmarshall u1(res);
- u1 >> r;
- if(!u1.okdone()) {
- fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
- "You are probably calling RPC 0x%x with wrong return "
- "type.\n", proc);
- VERIFY(0);
- return rpc_const::unmarshal_reply_failure;
- }
- return intret;
+ std::string rep;
+ std::string res;
+ int intret = invoke(proc, rep, req.cstr());
+ VERIFY( intret == rsm_client_protocol::OK );
+ unmarshall u(rep);
+ u >> intret;
+ if (intret < 0) return intret;
+ u >> res;
+ if (!u.okdone()) {
+ fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
+ "You probably forgot to set the reply string in "
+ "rsm::client_invoke, or you may call RPC 0x%x with wrong return "
+ "type\n", proc);
+ VERIFY(0);
+ return rpc_const::unmarshal_reply_failure;
+ }
+ unmarshall u1(res);
+ u1 >> r;
+ if(!u1.okdone()) {
+ fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
+ "You are probably calling RPC 0x%x with wrong return "
+ "type.\n", proc);
+ VERIFY(0);
+ return rpc_const::unmarshal_reply_failure;
+ }
+ return intret;
}
template<class R, class ...Args>