Mercurial > dovecot > core-2.2
changeset 20856:0b861a3aceca
lib: ostream-file: Renamed iov_size to iov_count everywhere and made it unsigned int for consistency.
author | Stephan Bosch <stephan@rename-it.nl> |
---|---|
date | Sat, 30 Apr 2016 13:29:47 +0200 |
parents | 0b12b2cb67dd |
children | 45e7b2203260 |
files | src/lib/ostream-file.c |
diffstat | 1 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/ostream-file.c Wed Oct 12 12:04:10 2016 +0300 +++ b/src/lib/ostream-file.c Sat Apr 30 13:29:47 2016 +0200 @@ -170,18 +170,19 @@ } static ssize_t o_stream_writev(struct file_ostream *fstream, - const struct const_iovec *iov, int iov_size) + const struct const_iovec *iov, + unsigned int iov_count) { ssize_t ret, ret2; size_t size, sent, total_size; bool partial; - int i; + unsigned int i; - for (i = 0, total_size = 0; i < iov_size; i++) + for (i = 0, total_size = 0; i < iov_count; i++) total_size += iov[i].iov_len; o_stream_socket_cork(fstream); - if (iov_size == 1) { + if (iov_count == 1) { i_assert(iov->iov_len > 0); if (!fstream->file || @@ -199,7 +200,7 @@ return -1; sent = 0; partial = FALSE; - while (iov_size > IOV_MAX) { + while (iov_count > IOV_MAX) { size = 0; for (i = 0; i < IOV_MAX; i++) size += iov[i].iov_len; @@ -215,16 +216,16 @@ fstream->buffer_offset += ret; sent += ret; iov += IOV_MAX; - iov_size -= IOV_MAX; + iov_count -= IOV_MAX; } - if (iov_size <= IOV_MAX) { + if (iov_count <= IOV_MAX) { size = 0; - for (i = 0; i < iov_size; i++) + for (i = 0; i < iov_count; i++) size += iov[i].iov_len; ret = writev(fstream->fd, (const struct iovec *)iov, - iov_size); + iov_count); partial = ret != (ssize_t)size; } if (ret > 0) { @@ -240,7 +241,7 @@ if (fstream->file) { if (errno == EINTR) { /* automatically retry */ - return o_stream_writev(fstream, iov, iov_size); + return o_stream_writev(fstream, iov, iov_count); } } else if (errno == EAGAIN || errno == EINTR) { /* try again later */ @@ -262,14 +263,14 @@ of disk space or we're writing to NFS. try to write the rest to resolve this. */ size = ret; - while (iov_size > 0 && size >= iov->iov_len) { + while (iov_count > 0 && size >= iov->iov_len) { size -= iov->iov_len; iov++; - iov_size--; + iov_count--; } - i_assert(iov_size > 0); + i_assert(iov_count > 0); if (size == 0) - ret2 = o_stream_writev(fstream, iov, iov_size); + ret2 = o_stream_writev(fstream, iov, iov_count); else { /* write the first iov separately */ struct const_iovec new_iov; @@ -281,10 +282,10 @@ if (ret2 > 0) { i_assert((size_t)ret2 == new_iov.iov_len); /* write the rest */ - if (iov_size > 1) { + if (iov_count > 1) { ret += ret2; ret2 = o_stream_writev(fstream, iov + 1, - iov_size - 1); + iov_count - 1); } } }