projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cosmetic changes
[invirt/third/libt4.git]
/
lock_server.cc
diff --git
a/lock_server.cc
b/lock_server.cc
index
90ad5b2
..
86e5ad2
100644
(file)
--- a/
lock_server.cc
+++ b/
lock_server.cc
@@
-3,7
+3,6
@@
#include "lock_server.h"
#include <unistd.h>
#include <arpa/inet.h>
#include "lock_server.h"
#include <unistd.h>
#include <arpa/inet.h>
-#include "handle.h"
lock_state::lock_state():
held(false)
lock_state::lock_state():
held(false)
@@
-35,45
+34,35
@@
lock_server::lock_server(rsm & r) : rsm_ (&r) {
r.reg(lock_protocol::acquire, &lock_server::acquire, this);
r.reg(lock_protocol::release, &lock_server::release, this);
r.reg(lock_protocol::acquire, &lock_server::acquire, this);
r.reg(lock_protocol::release, &lock_server::release, this);
- r.reg(lock_protocol::stat, &lock_server::stat, this);
}
void lock_server::revoker () {
while (1) {
}
void lock_server::revoker () {
while (1) {
- lock_protocol::lockid_t lid;
- revoke_fifo.deq(&lid);
- LOG("Revoking " << lid);
+ lock_protocol::lockid_t lid = revoke_fifo.deq();
+ LOG << "Revoking " << lid;
if (rsm_ && !rsm_->amiprimary())
continue;
lock_state & st = get_lock_state(lid);
if (rsm_ && !rsm_->amiprimary())
continue;
lock_state & st = get_lock_state(lid);
- holder_t held_by;
- {
- lock sl(st.m);
- held_by = st.held_by;
- }
+ lock sl(st.m);
+ holder_t held_by = st.held_by;
+ sl.unlock();
- rpcc *proxy = NULL;
- // try a few times?
- //int t=5;
- //while (t-- && !proxy)
- proxy = handle(held_by.first).safebind();
- if (proxy) {
+ if (auto cl = rpcc::bind_cached(held_by.first)) {
int r;
int r;
- auto ret = (rlock_protocol::status)proxy->call(rlock_protocol::revoke, r, lid, held_by.second);
- LOG("Revoke returned " << ret);
+ auto ret = (rlock_protocol::status)cl->call(rlock_protocol::revoke, r, lid, held_by.second);
+ LOG << "Revoke returned " << ret;
}
}
}
void lock_server::retryer() {
while (1) {
}
}
}
void lock_server::retryer() {
while (1) {
- lock_protocol::lockid_t lid;
- retry_fifo.deq(&lid);
+ lock_protocol::lockid_t lid = retry_fifo.deq();
if (rsm_ && !rsm_->amiprimary())
continue;
if (rsm_ && !rsm_->amiprimary())
continue;
- LOG("Sending retry for " << lid);
+ LOG << "Sending retry for " << lid;
lock_state & st = get_lock_state(lid);
holder_t front;
{
lock_state & st = get_lock_state(lid);
holder_t front;
{
@@
-83,21
+72,16
@@
void lock_server::retryer() {
front = st.wanted_by.front();
}
front = st.wanted_by.front();
}
- rpcc *proxy = NULL;
- // try a few times?
- //int t=5;
- //while (t-- && !proxy)
- proxy = handle(front.first).safebind();
- if (proxy) {
+ if (auto cl = rpcc::bind_cached(front.first)) {
int r;
int r;
- auto ret = (rlock_protocol::status)proxy->call(rlock_protocol::retry, r, lid, front.second);
- LOG("Retry returned " << ret);
+ auto ret = (rlock_protocol::status)cl->call(rlock_protocol::retry, r, lid, front.second);
+ LOG << "Retry returned " << ret;
}
}
}
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, const callback_t & id, lock_protocol::xid_t xid) {
}
}
}
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, const callback_t & id, lock_protocol::xid_t xid) {
- LOG("lid=" << lid << " client=" << 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);
holder_t h = holder_t(id, xid);
lock_state & st = get_lock_state(lid);
lock sl(st.m);
@@
-109,7
+93,7
@@
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, c
return lock_protocol::RPCERR;
else if (old_xid == xid) {
if (st.held && st.held_by == h) {
return lock_protocol::RPCERR;
else if (old_xid == xid) {
if (st.held && st.held_by == h) {
- LOG("Client " << id << " sent duplicate acquire xid=" << xid);
+ LOG << "Client " << id << " sent duplicate acquire xid=" << xid;
return lock_protocol::OK;
}
}
return lock_protocol::OK;
}
}
@@
-123,7
+107,7
@@
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, c
st.held = true;
st.held_by = h;
st.held = true;
st.held_by = h;
- LOG("Lock " << lid << " held by " << h.first);
+ LOG << "Lock " << lid << " held by " << h.first;
if (st.wanted_by.size())
revoke_fifo.enq(lid);
return lock_protocol::OK;
if (st.wanted_by.size())
revoke_fifo.enq(lid);
return lock_protocol::OK;
@@
-135,7
+119,7
@@
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, c
if (p.first == id) {
// make sure client is obeying serialization
if (p.second != xid) {
if (p.first == id) {
// make sure client is obeying serialization
if (p.second != xid) {
- LOG("Client " << id << " sent acquire xid=" << xid << " with in-progress xid=" << p.second);
+ LOG << "Client " << id << " sent acquire xid=" << xid << " with in-progress xid=" << p.second;
return lock_protocol::RPCERR;
}
found = true;
return lock_protocol::RPCERR;
}
found = true;
@@
-145,7
+129,7
@@
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, c
if (!found)
st.wanted_by.push_back(h);
if (!found)
st.wanted_by.push_back(h);
- LOG("wanted_by=" << st.wanted_by);
+ LOG << "wanted_by=" << st.wanted_by;
// send revoke if we're first in line
if (st.wanted_by.front() == h)
// send revoke if we're first in line
if (st.wanted_by.front() == h)
@@
-155,12
+139,12
@@
lock_protocol::status lock_server::acquire(int &, lock_protocol::lockid_t lid, c
}
lock_protocol::status lock_server::release(int &, lock_protocol::lockid_t lid, const callback_t & id, lock_protocol::xid_t xid) {
}
lock_protocol::status lock_server::release(int &, lock_protocol::lockid_t lid, const callback_t & id, lock_protocol::xid_t xid) {
- LOG("lid=" << lid << " client=" << id << "," << 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_t(id, xid)) {
st.held = false;
lock_state & st = get_lock_state(lid);
lock sl(st.m);
if (st.held && st.held_by == holder_t(id, xid)) {
st.held = false;
- LOG("Lock " << lid << " not held");
+ LOG << "Lock " << lid << " not held";
}
if (st.wanted_by.size())
retry_fifo.enq(lid);
}
if (st.wanted_by.size())
retry_fifo.enq(lid);
@@
-176,11
+160,3
@@
void lock_server::unmarshal_state(const string & state) {
lock sl(lock_table_lock);
unmarshall(state, false, nacquire, lock_table);
}
lock sl(lock_table_lock);
unmarshall(state, false, nacquire, lock_table);
}
-
-lock_protocol::status lock_server::stat(int & r, lock_protocol::lockid_t lid, const callback_t &) {
- LOG("stat request for " << lid);
- VERIFY(0);
- r = nacquire;
- return lock_protocol::OK;
-}
-