Mercurial > hg > nginx
diff src/os/unix/ngx_linux_sendfile_chain.c @ 5917:2c64b69daec5
Moved writev() handling code to a separate function.
This reduces code duplication and unifies debug logging of the writev() syscall
among various send chain functions.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 13 Aug 2014 15:11:45 +0400 |
parents | e044893b4587 |
children | c50b5ed3cd4b |
line wrap: on
line diff
--- a/src/os/unix/ngx_linux_sendfile_chain.c Wed Aug 13 15:11:45 2014 +0400 +++ b/src/os/unix/ngx_linux_sendfile_chain.c Wed Aug 13 15:11:45 2014 +0400 @@ -33,6 +33,7 @@ int rc, tcp_nodelay; off_t send, prev_send, sent; size_t file_size; + ssize_t n; ngx_err_t err; ngx_buf_t *file; ngx_uint_t eintr; @@ -199,32 +200,13 @@ rc, file->file_pos, sent, file_size); } else { - rc = writev(c->fd, header.iovs, header.count); - - if (rc == -1) { - err = ngx_errno; - - switch (err) { - case NGX_EAGAIN: - break; + n = ngx_writev(c, &header); - case NGX_EINTR: - eintr = 1; - break; - - default: - wev->error = 1; - ngx_connection_error(c, err, "writev() failed"); - return NGX_CHAIN_ERROR; - } - - ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, - "writev() not ready"); + if (n == NGX_ERROR) { + return NGX_CHAIN_ERROR; } - sent = rc > 0 ? rc : 0; - - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "writev: %O", sent); + sent = (n == NGX_AGAIN) ? 0 : n; } c->sent += sent;