// RPC stubs for clients to talk to lock_server, and cache the locks.
#include "lock_client.h"
-#include "rpc/rpc.h"
-#include <algorithm>
-#include "threaded_log.h"
#include <arpa/inet.h>
-#include "rsm_client.h"
-#include "lock.h"
-
void lock_state::wait(lock & mutex_lock) {
- auto self = std::this_thread::get_id();
+ auto self = this_thread::get_id();
c[self].wait(mutex_lock);
c.erase(self);
}
typedef map<lock_protocol::lockid_t, lock_state> lock_map;
-unsigned int lock_client::last_port = 0;
+in_port_t lock_client::last_port = 0;
lock_state & lock_client::get_lock_state(lock_protocol::lockid_t lid) {
lock sl(lock_table_lock);
return lock_table[lid]; // creates the lock if it doesn't already exist
}
-lock_client::lock_client(string xdst, class lock_release_user *_lu) : lu(_lu), next_xid(0) {
+lock_client::lock_client(string xdst, lock_release_user *_lu) : lu(_lu), next_xid(0) {
cl = new rpcc(xdst);
if (cl->bind() < 0)
LOG("lock_client: call bind");
srandom((uint32_t)time(NULL)^last_port);
rlock_port = ((random()%32000) | (0x1 << 10));
- id = "127.0.0.1:" + std::to_string(rlock_port);
+ id = "127.0.0.1:" + to_string(rlock_port);
last_port = rlock_port;
rpcs *rlsrpc = new rpcs(rlock_port);
rlsrpc->reg(rlock_protocol::revoke, &lock_client::revoke_handler, this);
lock_protocol::status lock_client::acquire(lock_protocol::lockid_t lid) {
lock_state &st = get_lock_state(lid);
lock sl(st.m);
- auto self = std::this_thread::get_id();
+ auto self = this_thread::get_id();
// check for reentrancy
VERIFY(st.state != lock_state::locked || st.held_by != self);
lock_protocol::status lock_client::release(lock_protocol::lockid_t lid) {
lock_state &st = get_lock_state(lid);
lock sl(st.m);
- auto self = std::this_thread::get_id();
+ auto self = this_thread::get_id();
VERIFY(st.state == lock_state::locked && st.held_by == self);
st.state = lock_state::free;
LOG("Lock " << lid << ": free");