RPC procedures are now identified via a struct containing a string name.
[invirt/third/libt4.git] / lock_server.cc
index a4d5881..86e5ad2 100644 (file)
@@ -3,7 +3,6 @@
 #include "lock_server.h"
 #include <unistd.h>
 #include <arpa/inet.h>
-#include "handle.h"
 
 lock_state::lock_state():
     held(false)
@@ -35,32 +34,23 @@ 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::stat, &lock_server::stat, this);
 }
 
 void lock_server::revoker () {
     while (1) {
-        lock_protocol::lockid_t lid;
-        revoke_fifo.deq(&lid);
+        lock_protocol::lockid_t lid = revoke_fifo.deq();
         LOG << "Revoking " << 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;
-            auto ret = (rlock_protocol::status)proxy->call(rlock_protocol::revoke, r, lid, held_by.second);
+            auto ret = (rlock_protocol::status)cl->call(rlock_protocol::revoke, r, lid, held_by.second);
             LOG << "Revoke returned " << ret;
         }
     }
@@ -68,8 +58,7 @@ void lock_server::revoker () {
 
 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;
 
@@ -83,14 +72,9 @@ void lock_server::retryer() {
             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;
-            auto ret = (rlock_protocol::status)proxy->call(rlock_protocol::retry, r, lid, front.second);
+            auto ret = (rlock_protocol::status)cl->call(rlock_protocol::retry, r, lid, front.second);
             LOG << "Retry returned " << ret;
         }
     }
@@ -176,11 +160,3 @@ void lock_server::unmarshal_state(const string & state) {
     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;
-}
-