src: add lock to inspector MainThreadHandle dtor

Otherwise, the `CHECK` is reported to be a race condition
by automated tooling. It’s not easy to tell from looking at
the source code whether that is actually the case or not,
but adding this lock should be a safe way to resolve it.

PR-URL: https://github.com/nodejs/node/pull/26010
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen 2019-02-08 20:47:20 +01:00 committed by Daniel Bevenius
parent 93417ac995
commit 82c4e170e5

View File

@ -45,6 +45,7 @@ class MainThreadHandle : public std::enable_shared_from_this<MainThreadHandle> {
: main_thread_(main_thread) {
}
~MainThreadHandle() {
Mutex::ScopedLock scoped_lock(block_lock_);
CHECK_NULL(main_thread_); // main_thread_ should have called Reset
}
std::unique_ptr<InspectorSession> Connect(