MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / aofRewriteBufferWrite

Function aofRewriteBufferWrite

src/aof.cpp:189–209  ·  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

187 * fd. If a short write or any other error happens -1 is returned,
188 * otherwise the number of bytes written is returned. */
189ssize_t aofRewriteBufferWrite(int fd) {
190 listNode *ln;
191 listIter li;
192 ssize_t count = 0;
193
194 listRewind(g_pserver->aof_rewrite_buf_blocks,&li);
195 while((ln = listNext(&li))) {
196 aofrwblock *block = (aofrwblock*)listNodeValue(ln);
197 ssize_t nwritten;
198
199 if (block->used) {
200 nwritten = write(fd,block->buf,block->used);
201 if (nwritten != (ssize_t)block->used) {
202 if (nwritten == 0) errno = EIO;
203 return -1;
204 }
205 count += nwritten;
206 }
207 }
208 return count;
209}
210
211/* ----------------------------------------------------------------------------
212 * AOF file implementation

Callers 1

Calls 2

listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected