diff --git a/include/boost/thread/win32/mutex.hpp b/include/boost/thread/win32/mutex.hpp index 50477329..eed19b34 100644 --- a/include/boost/thread/win32/mutex.hpp +++ b/include/boost/thread/win32/mutex.hpp @@ -161,6 +161,10 @@ namespace boost } void unlock() { + if(!locked()) + { + throw boost::lock_error(); + } m.unlock(); is_locked=false; } diff --git a/test/test_lock_concept.cpp b/test/test_lock_concept.cpp index c76a0c61..be698a67 100644 --- a/test/test_lock_concept.cpp +++ b/test/test_lock_concept.cpp @@ -117,6 +117,7 @@ boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) test->add(BOOST_TEST_CASE((test_unlocked_after_unlock_called()))); test->add(BOOST_TEST_CASE((test_locked_after_lock_called()))); test->add(BOOST_TEST_CASE((test_throws_if_lock_called_when_already_locked()))); + test->add(BOOST_TEST_CASE((test_throws_if_unlock_called_when_already_unlocked()))); test->add(BOOST_TEST_CASE((test_initially_locked()))); test->add(BOOST_TEST_CASE((test_initially_locked_with_bool_parameter_true()))); @@ -124,6 +125,7 @@ boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) test->add(BOOST_TEST_CASE((test_unlocked_after_unlock_called()))); test->add(BOOST_TEST_CASE((test_locked_after_lock_called()))); test->add(BOOST_TEST_CASE((test_throws_if_lock_called_when_already_locked()))); + test->add(BOOST_TEST_CASE((test_throws_if_unlock_called_when_already_unlocked()))); return test; }