Added a warning if an attempt is made to obtain a write lock twice from the same thread

This commit is contained in:
Klaus Schmidinger 2022-11-13 15:25:52 +01:00
parent 230adc8235
commit 5a029eb29f
2 changed files with 10 additions and 1 deletions

View File

@ -9794,3 +9794,4 @@ Video Disk Recorder Revision History
for recordings that are currently being edited.
- Fixed a possible crash if an editing process is canceled while the edited
recording is being replayed.
- Added a warning if an attempt is made to obtain a write lock twice from the same thread.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: thread.c 4.15 2020/09/16 13:48:33 kls Exp $
* $Id: thread.c 5.1 2022/11/13 15:25:52 kls Exp $
*/
#include "thread.h"
@ -753,6 +753,14 @@ bool cStateLock::Lock(cStateKey &StateKey, bool Write, int TimeoutMs)
dbglocking("%5d %-12s %10p timeout\n", cThread::ThreadId(), name, &StateKey);
StateKey.timedOut = true;
}
else if (threadId == cThread::ThreadId()) {
static bool DoubleWriteLockReported = false;
if (!DoubleWriteLockReported) {
dsyslog("WARNING: attempt to acquire write lock while already holding a write lock in the same thread - this may crash! (backtrace follows)");
cBackTrace::BackTrace();
DoubleWriteLockReported = true;
}
}
return false;
}