mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
util/disk_cache: check rename result
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 <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
67911fa4b8
commit
274aaa331c
1 changed files with 6 additions and 2 deletions
|
|
@ -878,7 +878,11 @@ cache_put(void *job, int thread_index)
|
|||
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);
|
||||
|
|
@ -886,7 +890,7 @@ cache_put(void *job, int thread_index)
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue