mirror of https://github.com/mpv-player/mpv
vo_gpu_next: guard from cache save conflict
If multiple instances of mpv are closed at the same time, they will write to the same temporary file. Fix that by using unique temporary file.
This commit is contained in:
parent
d124449c3d
commit
ff7f105c85
|
@ -1557,10 +1557,15 @@ static void save_cache_files(struct priv *p)
|
|||
|
||||
if (!target_file)
|
||||
continue;
|
||||
char *tmp = talloc_asprintf(ta_ctx, "%s~", target_file);
|
||||
FILE *cache = fopen(tmp, "wb");
|
||||
if (!cache)
|
||||
char *tmp = talloc_asprintf(ta_ctx, "%sXXXXXX", target_file);
|
||||
int fd = mkstemp(tmp);
|
||||
if (fd < 0)
|
||||
continue;
|
||||
FILE *cache = fdopen(fd, "wb");
|
||||
if (!cache) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
int ret = pl_cache_save_file(target_cache, cache);
|
||||
if (same_cache)
|
||||
ret += pl_cache_save_file(p->icc_cache, cache);
|
||||
|
|
Loading…
Reference in New Issue