mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Avoid unnecessary calls to time(3)
This commit is contained in:
parent
3bc89500d2
commit
297322481d
13
src/aof.c
13
src/aof.c
@ -60,7 +60,6 @@ int startAppendOnly(void) {
|
|||||||
* buffer and write it on disk using this function just before entering
|
* buffer and write it on disk using this function just before entering
|
||||||
* the event loop again. */
|
* the event loop again. */
|
||||||
void flushAppendOnlyFile(void) {
|
void flushAppendOnlyFile(void) {
|
||||||
time_t now;
|
|
||||||
ssize_t nwritten;
|
ssize_t nwritten;
|
||||||
|
|
||||||
if (sdslen(server.aofbuf) == 0) return;
|
if (sdslen(server.aofbuf) == 0) return;
|
||||||
@ -86,21 +85,21 @@ void flushAppendOnlyFile(void) {
|
|||||||
server.aofbuf = sdsempty();
|
server.aofbuf = sdsempty();
|
||||||
server.appendonly_current_size += nwritten;
|
server.appendonly_current_size += nwritten;
|
||||||
|
|
||||||
/* Don't Fsync if no-appendfsync-on-rewrite is set to yes and we have
|
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
|
||||||
* childs performing heavy I/O on disk. */
|
* children doing I/O in the background. */
|
||||||
if (server.no_appendfsync_on_rewrite &&
|
if (server.no_appendfsync_on_rewrite &&
|
||||||
(server.bgrewritechildpid != -1 || server.bgsavechildpid != -1))
|
(server.bgrewritechildpid != -1 || server.bgsavechildpid != -1))
|
||||||
return;
|
return;
|
||||||
/* Fsync if needed */
|
|
||||||
now = time(NULL);
|
/* Perform the fsync if needed. */
|
||||||
if (server.appendfsync == APPENDFSYNC_ALWAYS ||
|
if (server.appendfsync == APPENDFSYNC_ALWAYS ||
|
||||||
(server.appendfsync == APPENDFSYNC_EVERYSEC &&
|
(server.appendfsync == APPENDFSYNC_EVERYSEC &&
|
||||||
now-server.lastfsync > 1))
|
server.unixtime > server.lastfsync))
|
||||||
{
|
{
|
||||||
/* aof_fsync is defined as fdatasync() for Linux in order to avoid
|
/* aof_fsync is defined as fdatasync() for Linux in order to avoid
|
||||||
* flushing metadata. */
|
* flushing metadata. */
|
||||||
aof_fsync(server.appendfd); /* Let's try to get this data on the disk */
|
aof_fsync(server.appendfd); /* Let's try to get this data on the disk */
|
||||||
server.lastfsync = now;
|
server.lastfsync = server.unixtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user