Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
d1a53a37
Commit
d1a53a37
authored
Sep 01, 2008
by
Rémi Denis-Courmont
Committed by
Rémi Denis-Courmont
May 06, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Atomically update the cache file
parent
7037664e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/modules/cache.c
src/modules/cache.c
+15
-5
No files found.
src/modules/cache.c
View file @
d1a53a37
...
...
@@ -506,7 +506,10 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
free
(
psz_cachedir
);
msg_Dbg
(
p_this
,
"writing plugins cache %s"
,
psz_filename
);
file
=
utf8_fopen
(
psz_filename
,
"wb"
);
char
psz_tmpname
[
sizeof
(
psz_filename
)
+
12
];
snprintf
(
psz_tmpname
,
sizeof
(
psz_tmpname
),
"%s.%"
PRIu32
,
psz_filename
,
(
uint32_t
)
getpid
());
file
=
utf8_fopen
(
psz_tmpname
,
"wb"
);
if
(
file
==
NULL
)
goto
error
;
...
...
@@ -597,13 +600,20 @@ void CacheSave( vlc_object_t *p_this, module_bank_t *p_bank )
/* Fill-up file size */
i_file_size
=
ftell
(
file
);
fseek
(
file
,
0
,
SEEK_SET
);
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
||
fflush
(
file
))
/* flush libc buffers */
goto
error
;
if
(
fclose
(
file
)
==
0
)
#ifndef WIN32
rename
(
psz_tmpname
,
psz_filename
);
/* atomically replace old cache */
fclose
(
file
);
#else
remove
(
psz_filename
);
fclose
(
file
);
rename
(
psz_tmpname
,
psz_filename
);
#endif
return
;
/* success! */
file
=
NULL
;
error:
msg_Warn
(
p_this
,
"could not write plugins cache %s (%m)"
,
psz_filename
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment