5 unique_ptr<rpcc> client;
9 hinfo(const string & destination_) : destination(destination_) {}
12 static mutex mgr_mutex;
13 static map<string, shared_ptr<hinfo>> hmap;
15 handle::handle(const string & destination) {
17 h = hmap[destination];
19 h = (hmap[destination] = make_shared<hinfo>(destination));
22 rpcc * handle::safebind() {
25 lock cl(h->client_mutex);
29 unique_ptr<rpcc> client(new rpcc(h->destination));
30 LOG("trying to bind..." << h->destination);
31 // The test script assumes that the failure can be detected by paxos and
32 // rsm layer within few seconds. We have to set the timeout with a small
33 // value to support the assumption.
35 // With RPC_LOSSY=5, tests may fail due to delays and time outs.
36 int ret = client->bind(milliseconds(1000));
38 LOG("bind failure! " << h->destination << " " << ret);
41 LOG("bind succeeded " << h->destination);
42 h->client = move(client);
45 return h->client.get();
48 void handle::invalidate() {
50 lock cl(h->client_mutex);
53 LOG_NONMEMBER("cl " << h->destination << " refcnt " << h.use_count());
56 hmap.erase(h->destination);
60 void invalidate_handle(const string & m) {
62 if (hmap.find(m) == hmap.end()) {
63 LOG_NONMEMBER("cl " << m << " isn't in cl list");
67 hmap[m]->valid = false;
68 LOG_NONMEMBER("cl " << m << " refcnt " << hmap[m].use_count());