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. */
| 187 | * fd. If a short write or any other error happens -1 is returned, |
| 188 | * otherwise the number of bytes written is returned. */ |
| 189 | ssize_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 |
no test coverage detected