Working on g++ compatibility
[invirt/third/libt4.git] / lock_server.cc
index d5e85a5..0c3a6e9 100644 (file)
@@ -1,6 +1,5 @@
 // the caching lock server implementation
 
-#include "types.h"
 #include "lock_server.h"
 #include <unistd.h>
 #include <arpa/inet.h>
@@ -29,18 +28,18 @@ lock_state & lock_server::get_lock_state(lock_protocol::lockid_t lid) {
     return lock_table[lid];
 }
 
-lock_server::lock_server(class rsm *_rsm) : rsm (_rsm) {
-    std::thread(&lock_server::revoker, this).detach();
-    std::thread(&lock_server::retryer, this).detach();
-    rsm->set_state_transfer(this);
+lock_server::lock_server(rsm *r) : rsm_ (r) {
+    thread(&lock_server::revoker, this).detach();
+    thread(&lock_server::retryer, this).detach();
+    rsm_->set_state_transfer(this);
 }
 
-void lock_server::revoker() [[noreturn]] {
+void lock_server::revoker () {
     while (1) {
         lock_protocol::lockid_t lid;
         revoke_fifo.deq(&lid);
         LOG("Revoking " << lid);
-        if (rsm && !rsm->amiprimary())
+        if (rsm_ && !rsm_->amiprimary())
             continue;
 
         lock_state &st = get_lock_state(lid);
@@ -63,11 +62,11 @@ void lock_server::revoker() [[noreturn]] {
     }
 }
 
-void lock_server::retryer() [[noreturn]] {
+void lock_server::retryer() {
     while (1) {
         lock_protocol::lockid_t lid;
         retry_fifo.deq(&lid);
-        if (rsm && !rsm->amiprimary())
+        if (rsm_ && !rsm_->amiprimary())
             continue;
 
         LOG("Sending retry for " << lid);
@@ -93,7 +92,7 @@ void lock_server::retryer() [[noreturn]] {
     }
 }
 
-int lock_server::acquire(int &, lock_protocol::lockid_t lid, string 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);
     holder_t h = holder_t(id, xid);
     lock_state &st = get_lock_state(lid);
@@ -151,7 +150,7 @@ 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_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);
     lock_state &st = get_lock_state(lid);
     lock sl(st.m);
@@ -167,19 +166,17 @@ int lock_server::release(int &, lock_protocol::lockid_t lid, callback_t id, lock
 string lock_server::marshal_state() {
     lock sl(lock_table_lock);
     marshall rep;
-    rep << nacquire;
-    rep << lock_table;
-    return rep.str();
+    rep << nacquire << lock_table;
+    return rep.content();
 }
 
-void lock_server::unmarshal_state(string state) {
+void lock_server::unmarshal_state(const string & state) {
     lock sl(lock_table_lock);
-    unmarshall rep(state);
-    rep >> nacquire;
-    rep >> lock_table;
+    unmarshall rep(state, false);
+    rep >> nacquire >> lock_table;
 }
 
-lock_protocol::status lock_server::stat(int &r, lock_protocol::lockid_t lid) {
+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;