| Index: runtime/vm/thread_linux.cc
|
| ===================================================================
|
| --- runtime/vm/thread_linux.cc (revision 39381)
|
| +++ runtime/vm/thread_linux.cc (working copy)
|
| @@ -12,6 +12,7 @@
|
| #include <sys/time.h> // NOLINT
|
|
|
| #include "platform/assert.h"
|
| +#include "vm/isolate.h"
|
|
|
| namespace dart {
|
|
|
| @@ -193,6 +194,11 @@
|
|
|
| result = pthread_mutexattr_destroy(&attr);
|
| VALIDATE_PTHREAD_RESULT(result);
|
| +
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = NULL;
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -200,6 +206,11 @@
|
| int result = pthread_mutex_destroy(data_.mutex());
|
| // Verify that the pthread_mutex was destroyed.
|
| VALIDATE_PTHREAD_RESULT(result);
|
| +
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + ASSERT(owner_ == NULL);
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -208,7 +219,10 @@
|
| // Specifically check for dead lock to help debugging.
|
| ASSERT(result != EDEADLK);
|
| ASSERT(result == 0); // Verify no other errors.
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = Isolate::Current();
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -219,13 +233,20 @@
|
| return false;
|
| }
|
| ASSERT(result == 0); // Verify no other errors.
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = Isolate::Current();
|
| +#endif // defined(DEBUG)
|
| return true;
|
| }
|
|
|
|
|
| void Mutex::Unlock() {
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + ASSERT(owner_ == Isolate::Current());
|
| + owner_ = NULL;
|
| +#endif // defined(DEBUG)
|
| int result = pthread_mutex_unlock(data_.mutex());
|
| // Specifically check for wrong thread unlocking to aid debugging.
|
| ASSERT(result != EPERM);
|
|
|