1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 21:55:45 +02:00

7 Commits

Author SHA1 Message Date
Zygo Blaxell
1aa1decd1d lockset: drop unused method wait_unlock
This function is not used and does not appear to be useful.

Remove it.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-10-01 16:18:48 -04:00
Zygo Blaxell
8ea92202fc lockset: avoid starvation using a priority queue
Mutex locks are released and acquired unfairly, causing arbitrary delays
in acquiring locks.  This prevents threads from releasing subvol FD's
which in turn blocks subvol deletes.

Fix by implementing a priority queue in LockSet to ensure fairness.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-10-01 16:18:47 -04:00
Zygo Blaxell
aa0b22d445 crucible: lockset: track lockers and use handle type
Keep track of the locking thread so we can see why we are deadlocked
in gdb.

Use a handle type for locks based on shared_ptr.  Change the handle type
name to flush out any non-auto local variables.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-06-17 09:50:59 -04:00
Zygo Blaxell
9cb48c35b9 crucible: lockset: add LockSet<T>::Lock make_lock
Before:  decltype(foo)::Lock lock(foo, key);

After:   auto lock = foo.make_lock(key);

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-01-23 21:18:03 -05:00
Zygo Blaxell
6099bf0b01 crucible: fix further instances of copy-after-unlock bug
Before:

	unique_lock<mutex> lock(some_mutex);
	// run lock.~unique_lock() because return
	// return reference to unprotected heap
	return foo[bar];

After:

	unique_lock<mutex> lock(some_mutex);
	// make copy of object on heap protected by mutex lock
	auto tmp_copy = foo[bar];
	// run lock.~unique_lock() because return
	// pass locally allocated object to copy constructor
	return tmp_copy;

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-01-22 22:00:27 -05:00
Zygo Blaxell
bda4638048 crucible: LockSet: add a maximum size constraint
Extend the LockSet class so that the total number of locked (active)
items can be limited.  When the limit is reached, no new items can be
locked until some existing locked items are unlocked.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
2017-01-09 23:23:51 -05:00
Zygo Blaxell
cca0ee26a8 bees: remove local cruft, throw at github 2016-11-17 12:12:13 -05:00