Event handler used to send data to the child process doing the AOF * rewrite. We send pieces of our AOF differences buffer so that the final * write when the child finishes the rewrite will be small. */
| 93 | * rewrite. We send pieces of our AOF differences buffer so that the final |
| 94 | * write when the child finishes the rewrite will be small. */ |
| 95 | void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int mask) { |
| 96 | listNode *ln; |
| 97 | aofrwblock *block; |
| 98 | ssize_t nwritten; |
| 99 | UNUSED(el); |
| 100 | UNUSED(fd); |
| 101 | UNUSED(privdata); |
| 102 | UNUSED(mask); |
| 103 | |
| 104 | while(1) { |
| 105 | ln = listFirst(server.aof_rewrite_buf_blocks); |
| 106 | block = ln ? ln->value : NULL; |
| 107 | if (server.aof_stop_sending_diff || !block) { |
| 108 | aeDeleteFileEvent(server.el,server.aof_pipe_write_data_to_child, |
| 109 | AE_WRITABLE); |
| 110 | return; |
| 111 | } |
| 112 | if (block->used > 0) { |
| 113 | nwritten = write(server.aof_pipe_write_data_to_child, |
| 114 | block->buf,block->used); |
| 115 | if (nwritten <= 0) return; |
| 116 | memmove(block->buf,block->buf+nwritten,block->used-nwritten); |
| 117 | block->used -= nwritten; |
| 118 | block->free += nwritten; |
| 119 | } |
| 120 | if (block->used == 0) listDelNode(server.aof_rewrite_buf_blocks,ln); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /* Append data to the AOF rewrite buffer, allocating new blocks if needed. */ |
| 125 | void aofRewriteBufferAppend(unsigned char *s, unsigned long len) { |
nothing calls this directly
no test coverage detected