c[who].notify_one();
}
-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
if (cl->bind() < 0)
LOG << "lock_client: call bind";
- srandom((uint32_t)time(NULL)^last_port);
- rlock_port = ((random()%32000) | (0x1 << 10));
+ rlock_port = std::uniform_int_distribution<in_port_t>(1024,32000+1024)(global->random_generator);
id = "127.0.0.1:" + std::to_string(rlock_port);
- last_port = rlock_port;
rlsrpc = unique_ptr<rpcs>(new rpcs(rlock_port));
rlsrpc->reg(rlock_protocol::revoke, &lock_client::revoke_handler, this);
rlsrpc->reg(rlock_protocol::retry, &lock_client::retry_handler, this);
}
void lock_client::releaser() {
- while (1) {
- maybe<lock_protocol::lockid_t> mlid;
- release_fifo.deq(&mlid);
-
- if (!mlid) {
- LOG << "Releaser stopping";
- break;
- }
-
+ while (auto mlid = release_fifo.deq()) {
lock_protocol::lockid_t lid = mlid;
LOG << "Releaser: " << lid;
LOG << "Lock " << lid << ": none";
st.signal();
}
+ LOG << "Releaser stopping";
}
int lock_client::stat(lock_protocol::lockid_t lid) {