diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-11-03 01:56:18 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-11-03 01:56:18 +0300 |
commit | 659774979feb9741a441505e26774b35830fd4ca (patch) | |
tree | 596059bbe20959ad54cbfde8bcdf24cd7f9e9f83 /src/os/unix/ngx_freebsd_sendfile_chain.c | |
parent | fe0f5cc6e1e48412235ae91c2f71ec2ec9110a60 (diff) |
nginx-0.0.1-2003-11-03-01:56:18 import
Diffstat (limited to 'src/os/unix/ngx_freebsd_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index c24149928..65dfc03f6 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -31,13 +31,28 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) struct sf_hdtr hdtr; ngx_err_t err; ngx_array_t header, trailer; + ngx_event_t *wev; ngx_hunk_t *file; ngx_chain_t *cl, *tail; - if (!c->write->ready) { + wev = c->write; + + if (!wev->ready) { return in; } +#if (HAVE_KQUEUE) + + if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->kq_eof) { + ngx_log_error(NGX_LOG_ERR, c->log, wev->kq_errno, + "kevent() reported about closed connection"); + + wev->error = 1; + return NGX_CHAIN_ERROR; + } + +#endif + do { cl = in; file = NULL; @@ -181,7 +196,7 @@ ngx_log_debug(c->log, "NOPUSH"); "sendfile() sent only %qd bytes", sent); } else { - c->write->error = 1; + wev->error = 1; ngx_log_error(NGX_LOG_CRIT, c->log, err, "sendfile() failed"); return NGX_CHAIN_ERROR; @@ -194,7 +209,7 @@ ngx_log_debug(c->log, "NOPUSH"); #endif } else { - rc = writev(c->fd, (struct iovec *) header.elts, header.nelts); + rc = writev(c->fd, header.elts, header.nelts); if (rc == -1) { err = ngx_errno; @@ -206,7 +221,7 @@ ngx_log_debug(c->log, "NOPUSH"); ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EINTR"); } else { - c->write->error = 1; + wev->error = 1; ngx_log_error(NGX_LOG_CRIT, c->log, err, "writev() failed"); return NGX_CHAIN_ERROR; } @@ -268,7 +283,7 @@ ngx_log_debug(c->log, "NOPUSH"); * return EAGAIN right away and would not send anything */ - c->write->ready = 0; + wev->ready = 0; break; } @@ -277,7 +292,7 @@ ngx_log_debug(c->log, "NOPUSH"); } while ((tail && tail == in) || eintr); if (in) { - c->write->ready = 0; + wev->ready = 0; } return in; |