diff options
Diffstat (limited to 'src/os/unix')
-rw-r--r-- | src/os/unix/ngx_files.c | 2 | ||||
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 7 | ||||
-rw-r--r-- | src/os/unix/ngx_linux_sendfile_chain.c | 59 | ||||
-rw-r--r-- | src/os/unix/ngx_solaris_sendfilev_chain.c | 46 |
4 files changed, 59 insertions, 55 deletions
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c index 5d551ebe7..8b906f097 100644 --- a/src/os/unix/ngx_files.c +++ b/src/os/unix/ngx_files.c @@ -125,7 +125,7 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, ngx_err_t err; ngx_array_t io; - /* use pwrite() if there's the only hunk in a chain */ + /* use pwrite() if there's the only buf in a chain */ if (cl->next == NULL) { return ngx_write_file(file, cl->buf->pos, diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 694ea2226..abc3d19b5 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -162,7 +162,9 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) if (file) { - if (ngx_freebsd_use_tcp_nopush && c->tcp_nopush == 0) { + if (ngx_freebsd_use_tcp_nopush + && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET) + { if (ngx_tcp_nopush(c->fd) == NGX_ERROR) { err = ngx_errno; @@ -180,7 +182,8 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) } } else { - c->tcp_nopush = 1; + c->tcp_nopush = NGX_TCP_NOPUSH_SET; + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "tcp_nopush"); } diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c index 0c6b9d0e8..75f51cfd1 100644 --- a/src/os/unix/ngx_linux_sendfile_chain.c +++ b/src/os/unix/ngx_linux_sendfile_chain.c @@ -58,32 +58,32 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) /* create the iovec and coalesce the neighbouring bufs */ for (cl = in; cl && header.nelts < IOV_MAX; cl = cl->next) { - if (ngx_hunk_special(cl->hunk)) { + if (ngx_buf_special(cl->buf)) { continue; } - if (!ngx_hunk_in_memory_only(cl->hunk)) { + if (!ngx_buf_in_memory_only(cl->buf)) { break; } - if (prev == cl->hunk->pos) { - iov->iov_len += cl->hunk->last - cl->hunk->pos; + if (prev == cl->buf->pos) { + iov->iov_len += cl->buf->last - cl->buf->pos; } else { ngx_test_null(iov, ngx_push_array(&header), NGX_CHAIN_ERROR); - iov->iov_base = (void *) cl->hunk->pos; - iov->iov_len = cl->hunk->last - cl->hunk->pos; + iov->iov_base = (void *) cl->buf->pos; + iov->iov_len = cl->buf->last - cl->buf->pos; } - prev = cl->hunk->last; + prev = cl->buf->last; } /* set TCP_CORK if there is a header before a file */ - if (!c->tcp_nopush == 0 + if (c->tcp_nopush == NGX_TCP_NOPUSH_UNSET && header.nelts != 0 && cl - && cl->hunk->type & NGX_HUNK_FILE) + && cl->buf->in_file) { if (ngx_tcp_nopush(c->fd) == NGX_ERROR) { err = ngx_errno; @@ -100,32 +100,33 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) } } else { - c->tcp_nopush = 1; + c->tcp_nopush = NGX_TCP_NOPUSH_SET; + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "tcp_nopush"); } } - if (header.nelts == 0 && cl && cl->hunk->type & NGX_HUNK_FILE) { + if (header.nelts == 0 && cl && cl->buf->in_file) { - /* get the file hunk */ + /* get the file buf */ - file = cl->hunk; + file = cl->buf; fsize = (size_t) (file->file_last - file->file_pos); fprev = file->file_last; cl = cl->next; - /* coalesce the neighbouring file hunks */ + /* coalesce the neighbouring file bufs */ - while (cl && (cl->hunk->type & NGX_HUNK_FILE)) { - if (file->file->fd != cl->hunk->file->fd - || fprev != cl->hunk->file_pos) + while (cl && (cl->buf->in_file)) { + if (file->file->fd != cl->buf->file->fd + || fprev != cl->buf->file_pos) { break; } - fsize += (size_t) (cl->hunk->file_last - cl->hunk->file_pos); - fprev = cl->hunk->file_last; + fsize += (size_t) (cl->buf->file_last - cl->buf->file_pos); + fprev = cl->buf->file_last; cl = cl->next; } } @@ -199,7 +200,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) for (cl = in; cl; cl = cl->next) { - if (ngx_hunk_special(cl->hunk)) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -207,28 +208,28 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) break; } - size = ngx_hunk_size(cl->hunk); + size = ngx_buf_size(cl->buf); if (sent >= size) { sent -= size; - if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { - cl->hunk->pos = cl->hunk->last; + if (ngx_buf_in_memory(cl->buf)) { + cl->buf->pos = cl->buf->last; } - if (cl->hunk->type & NGX_HUNK_FILE) { - cl->hunk->file_pos = cl->hunk->file_last; + if (cl->buf->in_file) { + cl->buf->file_pos = cl->buf->file_last; } continue; } - if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { - cl->hunk->pos += sent; + if (ngx_buf_in_memory(cl->buf)) { + cl->buf->pos += sent; } - if (cl->hunk->type & NGX_HUNK_FILE) { - cl->hunk->file_pos += sent; + if (cl->buf->in_file) { + cl->buf->file_pos += sent; } break; diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c index 964027f65..352c1623d 100644 --- a/src/os/unix/ngx_solaris_sendfilev_chain.c +++ b/src/os/unix/ngx_solaris_sendfilev_chain.c @@ -43,42 +43,42 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in) /* create the sendfilevec and coalesce the neighbouring bufs */ for (cl = in; cl && vec.nelts < IOV_MAX; cl = cl->next) { - if (ngx_hunk_special(cl->hunk)) { + if (ngx_buf_special(cl->buf)) { continue; } - if (ngx_hunk_in_memory_only(cl->hunk)) { + if (ngx_buf_in_memory_only(cl->buf)) { fd = SFV_FD_SELF; - if (prev == cl->hunk->pos) { - sfv->sfv_len += cl->hunk->last - cl->hunk->pos; + if (prev == cl->buf->pos) { + sfv->sfv_len += cl->buf->last - cl->buf->pos; } else { ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR); sfv->sfv_fd = SFV_FD_SELF; sfv->sfv_flag = 0; - sfv->sfv_off = (off_t) (uintptr_t) cl->hunk->pos; - sfv->sfv_len = cl->hunk->last - cl->hunk->pos; + sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos; + sfv->sfv_len = cl->buf->last - cl->buf->pos; } - prev = cl->hunk->last; + prev = cl->buf->last; } else { prev = NULL; - if (fd == cl->hunk->file->fd && fprev == cl->hunk->file_pos) { - sfv->sfv_len += cl->hunk->file_last - cl->hunk->file_pos; + if (fd == cl->buf->file->fd && fprev == cl->buf->file_pos) { + sfv->sfv_len += cl->buf->file_last - cl->buf->file_pos; } else { ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR); - fd = cl->hunk->file->fd; + fd = cl->buf->file->fd; sfv->sfv_fd = fd; sfv->sfv_flag = 0; - sfv->sfv_off = cl->hunk->file_pos; - sfv->sfv_len = cl->hunk->file_last - cl->hunk->file_pos; + sfv->sfv_off = cl->buf->file_pos; + sfv->sfv_len = cl->buf->file_last - cl->buf->file_pos; } - fprev = cl->hunk->file_last; + fprev = cl->buf->file_last; } } @@ -117,7 +117,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in) for (cl = in; cl; cl = cl->next) { - if (ngx_hunk_special(cl->hunk)) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -125,28 +125,28 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in) break; } - size = ngx_hunk_size(cl->hunk); + size = ngx_buf_size(cl->buf); if (sent >= size) { sent -= size; - if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { - cl->hunk->pos = cl->hunk->last; + if (ngx_buf_in_memory(cl->buf)) { + cl->buf->pos = cl->buf->last; } - if (cl->hunk->type & NGX_HUNK_FILE) { - cl->hunk->file_pos = cl->hunk->file_last; + if (cl->buf->in_file) { + cl->buf->file_pos = cl->buf->file_last; } continue; } - if (cl->hunk->type & NGX_HUNK_IN_MEMORY) { - cl->hunk->pos += sent; + if (ngx_buf_in_memory(cl->buf)) { + cl->buf->pos += sent; } - if (cl->hunk->type & NGX_HUNK_FILE) { - cl->hunk->file_pos += sent; + if (cl->buf->in_file) { + cl->buf->file_pos += sent; } break; |