Commit 61e00b11 authored by Misha Shneerson's avatar Misha Shneerson Committed by Facebook GitHub Bot

print tid of the stalling thread.

Reviewed By: yfeldblum

Differential Revision: D30914679

fbshipit-source-id: 79a609ed1eda97a97e6eeeb47038a1e746b75e2d
parent a082c773
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <memory> #include <memory>
#include <folly/concurrency/DeadlockDetector.h> #include <folly/concurrency/DeadlockDetector.h>
#include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h> #include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h>
#include <folly/system/ThreadId.h>
namespace folly { namespace folly {
...@@ -33,8 +34,10 @@ void IOThreadPoolDeadlockDetectorObserver::threadStarted( ...@@ -33,8 +34,10 @@ void IOThreadPoolDeadlockDetectorObserver::threadStarted(
auto eventBase = folly::IOThreadPoolExecutor::getEventBase(h); auto eventBase = folly::IOThreadPoolExecutor::getEventBase(h);
// This Observer only works with IOThreadPoolExecutor class. // This Observer only works with IOThreadPoolExecutor class.
CHECK_NOTNULL(eventBase); CHECK_NOTNULL(eventBase);
auto thid = folly::to<std::string>(folly::getOSThreadID());
auto name = name_ + ":" + thid;
detectors_.wlock()->insert_or_assign( detectors_.wlock()->insert_or_assign(
h, deadlockDetectorFactory_->create(eventBase, name_)); h, deadlockDetectorFactory_->create(eventBase, name));
} }
void IOThreadPoolDeadlockDetectorObserver::threadStopped( void IOThreadPoolDeadlockDetectorObserver::threadStopped(
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
*/ */
#include <memory> #include <memory>
#include <fmt/core.h>
#include <folly/concurrency/DeadlockDetector.h> #include <folly/concurrency/DeadlockDetector.h>
#include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h> #include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h>
#include <folly/executors/IOThreadPoolExecutor.h> #include <folly/executors/IOThreadPoolExecutor.h>
...@@ -39,7 +42,9 @@ class DeadlockDetectorFactoryMock : public DeadlockDetectorFactory { ...@@ -39,7 +42,9 @@ class DeadlockDetectorFactoryMock : public DeadlockDetectorFactory {
std::unique_ptr<DeadlockDetector> create( std::unique_ptr<DeadlockDetector> create(
folly::Executor* executor, const std::string& name) override { folly::Executor* executor, const std::string& name) override {
EXPECT_TRUE(executor != nullptr); EXPECT_TRUE(executor != nullptr);
EXPECT_EQ("TestPool", name); std::string expectedName =
fmt::format("TestPool:{}", folly::getOSThreadID());
EXPECT_EQ(expectedName, name);
return std::make_unique<DeadlockDetectorMock>(counter_); return std::make_unique<DeadlockDetectorMock>(counter_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment