c[who].notify_one();
}
-int lock_client::last_port = 0;
+unsigned int lock_client::last_port = 0;
lock_state & lock_client::get_lock_state(lock_protocol::lockid_t lid) {
lock sl(lock_table_lock);
make_sockaddr(xdst.c_str(), &dstsock);
cl = new rpcc(dstsock);
if (cl->bind() < 0) {
- printf("lock_client: call bind\n");
+ LOG("lock_client: call bind");
}
- srand(time(NULL)^last_port);
- rlock_port = ((rand()%32000) | (0x1 << 10));
+ srandom((uint32_t)time(NULL)^last_port);
+ rlock_port = ((random()%32000) | (0x1 << 10));
const char *hname;
// VERIFY(gethostname(hname, 100) == 0);
hname = "127.0.0.1";
rlsrpc->reg(rlock_protocol::retry, &lock_client::retry_handler, this);
{
lock sl(xid_mutex);
- xid = 0;
+ next_xid = 0;
}
rsmc = new rsm_client(xdst);
releaser_thread = std::thread(&lock_client::releaser, this);
}
-void lock_client::releaser() {
+void lock_client::releaser() [[noreturn]] {
while (1) {
lock_protocol::lockid_t lid;
release_fifo.deq(&lid);
sl.unlock();
int r;
rsmc->call(lock_protocol::release, r, lid, id, st.xid);
+ if (lu)
+ lu->dorelease(lid);
sl.lock();
}
st.state = lock_state::none;
if (st.state == lock_state::none || st.state == lock_state::retrying) {
if (st.state == lock_state::none) {
- lock sl(xid_mutex);
- st.xid = xid++;
+ lock l(xid_mutex);
+ st.xid = next_xid++;
}
st.state = lock_state::acquiring;
LOG("Lock " << lid << ": acquiring");
return rlock_protocol::OK;
}
-rlock_protocol::status lock_client::retry_handler(int &, lock_protocol::lockid_t lid, lock_protocol::xid_t xid) {
+rlock_protocol::status lock_client::retry_handler(int &, lock_protocol::lockid_t lid, lock_protocol::xid_t) {
lock_state &st = get_lock_state(lid);
lock sl(st.m);
VERIFY(st.state == lock_state::acquiring);