aofChildWriteDiffData(): write as much as possible.

This commit is contained in:
antirez 2014-07-04 15:54:20 +02:00
parent 30c42f12b0
commit 62f9d34c56

View File

@ -92,10 +92,13 @@ 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;
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);
@ -107,6 +110,7 @@ void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int mask) {
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. */
void aofRewriteBufferAppend(unsigned char *s, unsigned long len) {