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

Function aofRewriteBufferWrite

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

Write the buffer (possibly composed of multiple blocks) into the specified * fd. If a short write or any other error happens -1 is returned, * otherwise the number of bytes written is returned. */

Source from the content-addressed store, hash-verified

174 * fd. If a short write or any other error happens -1 is returned,
175 * otherwise the number of bytes written is returned. */
176ssize_t aofRewriteBufferWrite(int fd) {
177 listNode *ln;
178 listIter li;
179 ssize_t count = 0;
180
181 listRewind(server.aof_rewrite_buf_blocks,&li);
182 while((ln = listNext(&li))) {
183 aofrwblock *block = listNodeValue(ln);
184 ssize_t nwritten;
185
186 if (block->used) {
187 nwritten = write(fd,block->buf,block->used);
188 if (nwritten != (ssize_t)block->used) {
189 if (nwritten == 0) errno = EIO;
190 return -1;
191 }
192 count += nwritten;
193 }
194 }
195 return count;
196}
197
198/* ----------------------------------------------------------------------------
199 * AOF file implementation

Callers 1

Calls 3

listRewindFunction · 0.85
listNextFunction · 0.85
writeFunction · 0.70

Tested by

no test coverage detected