Commit Graph

3 Commits

Author SHA1 Message Date
Cory Fields 4165af1b73
c++11: don't throw from the reverselock destructor
noexcept is default for destructors as of c++11. By throwing in reverselock's
destructor if it's lock has been tampered with, the likely result is
std::terminate being called. Indeed that happened before this change.

Once reverselock has taken another lock (its ctor didn't throw), it makes no
sense to try to grab or lock the parent lock. That is be broken/undefined
behavior depending on the parent lock's implementation, but it shouldn't cause
the reverselock to fail to re-lock when destroyed.

To avoid those problems, simply swap the parent lock's contents with a dummy
for the duration of the lock. That will ensure that any undefined behavior is
caught at the call-site rather than the reverse lock's destruction.

Barring a failed mutex unlock which would be indicative of a larger problem,
the destructor should now never throw.
2017-11-29 17:24:59 +00:00
Nathan Wilcox 108650a55a Include a dubious "bug-fix" which allows exceptions to be thrown in reverselock destructor, which is required in reverselock_tests. ref #480 2015-12-22 09:20:42 -08:00
Casey Rodarmor 6b51b9b195 Replace boost::reverse_lock with our own. 2015-09-22 00:43:13 +00:00