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_freebsd_sendfile_chain.c | |
parent | 79ddab189fb4bf27abd21a04bb9d1210e06384ac (diff) |
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_freebsd_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 76f6ef235..7199c8654 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -35,6 +35,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) int rc, flags; off_t send, prev_send, sent; size_t file_size; + ssize_t n; ngx_uint_t eintr, eagain; ngx_err_t err; ngx_buf_t *file; @@ -217,33 +218,13 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) rc, file->file_pos, sent, file_size + header.size); } else { - rc = writev(c->fd, header.iovs, header.count); + n = ngx_writev(c, &header); - ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, - "writev: %d of %uz", rc, header.size); - - 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; + sent = (n == NGX_AGAIN) ? 0 : n; } c->sent += sent; |