From 93cd75bbe084f5d94bbf6216200820ff0b2785fe Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 5 Jul 2014 01:11:28 +0200 Subject: aofChildWriteDiffData() better handling of free blocks. --- src/aof.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/aof.c b/src/aof.c index 6858120c9..aa97626a1 100644 --- a/src/aof.c +++ b/src/aof.c @@ -104,10 +104,13 @@ void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int mask) { AE_WRITABLE); return; } - nwritten = write(server.aof_pipe_write_data_to_child,block->buf,block->used); - if (nwritten <= 0) return; - memmove(block->buf,block->buf+nwritten,block->used-nwritten); - block->used -= nwritten; + if (block->used > 0) { + nwritten = write(server.aof_pipe_write_data_to_child, + block->buf,block->used); + if (nwritten <= 0) return; + memmove(block->buf,block->buf+nwritten,block->used-nwritten); + block->used -= nwritten; + } if (block->used == 0) listDelNode(server.aof_rewrite_buf_blocks,ln); } } -- cgit v1.2.1