From ae1b1a68cb1a7bdfc2ce88d5133e1010a0c2d054 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 15 Jun 2014 23:59:20 +0200 Subject: 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). --- stream/cache.c | 1 + 1 file changed, 1 insertion(+) 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; } -- cgit v1.2.3