27 #define NGX_SENDFILE_LIMIT 2147483647L
31 #define NGX_HEADERS 64
33 #define NGX_HEADERS IOV_MAX
41 off_t size, send, prev_send, aligned, sent, fprev;
51 #if (NGX_HAVE_SENDFILE64)
73 header.
elts = headers;
74 header.
size =
sizeof(
struct iovec);
92 for (cl = in; cl && send < limit; cl = cl->
next) {
101 "zero size buf in sendfile "
102 "t:%d r:%d f:%d %p %p-%p %p %O-%O",
125 if (send + size > limit) {
129 if (prev == cl->
buf->
pos) {
130 iov->iov_len += (size_t) size;
142 iov->iov_base = (
void *) cl->
buf->
pos;
143 iov->iov_len = (
size_t) size;
146 prev = cl->
buf->
pos + (size_t) size;
163 if (setsockopt(c->
fd, IPPROTO_TCP, TCP_NODELAY,
164 (
const void *) &tcp_nodelay,
sizeof(int)) == -1)
177 "setsockopt(TCP_NODELAY) failed");
225 if (send + size > limit) {
231 if (aligned <= cl->buf->file_last) {
236 file_size += (size_t) size;
250 if (file_size == 0) {
255 #if (NGX_HAVE_SENDFILE64)
262 "sendfile: @%O %uz", file->
file_pos, file_size);
284 "sendfile() is not ready");
287 sent = rc > 0 ? rc : 0;
290 "sendfile: %d, @%O %O:%uz",
291 rc, file->
file_pos, sent, file_size);
314 "writev() not ready");
317 sent = rc > 0 ? rc : 0;
322 if (send - prev_send == sent) {
328 for (cl = in; cl; cl = cl->
next) {
355 cl->
buf->
pos += (size_t) sent;
374 if (send >= limit || cl == NULL) {