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