10 hinfo(const string & m_) : m(m_) {}
16 map<string, hinfo *> hmap;
17 void delete_handle(const string & m, lock & handle_mutex_lock);
19 hinfo *acquire_handle(string m);
20 void release_handle(hinfo *h);
21 void delete_handle(const string & m);
24 static handle_mgr mgr;
26 handle::handle(const string & m) : h(mgr.acquire_handle(m)) {}
28 rpcc * handle::safebind() {
31 lock ml(h->client_mutex);
36 rpcc *cl = new rpcc(h->m);
37 LOG("trying to bind..." << h->m);
38 // The test script assumes that the failure can be detected by paxos and
39 // rsm layer within few seconds. We have to set the timeout with a small
40 // value to support the assumption.
42 // With RPC_LOSSY=5, tests may fail due to delays and time outs.
43 int ret = cl->bind(milliseconds(1000));
45 LOG("bind failure! " << h->m << " " << ret);
49 LOG("bind succeeded " << h->m);
56 if (h) mgr.release_handle(h);
59 hinfo * handle_mgr::acquire_handle(string m) {
62 if (hmap.find(m) == hmap.end()) {
66 } else if (!hmap[m]->del) {
73 void handle_mgr::release_handle(hinfo *h) {
75 if (--h->refcnt == 0 && h->del)
76 delete_handle(h->m, ml);
79 void handle_mgr::delete_handle(const string & m) {
84 void handle_mgr::delete_handle(const string & m, lock &) {
85 if (hmap.find(m) == hmap.end()) {
86 LOG("cl " << m << " isn't in cl list");
89 LOG("cl " << m << " refcnt " << hmap[m]->refcnt);
102 void invalidate_handle(const string & m) {
103 mgr.delete_handle(m);