8 handle::handle(std::string m)
10 h = mgr.get_handle(m);
24 make_sockaddr(h->m.c_str(), &dstsock);
25 rpcc *cl = new rpcc(dstsock);
26 tprintf("handler_mgr::get_handle trying to bind...%s\n", h->m.c_str());
28 // Starting with lab 6, our test script assumes that the failure
29 // can be detected by paxos and rsm layer within few seconds. We have
30 // to set the timeout with a small value to support the assumption.
32 // Note: with RPC_LOSSY=5, your lab would failed to pass the tests of
33 // lab 6 and lab 7 because the rpc layer may delay your RPC request,
34 // and cause a time out failure. Please make sure RPC_LOSSY is set to 0.
35 ret = cl->bind(rpcc::to(1000));
37 tprintf("handle_mgr::get_handle bind failure! %s %d\n", h->m.c_str(), ret);
41 tprintf("handle_mgr::get_handle bind succeeded %s\n", h->m.c_str());
49 if (h) mgr.done_handle(h);
52 handle_mgr::handle_mgr()
57 handle_mgr::get_handle(std::string m)
59 lock ml(handle_mutex);
61 if (hmap.find(m) == hmap.end()) {
68 } else if (!hmap[m]->del) {
76 handle_mgr::done_handle(struct hinfo *h)
78 lock ml(handle_mutex);
80 if (h->refcnt == 0 && h->del)
81 delete_handle_wo(h->m);
85 handle_mgr::delete_handle(std::string m)
87 lock ml(handle_mutex);
91 // Must be called with handle_mutex locked.
93 handle_mgr::delete_handle_wo(std::string m)
95 if (hmap.find(m) == hmap.end()) {
96 tprintf("handle_mgr::delete_handle_wo: cl %s isn't in cl list\n", m.c_str());
98 tprintf("handle_mgr::delete_handle_wo: cl %s refcnt %d\n", m.c_str(),
100 struct hinfo *h = hmap[m];
101 if (h->refcnt == 0) {