X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/6b5e09540e9392a7015fae1ad3b01b0973600ff2..d54215aea2a7321ab0f2dc7b0042fea2b7ff5df5:/handle.cc diff --git a/handle.cc b/handle.cc index 79b3b4c..792ce40 100644 --- a/handle.cc +++ b/handle.cc @@ -12,7 +12,7 @@ public: static mutex mgr_mutex; static map> hmap; -handle::handle(const string & destination) { +handle::handle(const string & destination) : destination_(destination) { lock ml(mgr_mutex); h = hmap[destination]; if (!h || !h->valid) @@ -27,12 +27,7 @@ rpcc * handle::safebind() { return nullptr; if (!h->client) { unique_ptr client(new rpcc(h->destination)); - LOG("trying to bind..." << h->destination); - // 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. + LOG("bind(\"" << h->destination << "\")"); int ret = client->bind(milliseconds(1000)); if (ret < 0) { LOG("bind failure! " << h->destination << " " << ret); @@ -46,25 +41,11 @@ rpcc * handle::safebind() { } void handle::invalidate() { - { - lock cl(h->client_mutex); - h->valid = false; - - LOG_NONMEMBER("cl " << h->destination << " refcnt " << h.use_count()); - } - lock ml(mgr_mutex); - hmap.erase(h->destination); - h = nullptr; -} - -void invalidate_handle(const string & m) { + h.reset(); lock ml(mgr_mutex); - if (hmap.find(m) == hmap.end()) { - LOG_NONMEMBER("cl " << m << " isn't in cl list"); - return; + if (hmap.find(destination_) != hmap.end()) { + hmap[destination_]->valid = false; + LOG_NONMEMBER("cl " << destination_ << " refcnt " << hmap[destination_].use_count()); + hmap.erase(destination_); } - - hmap[m]->valid = false; - LOG_NONMEMBER("cl " << m << " refcnt " << hmap[m].use_count()); - hmap.erase(m); }