33 #define NGX_HEADERS 64
34 #define NGX_TRAILERS 64
36 #define NGX_HEADERS IOV_MAX
37 #define NGX_TRAILERS IOV_MAX
46 off_t size, send, prev_send, aligned, sent, fprev;
47 size_t header_size, file_size;
67 "kevent() reported about an closed connection");
84 header.
elts = headers;
85 header.
size =
sizeof(
struct iovec);
89 trailer.
elts = trailers;
90 trailer.
size =
sizeof(
struct iovec);
110 for (cl = in; cl && send < limit; cl = cl->
next) {
122 if (send + size > limit) {
126 if (prev == cl->
buf->
pos) {
127 iov->iov_len += (size_t) size;
139 iov->iov_base = (
void *) cl->
buf->
pos;
140 iov->iov_len = (
size_t) size;
143 prev = cl->
buf->
pos + (size_t) size;
144 header_size += (size_t) size;
157 if (send + size > limit) {
163 if (aligned <= cl->buf->file_last) {
168 file_size += (size_t) size;
188 while (cl && send < limit) {
201 if (send + size > limit) {
205 if (prev == cl->
buf->
pos) {
206 iov->iov_len += (size_t) size;
218 iov->iov_base = (
void *) cl->
buf->
pos;
219 iov->iov_len = (
size_t) size;
222 prev = cl->
buf->
pos + (size_t) size;
261 hdtr.headers = header.
nelts ? (
struct iovec *) header.
elts: NULL;
262 hdtr.hdr_cnt = header.
nelts;
263 hdtr.trailers = trailer.
nelts ? (
struct iovec *) trailer.
elts: NULL;
264 hdtr.trl_cnt = trailer.
nelts;
277 #if (NGX_HAVE_AIO_SENDFILE)
278 flags = c->aio_sendfile ? SF_NODISKIO : 0;
282 file_size + header_size, &hdtr, &sent, flags);
296 #if (NGX_HAVE_AIO_SENDFILE)
298 c->busy_sendfile = file;
309 "sendfile() sent only %O bytes", sent);
316 }
else if (rc >= 0 && sent == 0) {
325 "sendfile() reported that \"%s\" was truncated at %O",
332 "sendfile: %d, @%O %O:%uz",
333 rc, file->
file_pos, sent, file_size + header_size);
339 "writev: %d of %uz", rc, header_size);
359 "writev() not ready");
362 sent = rc > 0 ? rc : 0;
365 if (send - prev_send == sent) {
371 for (cl = in; cl; cl = cl->
next) {
398 cl->
buf->
pos += (size_t) sent;
408 #if (NGX_HAVE_AIO_SENDFILE)
409 if (c->busy_sendfile) {
436 if (send >= limit || cl == NULL) {