summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-15 23:59:20 +0200
committerwm4 <wm4@nowhere>2014-06-16 01:00:59 +0200
commitae1b1a68cb1a7bdfc2ce88d5133e1010a0c2d054 (patch)
tree0b483849c9aa5c5149a2a9ed004423e24b8f3dc1 /stream
parenteca0fcb77a95793b31b6447e0c91bf4d4045efeb (diff)
downloadmpv-ae1b1a68cb1a7bdfc2ce88d5133e1010a0c2d054.tar.bz2
mpv-ae1b1a68cb1a7bdfc2ce88d5133e1010a0c2d054.tar.xz
cache: avoid race condition between cache wakeup and idling
When the reader is out of data, it tries to wake up the cache thread to get more data. In theory, there's a small race condition, which could cause the cache to miss the wakeup and idle before reaction. Most certainly didn't cause real issues, because even if this extremely unlikely race condition happens, the cache won't idle for longer than 1 second (the hardcoded cache idle time).
Diffstat (limited to 'stream')
-rw-r--r--stream/cache.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/stream/cache.c b/stream/cache.c
index 7ed3f3ae32..9e04514993 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -567,6 +567,7 @@ static int cache_fill_buffer(struct stream *cache, char *buffer, int max_len)
break;
if (s->eof && s->read_filepos >= s->max_filepos && s->reads >= retry)
break;
+ s->idle = false;
if (cache_wakeup_and_wait(s, &retry_time) == CACHE_INTERRUPTED)
break;
}