提交 248e9165 编写于 作者: A antirez

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.
上级 d401022d
...@@ -86,6 +86,7 @@ static size_t rioFileWrite(rio *r, const void *buf, size_t len) { ...@@ -86,6 +86,7 @@ static size_t rioFileWrite(rio *r, const void *buf, size_t len) {
if (r->io.file.autosync && if (r->io.file.autosync &&
r->io.file.buffered >= r->io.file.autosync) r->io.file.buffered >= r->io.file.autosync)
{ {
fflush(r->io.file.fp);
aof_fsync(fileno(r->io.file.fp)); aof_fsync(fileno(r->io.file.fp));
r->io.file.buffered = 0; r->io.file.buffered = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册