2 #include "threaded_log.h"
15 hinfo(const string & m_) : m(m_) {}
21 map<string, hinfo *> hmap;
22 void delete_handle(const string & m, lock & handle_mutex_lock);
24 hinfo *acquire_handle(string m);
25 void release_handle(hinfo *h);
26 void delete_handle(const string & m);
29 static handle_mgr mgr;
31 handle::handle(const string & m) : h(mgr.acquire_handle(m)) {}
33 rpcc * handle::safebind() {
36 lock ml(h->client_mutex);
41 rpcc *cl = new rpcc(h->m);
42 LOG("handler_mgr::acquire_handle trying to bind..." << h->m);
43 // The test script assumes that the failure can be detected by paxos and
44 // rsm layer within few seconds. We have to set the timeout with a small
45 // value to support the assumption.
47 // With RPC_LOSSY=5, tests may fail due to delays and time outs.
48 int ret = cl->bind(rpcc::to(1000));
50 LOG("handle_mgr::acquire_handle bind failure! " << h->m << " " << ret);
54 LOG("handle_mgr::acquire_handle bind succeeded " << h->m);
61 if (h) mgr.release_handle(h);
64 hinfo * handle_mgr::acquire_handle(string m) {
67 if (hmap.find(m) == hmap.end()) {
70 } else if (!hmap[m]->del) {
77 void handle_mgr::release_handle(hinfo *h) {
79 if (--h->refcnt == 0 && h->del)
80 delete_handle(h->m, ml);
83 void handle_mgr::delete_handle(const string & m) {
88 void handle_mgr::delete_handle(const string & m, lock &) {
89 if (hmap.find(m) == hmap.end()) {
90 LOG("handle_mgr::delete_handle: cl " << m << " isn't in cl list");
93 LOG("handle_mgr::delete_handle: cl " << m << " refcnt " << hmap[m]->refcnt);
106 void invalidate_handle(const string & m) {
107 mgr.delete_handle(m);