message: Refactor: Sync, GetLockData + few inlines with upstream's formatting.
diff: @@ -81,7 +81,11 @@ struct LockData {
  LockOrders lockorders;
  InvLockOrders invlockorders;
  std::mutex dd_mutex;
  -} static lockdata;
  +};
  +LockData& GetLockData() {
  + static LockData lockdata;
  + return lockdata;
  +}
  static thread_local LockStack g_lockstack;
  @@ -91,20 +95,20 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
  LogPrintf("Previous lock order was:\n");
  for (const std::pair<void*, CLockLocation> & i : s2) {
  if (i.first == mismatch.first) {
  - LogPrintf(" (1)");
  + LogPrintf(" (1)"); /* Continued */
  }
  if (i.first == mismatch.second) {
  - LogPrintf(" (2)");
  + LogPrintf(" (2)"); /* Continued */
  }
  LogPrintf(" %s\n", i.second.ToString());
  }
  LogPrintf("Current lock order is:\n");
  for (const std::pair<void*, CLockLocation> & i : s1) {
  if (i.first == mismatch.first) {
  - LogPrintf(" (1)");
  + LogPrintf(" (1)"); /* Continued */
  }
  if (i.first == mismatch.second) {
  - LogPrintf(" (2)");
  + LogPrintf(" (2)"); /* Continued */
  }
  LogPrintf(" %s\n", i.second.ToString());
  }
  @@ -112,6 +116,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));
  @@ -123,7 +128,7 @@ static void push_lock(void* c, const CLockLocation& locklocation)
  std::pair<void*, void*> p1 = std::make_pair(i.first, c);
  if (lockdata.lockorders.count(p1))
  continue;
  - lockdata.lockorders[p1] = g_lockstack;
  + lockdata.lockorders.emplace(p1, g_lockstack);
  std::pair<void*, void*> p2 = std::make_pair(c, i.first);
  lockdata.invlockorders.insert(p2);
  @@ -166,6 +171,7 @@ void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine,
  void DeleteLock(void* cs)
  {
  + LockData& lockdata = GetLockData();
  if (!lockdata.available) {
  // We're already shutting down.
  return;
  