Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ struct LockData {
LockOrders lockorders;
InvLockOrders invlockorders;
std::mutex dd_mutex;
} static lockdata;
};
LockData& GetLockData() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err could also be static..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@promag Thanks for your reviewing.
Does this mean that the scope of GetLockData() should be compile-unit local same as original lockdata to prevent external calling?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes linkage changed, but I don't think it warrants a PR.

static LockData lockdata;
return lockdata;
}

static thread_local LockStack g_lockstack;

Expand Down Expand Up @@ -109,6 +113,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,

static void push_lock(void* c, const CLockLocation& locklocation)
{
LockData& lockdata = GetLockData();
std::lock_guard<std::mutex> lock(lockdata.dd_mutex);

g_lockstack.push_back(std::make_pair(c, locklocation));
Expand Down Expand Up @@ -173,6 +178,7 @@ void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLi

void DeleteLock(void* cs)
{
LockData& lockdata = GetLockData();
if (!lockdata.available) {
// We're already shutting down.
return;
Expand Down