-rpcc * handle::safebind() {
- if (!h)
- return nullptr;
- lock ml(h->client_mutex);
- if (h->del)
- return nullptr;
- if (h->cl)
- return h->cl;
- rpcc *cl = new rpcc(h->m);
- LOG("trying to bind..." << h->m);
- // The test script assumes that the failure can be detected by paxos and
- // rsm layer within few seconds. We have to set the timeout with a small
- // value to support the assumption.
- //
- // With RPC_LOSSY=5, tests may fail due to delays and time outs.
- int ret = cl->bind(milliseconds(1000));
- if (ret < 0) {
- LOG("bind failure! " << h->m << " " << ret);
- delete cl;
- h->del = true;
- } else {
- LOG("bind succeeded " << h->m);
- h->cl = cl;
- }
- return h->cl;
-}
-
-handle::~handle() {
- if (h) mgr.release_handle(h);
+static shared_ptr<hinfo> acquire_handle(string m) {
+ lock ml(mgr_mutex);
+ shared_ptr<hinfo> h = hmap[m];
+ if (!h || h->del)
+ return (hmap[m] = make_shared<hinfo>(m));
+ return h;