diff options
author | antirez <antirez@gmail.com> | 2014-07-04 15:54:20 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-07-04 15:54:20 +0200 |
commit | 62f9d34c5625e356c4376868def8a6458479f09f (patch) | |
tree | bc71e68c58b1c0c0d2afec3c84be19abe69a79fa /src/aof.c | |
parent | 30c42f12b098a5e44fe7f517ba0a47e5c4b5e588 (diff) | |
download | redis-62f9d34c5625e356c4376868def8a6458479f09f.tar.gz |
aofChildWriteDiffData(): write as much as possible.
Diffstat (limited to 'src/aof.c')
-rw-r--r-- | src/aof.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -92,20 +92,24 @@ unsigned long aofRewriteBufferSize(void) { * rewrite. We send pieces of our AOF differences buffer so that the final * write when the child finishes the rewrite will be small. */ void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int mask) { - listNode *ln = listFirst(server.aof_rewrite_buf_blocks); - aofrwblock *block = ln ? ln->value : NULL; + listNode *ln; + aofrwblock *block; ssize_t nwritten; - if (server.aof_stop_sending_diff || !block) { - aeDeleteFileEvent(server.el,server.aof_pipe_write_data_to_child, - AE_WRITABLE); - return; + while(1) { + ln = listFirst(server.aof_rewrite_buf_blocks); + block = ln ? ln->value : NULL; + if (server.aof_stop_sending_diff || !block) { + aeDeleteFileEvent(server.el,server.aof_pipe_write_data_to_child, + 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) listDelNode(server.aof_rewrite_buf_blocks,ln); } - 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); } /* Append data to the AOF rewrite buffer, allocating new blocks if needed. */ |