Browse files

Assert no lock recursion.

Change-Id: I241186e71987834c30fe1796f901a09e41b8e9eb
Reviewed-on: http://review.membase.org/4597
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information...
1 parent 8346f26 commit d8589944012f3207f22355cd129d04bbe630dc97 @dustin dustin committed Feb 16, 2011
Showing with 3 additions and 0 deletions.
  1. +3 −0 locks.hh
View
3 locks.hh
@@ -5,6 +5,7 @@
#include <stdexcept>
#include <iostream>
#include <sstream>
+#include <functional>
#include "common.hh"
#include "mutex.hh"
@@ -80,6 +81,7 @@ public:
MultiLockHolder(Mutex *m, size_t n) : mutexes(m),
locked(new bool[n]),
n_locks(n) {
+ std::fill_n(locked, n_locks, false);
lock();
}
@@ -93,6 +95,7 @@ public:
*/
void lock() {
for (size_t i = 0; i < n_locks; i++) {
+ assert(!locked[i]);
mutexes[i].acquire();
locked[i] = true;
}

0 comments on commit d858994

Please sign in to comment.