util/disk_cache: don't deadlock on premature EOF
authorGrazvydas Ignotas <notasas@gmail.com>
Fri, 24 Mar 2017 23:58:42 +0000 (01:58 +0200)
committerTimothy Arceri <tarceri@itsqueeze.com>
Sat, 25 Mar 2017 02:08:37 +0000 (13:08 +1100)
commitb9e92334f79bff2497fd718d49fe7c53b5f2074c
tree57ac33ea2a4cd75d352136aec2a6d9262defff53
parent741432616436d981eb75ebf8b0da8ae5ebbf48d8
util/disk_cache: don't deadlock on premature EOF

If we get EOF earlier than expected, the current read loops will
deadlock. This may easily happen if the disk cache gets corrupted.
Fix it by using a helper function that handles EOF.

Steps to reproduce (on a build with asserts disabled):
$ glxgears
$ find ~/.cache/mesa/ -type f -exec truncate -s 0 '{}' \;
$ glxgears # deadlock

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/util/disk_cache.c