I haven't seen this causing problems in practice, but for correctness we should also check if rename succeeded to avoid breaking accounting and leaving a .tmp file behind.
Signed-off-by: Grazvydas Ignotas <nota...@gmail.com> --- src/util/disk_cache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index f6768d5..0e08b20 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -876,19 +876,23 @@ cache_put(void *job, int thread_index) fd, filename_tmp); if (file_size == 0) { unlink(filename_tmp); goto done; } - rename(filename_tmp, filename); + ret = rename(filename_tmp, filename); + if (ret == -1) { + unlink(filename_tmp); + goto done; + } file_size += cf_data_size; p_atomic_add(dc_job->cache->size, file_size); done: if (fd_final != -1) close(fd_final); - /* This close finally releases the flock, (now that the final dile + /* This close finally releases the flock, (now that the final file * has been renamed into place and the size has been added). */ if (fd != -1) close(fd); if (filename_tmp) -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev