projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Global destructor clean-ups and python test fixes
[invirt/third/libt4.git]
/
lock_client.cc
diff --git
a/lock_client.cc
b/lock_client.cc
index
9949eac
..
009e051
100644
(file)
--- a/
lock_client.cc
+++ b/
lock_client.cc
@@
-44,10
+44,22
@@
lock_client::lock_client(string xdst, lock_release_user *_lu) : lu(_lu), next_xi
rlsrpc->start();
}
rlsrpc->start();
}
+lock_client::~lock_client() {
+ release_fifo.enq(nothing<lock_protocol::lockid_t>());
+ releaser_thread.join();
+}
+
void lock_client::releaser() {
while (1) {
void lock_client::releaser() {
while (1) {
- lock_protocol::lockid_t lid;
- release_fifo.deq(&lid);
+ maybe<lock_protocol::lockid_t> mlid;
+ release_fifo.deq(&mlid);
+
+ if (!mlid) {
+ LOG << "Releaser stopping";
+ break;
+ }
+
+ lock_protocol::lockid_t lid = mlid;
LOG << "Releaser: " << lid;
lock_state & st = get_lock_state(lid);
LOG << "Releaser: " << lid;
lock_state & st = get_lock_state(lid);
@@
-122,7
+134,7
@@
lock_protocol::status lock_client::acquire(lock_protocol::lockid_t lid) {
st.state = lock_state::locked;
st.held_by = releaser_thread.get_id();
LOG << "Queuing " << lid << " for release";
st.state = lock_state::locked;
st.held_by = releaser_thread.get_id();
LOG << "Queuing " << lid << " for release";
- release_fifo.enq(lid);
+ release_fifo.enq(just(lid));
} else if (front == self) {
st.wanted_by.pop_front();
st.state = lock_state::locked;
} else if (front == self) {
st.wanted_by.pop_front();
st.state = lock_state::locked;
@@
-156,7
+168,7
@@
lock_protocol::status lock_client::release(lock_protocol::lockid_t lid) {
st.held_by = releaser_thread.get_id();
st.wanted_by.pop_front();
LOG << "Queuing " << lid << " for release";
st.held_by = releaser_thread.get_id();
st.wanted_by.pop_front();
LOG << "Queuing " << lid << " for release";
- release_fifo.enq(lid);
+ release_fifo.enq(just(lid));
} else
st.signal(front);
}
} else
st.signal(front);
}
@@
-179,7
+191,7
@@
rlock_protocol::status lock_client::revoke_handler(int &, lock_protocol::lockid_
st.held_by = releaser_thread.get_id();
if (st.wanted_by.size())
st.wanted_by.pop_front();
st.held_by = releaser_thread.get_id();
if (st.wanted_by.size())
st.wanted_by.pop_front();
- release_fifo.enq(lid);
+ release_fifo.enq(just(lid));
} else {
// get in line
st.wanted_by.push_back(releaser_thread.get_id());
} else {
// get in line
st.wanted_by.push_back(releaser_thread.get_id());