summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2017-06-06 09:25:48 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2017-06-06 09:25:48 +0200
commitdc775bc5f89461c0e6808a7464bee6f8ae818499 (patch)
tree6888f1182c910af124d6b98e9fd60b47d334fa10 /thread.c
parentec47c4f9326505c42af9aa9c02334f219ee7b701 (diff)
downloadvdr-dc775bc5f89461c0e6808a7464bee6f8ae818499.tar.gz
vdr-dc775bc5f89461c0e6808a7464bee6f8ae818499.tar.bz2
Fixed false positives when checking the locking sequence, in case of nested locks within the same thread
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/thread.c b/thread.c
index 345f2af4..e6ae889e 100644
--- a/thread.c
+++ b/thread.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.c 4.4 2017/06/03 12:43:22 kls Exp $
+ * $Id: thread.c 4.5 2017/06/06 09:11:03 kls Exp $
*/
#include "thread.h"
@@ -568,6 +568,7 @@ private:
cVector<int> flags;
tThreadId logThreadIds[SLL_SIZE];
int logFlags[SLL_SIZE];
+ uint8_t logCounter[SLL_SIZE][SLL_MAX_LIST];
char logCaller[SLL_SIZE][SLL_LENGTH];
int logIndex;
bool dumped;
@@ -581,6 +582,7 @@ cStateLockLog::cStateLockLog(void)
{
memset(logThreadIds, 0, sizeof(logThreadIds));
memset(logFlags, 0, sizeof(logFlags));
+ memset(logCounter, 0, sizeof(logCounter));
memset(logCaller, 0, sizeof(logCaller));
logIndex = 0;
dumped = false;
@@ -630,9 +632,9 @@ void cStateLockLog::Dump(const char *Name, tThreadId ThreadId)
void cStateLockLog::Check(const char *Name, bool Lock, bool Write)
{
if (!dumped && Name) {
- int n = *Name - '0';
- if (1 <= n && n <= SLL_MAX_LIST) {
- int b = 1 << (n - 1);
+ int n = *Name - '0' - 1;
+ if (0 < n && n < SLL_MAX_LIST) {
+ int b = 1 << n;
cMutexLock MutexLock(&mutex);
tThreadId ThreadId = cThread::ThreadId();
int Index = threadIds.IndexOf(ThreadId);
@@ -651,9 +653,10 @@ void cStateLockLog::Check(const char *Name, bool Lock, bool Write)
;
else if ((flags[Index] & b) == 0) // thread already holds "bigger" locks, so it may only re-lock one that it already has!
DoDump = true;
+ logCounter[Index][n]++;
flags[Index] |= b;
}
- else
+ else if (--logCounter[Index][n] == 0)
flags[Index] &= ~b;
logThreadIds[logIndex] = ThreadId;
logFlags[logIndex] = flags[Index] | (Write ? SLL_WRITE_FLAG : 0);