Opcode::UPDATE().getCode(), QR_FLAG, 0, 0, 0, 0);
}
-// We just test the mutex can be locked (exactly once).
-TEST_F(AuthSrvTest, mutex) {
- isc::util::thread::Mutex::Locker l1(server.getDataSrcClientListMutex());
- // TODO: Once we have non-debug build, this one will not work, since
- // we currently use the fact that we can't lock twice from the same
- // thread. In the non-debug mode, this would deadlock.
- // Skip then.
- EXPECT_THROW({
- isc::util::thread::Mutex::Locker l2(
- server.getDataSrcClientListMutex());
- }, isc::InvalidOperation);
-}
-
}
EXPECT_TRUE(holder.findClientList(RRClass::IN()));
EXPECT_FALSE(holder.findClientList(RRClass::CH()));
}
-}
+ // Duplicate lock acquisition is prohibited (only test mgr can detect
+ // this reliably, so this test may not be that useful)
+ TestDataSrcClientsMgr::Holder holder1(mgr);
+ EXPECT_THROW(TestDataSrcClientsMgr::Holder holder2(mgr), isc::Unexpected);
+}
TEST(DataSrcClientsMgrTest, realThread) {
// Using the non-test definition with a real thread. Just checking
class Locker {
public:
Locker(TestMutex& mutex) : mutex_(mutex) {
+ if (mutex.lock_count != mutex.unlock_count) {
+ isc_throw(Unexpected,
+ "attempt of duplicate lock acquisition");
+ }
+
++mutex.lock_count;
if (mutex.lock_count > 100) { // 100 is an arbitrary choice
isc_throw(Unexpected,