diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-08-30 09:52:39 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-08-30 09:52:39 +0000 |
commit | bfff03406d869119eb0cec68f028e8ab6fd6caa5 (patch) | |
tree | df66c97cc1e19310ce18a8d882480bdfa0c32780 /src/os/unix/ngx_freebsd_sendfile_chain.c | |
parent | ddda411d146607ec6cd61fcbb3fff95340a28df2 (diff) | |
download | nginx-bfff03406d869119eb0cec68f028e8ab6fd6caa5.tar.gz nginx-bfff03406d869119eb0cec68f028e8ab6fd6caa5.zip |
aio sendfile
Diffstat (limited to 'src/os/unix/ngx_freebsd_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 26e386357..976b6d0b4 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -40,7 +40,7 @@ ngx_chain_t * ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) { - int rc; + int rc, flags; u_char *prev; off_t size, send, prev_send, aligned, sent, fprev; size_t header_size, file_size; @@ -78,6 +78,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) send = 0; eagain = 0; + flags = 0; header.elts = headers; header.size = sizeof(struct iovec); @@ -261,8 +262,12 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) sent = 0; +#if (NGX_HAVE_AIO_SENDFILE) + flags = c->aio_sendfile ? SF_NODISKIO : 0; +#endif + rc = sendfile(file->file->fd, c->fd, file->file_pos, - file_size + header_size, &hdtr, &sent, 0); + file_size + header_size, &hdtr, &sent, flags); if (rc == -1) { err = ngx_errno; @@ -276,6 +281,12 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) eintr = 1; break; +#if (NGX_HAVE_AIO_SENDFILE) + case NGX_EBUSY: + c->busy_sendfile = file; + break; +#endif + default: wev->error = 1; (void) ngx_connection_error(c, err, "sendfile() failed"); @@ -383,6 +394,12 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) break; } +#if (NGX_HAVE_AIO_SENDFILE) + if (c->busy_sendfile) { + return cl; + } +#endif + if (eagain) { /* |