Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
29732248
Commit
29732248
authored
Aug 18, 2011
by
Pieter Noordhuis
Committed by
antirez
Sep 13, 2011
Browse files
Avoid unnecessary calls to time(3)
parent
3bc89500
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
29732248
...
...
@@ -60,7 +60,6 @@ int startAppendOnly(void) {
* buffer and write it on disk using this function just before entering
* the event loop again. */
void
flushAppendOnlyFile
(
void
)
{
time_t
now
;
ssize_t
nwritten
;
if
(
sdslen
(
server
.
aofbuf
)
==
0
)
return
;
...
...
@@ -86,21 +85,21 @@ void flushAppendOnlyFile(void) {
server
.
aofbuf
=
sdsempty
();
server
.
appendonly_current_size
+=
nwritten
;
/* Don't
F
sync if no-appendfsync-on-rewrite is set to yes and
we hav
e
* child
s performing heavy I/O on disk
. */
/* Don't
f
sync if no-appendfsync-on-rewrite is set to yes and
there ar
e
* child
ren doing I/O in the background
. */
if
(
server
.
no_appendfsync_on_rewrite
&&
(
server
.
bgrewritechildpid
!=
-
1
||
server
.
bgsavechildpid
!=
-
1
))
return
;
/* Fsync if needed */
now
=
time
(
NULL
);
/* Perform the fsync if needed. */
if
(
server
.
appendfsync
==
APPENDFSYNC_ALWAYS
||
(
server
.
appendfsync
==
APPENDFSYNC_EVERYSEC
&&
now
-
server
.
lastfsync
>
1
))
server
.
unixtime
>
server
.
lastfsync
))
{
/* aof_fsync is defined as fdatasync() for Linux in order to avoid
* flushing metadata. */
aof_fsync
(
server
.
appendfd
);
/* Let's try to get this data on the disk */
server
.
lastfsync
=
now
;
server
.
lastfsync
=
server
.
unixtime
;
}
}
...
...
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