diff options
author | Valentin Bartenev <vbart@nginx.com> | 2014-08-13 15:11:45 +0400 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2014-08-13 15:11:45 +0400 |
commit | a301e1a7064b0d83a2f456a305f07962ad4f0773 (patch) | |
tree | acc9b36408691221b10271b9e8104cafa5b7125c /src/os/unix/ngx_linux_sendfile_chain.c | |
parent | 79ddab189fb4bf27abd21a04bb9d1210e06384ac (diff) | |
download | nginx-a301e1a7064b0d83a2f456a305f07962ad4f0773.tar.gz nginx-a301e1a7064b0d83a2f456a305f07962ad4f0773.zip |
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.
Diffstat (limited to 'src/os/unix/ngx_linux_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_linux_sendfile_chain.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c index c83677f0f..f1fcc748a 100644 --- a/src/os/unix/ngx_linux_sendfile_chain.c +++ b/src/os/unix/ngx_linux_sendfile_chain.c @@ -33,6 +33,7 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) 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 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) rc, file->file_pos, sent, file_size); } else { - rc = writev(c->fd, header.iovs, header.count); + n = ngx_writev(c, &header); - if (rc == -1) { - err = ngx_errno; - - switch (err) { - case NGX_EAGAIN: - break; - - 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; |