MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aofChildWriteDiffData

Function aofChildWriteDiffData

app/redis-6.2.6/src/aof.c:95–122  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
95void 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. */
125void aofRewriteBufferAppend(unsigned char *s, unsigned long len) {

Callers

nothing calls this directly

Calls 4

aeDeleteFileEventFunction · 0.85
listDelNodeFunction · 0.85
writeFunction · 0.70
memmoveFunction · 0.50

Tested by

no test coverage detected