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).
This commit is contained in:
wm4 2014-06-15 23:59:20 +02:00
parent eca0fcb77a
commit ae1b1a68cb
1 changed files with 1 additions and 0 deletions

View File

@ -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;
}