31 #define NGX_HEADERS 64
32 #define NGX_TRAILERS 64
34 #define NGX_HEADERS IOV_MAX
35 #define NGX_TRAILERS IOV_MAX
44 off_t size, send, prev_send, aligned, sent, fprev;
45 off_t header_size, file_size;
65 "kevent() reported about an closed connection");
80 header.
elts = headers;
81 header.
size =
sizeof(
struct iovec);
85 trailer.
elts = trailers;
86 trailer.
size =
sizeof(
struct iovec);
106 for (cl = in; cl && send < limit; cl = cl->
next) {
118 if (send + size > limit) {
122 if (prev == cl->
buf->
pos) {
123 iov->iov_len += (size_t) size;
135 iov->iov_base = (
void *) cl->
buf->
pos;
136 iov->iov_len = (
size_t) size;
139 prev = cl->
buf->
pos + (size_t) size;
153 if (send + size > limit) {
159 if (aligned <= cl->buf->file_last) {
176 if (file && header.
nelts == 0) {
183 while (cl && send < limit) {
196 if (send + size > limit) {
200 if (prev == cl->
buf->
pos) {
201 iov->iov_len += (size_t) size;
213 iov->iov_base = (
void *) cl->
buf->
pos;
214 iov->iov_len = (
size_t) size;
217 prev = cl->
buf->
pos + (size_t) size;
230 hdtr.headers = header.
nelts ? (
struct iovec *) header.
elts: NULL;
231 hdtr.hdr_cnt = header.
nelts;
232 hdtr.trailers = trailer.
nelts ? (
struct iovec *) trailer.
elts: NULL;
233 hdtr.trl_cnt = trailer.
nelts;
235 sent = header_size + file_size;
238 "sendfile: @%O %O h:%O",
262 "sendfile() sent only %O bytes", sent);
265 if (rc == 0 && sent == 0) {
274 "sendfile() reported that \"%s\" was truncated",
281 "sendfile: %d, @%O %O:%O",
282 rc, file->
file_pos, sent, file_size + header_size);
288 "writev: %d of %uz", rc, send);
308 "writev() not ready");
311 sent = rc > 0 ? rc : 0;
314 if (send - prev_send == sent) {
320 for (cl = in; cl; cl = cl->
next) {
347 cl->
buf->
pos += (size_t) sent;
366 if (send >= limit || cl == NULL) {