summaryrefslogtreecommitdiff
path: root/src/rio.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-01-22 09:54:43 +0100
committerantirez <antirez@gmail.com>2014-01-22 09:54:55 +0100
commit172f14d48c26d35435a77cafbb49458a1a788887 (patch)
tree45901fe279bec086536d386de0010a059510dfc3 /src/rio.c
parent80e80668f47698320bff4fe45ce2ecd2a463d787 (diff)
downloadredis-172f14d48c26d35435a77cafbb49458a1a788887.tar.gz
Use fflush() before fsync() in rio.c.
Incremental flushing in rio.c is only used to avoid huge kernel buffers synched to slow disks creating big latency spikes, so this fix has no durability implications, however it is certainly more correct to make sure that the FILE buffers are flushed to the kernel before calling fsync on the file descriptor. Thanks to Li Shao Kai for reporting this issue in the Redis mailing list.
Diffstat (limited to 'src/rio.c')
-rw-r--r--src/rio.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/rio.c b/src/rio.c
index 405e789e6..44f9b7a01 100644
--- a/src/rio.c
+++ b/src/rio.c
@@ -86,6 +86,7 @@ static size_t rioFileWrite(rio *r, const void *buf, size_t len) {
if (r->io.file.autosync &&
r->io.file.buffered >= r->io.file.autosync)
{
+ fflush(r->io.file.fp);
aof_fsync(fileno(r->io.file.fp));
r->io.file.buffered = 0;
}