X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/2546a41ad36fdc9ef6471cb35a1d56930ae1b527..5a5c578e2e358a121cdb9234a6cb11c4ecfbf323:/lock_server.cc?ds=sidebyside diff --git a/lock_server.cc b/lock_server.cc index cac6a90..379838a 100644 --- a/lock_server.cc +++ b/lock_server.cc @@ -1,18 +1,10 @@ // the caching lock server implementation +#include "types.h" #include "lock_server.h" -#include #include #include -#include "lang/verify.h" #include "handle.h" -#include "threaded_log.h" -#include "rpc/marshall.h" -#include "lock.h" - -using std::ostringstream; -using std::istringstream; -using std::vector; lock_state::lock_state(): held(false) @@ -61,7 +53,7 @@ void lock_server::revoker() [[noreturn]] { continue; lock_state &st = get_lock_state(lid); - holder held_by; + holder_t held_by; { lock sl(st.m); held_by = st.held_by; @@ -89,7 +81,7 @@ void lock_server::retryer() [[noreturn]] { LOG("Sending retry for " << lid); lock_state &st = get_lock_state(lid); - holder front; + holder_t front; { lock sl(st.m); if (st.wanted_by.empty()) @@ -111,8 +103,8 @@ void lock_server::retryer() [[noreturn]] { } int lock_server::acquire(int &, lock_protocol::lockid_t lid, string id, lock_protocol::xid_t xid) { - LOG_FUNC_ENTER_SERVER; - holder h = holder(id, xid); + LOG("lid=" << lid << " client=" << id << "," << xid); + holder_t h = holder_t(id, xid); lock_state &st = get_lock_state(lid); lock sl(st.m); @@ -145,11 +137,11 @@ int lock_server::acquire(int &, lock_protocol::lockid_t lid, string id, lock_pro // get in line bool found = false; - for (list::iterator i = st.wanted_by.begin(); i != st.wanted_by.end(); i++) { - if (i->first == id) { + for (auto p : st.wanted_by) { + if (p.first == id) { // make sure client is obeying serialization - if (i->second != xid) { - LOG("Client " << id << " sent acquire xid=" << xid << " with in-progress xid=" << i->second); + if (p.second != xid) { + LOG("Client " << id << " sent acquire xid=" << xid << " with in-progress xid=" << p.second); return lock_protocol::RPCERR; } found = true; @@ -159,7 +151,7 @@ int lock_server::acquire(int &, lock_protocol::lockid_t lid, string id, lock_pro if (!found) st.wanted_by.push_back(h); - LOG("wanted_by=" << make_iterator_pair(st.wanted_by.begin(), st.wanted_by.end())); + LOG("wanted_by=" << st.wanted_by); // send revoke if we're first in line if (st.wanted_by.front() == h) @@ -168,11 +160,11 @@ int lock_server::acquire(int &, lock_protocol::lockid_t lid, string id, lock_pro return lock_protocol::RETRY; } -int lock_server::release(int &, lock_protocol::lockid_t lid, callback id, lock_protocol::xid_t xid) { - LOG_FUNC_ENTER_SERVER; +int lock_server::release(int &, lock_protocol::lockid_t lid, callback_t id, lock_protocol::xid_t xid) { + LOG("lid=" << lid << " client=" << id << "," << xid); lock_state &st = get_lock_state(lid); lock sl(st.m); - if (st.held && st.held_by == holder(id, xid)) { + if (st.held && st.held_by == holder_t(id, xid)) { st.held = false; LOG("Lock " << lid << " not held"); }