#include "rsm_client.h"
#include <arpa/inet.h>
-#include <handle.h>
#include <unistd.h>
rsm_client::rsm_client(string dst) : primary(dst) {
lock ml(rsm_client_mutex);
while (1) {
LOG << "proc " << std::hex << proc << " primary " << primary;
- handle h(primary);
+ string prim = primary;
ml.unlock();
- rpcc *cl = h.safebind();
+ auto cl = rpcc::bind_cached(prim);
auto ret = rsm_client_protocol::OK;
if (cl)
ret = (rsm_client_protocol::status)cl->call_timeout(rsm_client_protocol::invoke, milliseconds(500), rep, proc, req);
if (!cl)
goto prim_fail;
- LOG << "proc " << std::hex << proc << " primary " << primary << " ret " << std::dec << ret;
+ LOG << "proc " << std::hex << proc << " primary " << prim << " ret " << std::dec << ret;
if (ret == rsm_client_protocol::OK)
return rsm_protocol::OK;
if (ret == rsm_client_protocol::BUSY) {
- LOG << "rsm is busy " << primary;
+ LOG << "rsm is busy " << prim;
usleep(300000);
continue;
}
if (ret == rsm_client_protocol::NOTPRIMARY) {
- LOG << "primary " << primary << " isn't the primary--let's get a complete list of mems";
+ LOG << "primary " << prim << " isn't the primary--let's get a complete list of mems";
if (init_members(ml))
continue;
}
prim_fail:
- LOG << "primary " << primary << " failed ret " << std::dec << ret;
+ LOG << "primary " << prim << " failed ret " << std::dec << ret;
primary_failure(ml);
- LOG << "retry new primary " << primary;
+ LOG << "retry new primary " << prim;
}
}
bool rsm_client::init_members(lock & rsm_client_mutex_lock) {
LOG << "get members!";
- handle h(primary);
+ string prim = primary;
int ret = rsm_client_protocol::ERR;
- rpcc *cl;
+ shared_ptr<rpcc> cl;
{
rsm_client_mutex_lock.unlock();
- cl = h.safebind();
+ cl = rpcc::bind_cached(prim);
if (cl)
ret = cl->call_timeout(rsm_client_protocol::members, milliseconds(100), known_mems, 0);
rsm_client_mutex_lock.lock();