Changeset View
Changeset View
Standalone View
Standalone View
src/sync.cpp
Show All 17 Lines | void PrintLockContention(const char *pszName, const char *pszFile, int nLine) { | ||||
LogPrintf("Locker: %s:%d\n", pszFile, nLine); | LogPrintf("Locker: %s:%d\n", pszFile, nLine); | ||||
} | } | ||||
#endif /* DEBUG_LOCKCONTENTION */ | #endif /* DEBUG_LOCKCONTENTION */ | ||||
#ifdef DEBUG_LOCKORDER | #ifdef DEBUG_LOCKORDER | ||||
// | // | ||||
// Early deadlock detection. | // Early deadlock detection. | ||||
// Problem being solved: | // Problem being solved: | ||||
// Thread 1 locks A, then B, then C | // Thread 1 locks A, then B, then C | ||||
// Thread 2 locks D, then C, then A | // Thread 2 locks D, then C, then A | ||||
// --> may result in deadlock between the two threads, depending on when | // --> may result in deadlock between the two threads, depending on when | ||||
// they run. | // they run. | ||||
// Solution implemented here: | // Solution implemented here: | ||||
// Keep track of pairs of locks: (A before B), (A before C), etc. | // Keep track of pairs of locks: (A before B), (A before C), etc. | ||||
// Complain if any thread tries to lock in a different order. | // Complain if any thread tries to lock in a different order. | ||||
// | // | ||||
struct CLockLocation { | struct CLockLocation { | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |