diff options
author | waker <wakeroid@gmail.com> | 2011-05-14 20:01:33 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-05-14 20:01:33 +0200 |
commit | 83cf2897f3069dee94549da7ace743b7303df2e7 (patch) | |
tree | 552f02254a95e962b138f43528ed121fdf3f30b3 /playlist.c | |
parent | 5b9e267c44f64899cbdd6319d78618e9767fd721 (diff) |
fixed several pl_lock race conditions in streamer;
added assertion to catch this kind of race conditions,
which can be turned on by defining DETECT_PL_LOCK_RC 1 in streamer.c and playlist.c
Diffstat (limited to 'playlist.c')
-rw-r--r-- | playlist.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -52,6 +52,7 @@ #define DISABLE_LOCKING 0 #define DEBUG_LOCKING 0 +//#define DETECT_PL_LOCK_RC 1 // file format revision history // 1.1->1.2 changelog: @@ -164,14 +165,21 @@ pl_free (void) { } #if DEBUG_LOCKING -int pl_lock_cnt = 0; +volatile int pl_lock_cnt = 0; +#endif +#if DETECT_PL_LOCK_RC +static pthread_t tids[1000]; +static int ntids = 0; +pthread_t pl_lock_tid = 0; #endif -//pthread_t pl_lock_tid = 0; void pl_lock (void) { #if !DISABLE_LOCKING mutex_lock (mutex); - //pl_lock_tid = pthread_self(); +#if DETECT_PL_LOCK_RC + pl_lock_tid = pthread_self(); + tids[ntids++] = pl_lock_tid; +#endif #if DEBUG_LOCKING pl_lock_cnt++; @@ -183,6 +191,17 @@ pl_lock (void) { void pl_unlock (void) { #if !DISABLE_LOCKING +#if DETECT_PL_LOCK_RC + if (ntids > 0) { + ntids--; + } + if (ntids > 0) { + pl_lock_tid = tids[ntids-1]; + } + else { + pl_lock_tid = 0; + } +#endif mutex_unlock (mutex); #if DEBUG_LOCKING pl_lock_cnt--; |