annotate src/os/unix/ngx_freebsd_sendfile_chain.c @ 5850:f9c83484d9ce

Moved the code for adjusting sent buffers in a separate function.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 13 Aug 2014 15:11:45 +0400
parents 675bda8dcfdb
children 150df089fe47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 265
diff changeset
1
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 265
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 4335
diff changeset
4 * Copyright (C) Nginx, Inc.
272
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 265
diff changeset
5 */
d4e65d74db9f nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 265
diff changeset
6
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_config.h>
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
9 #include <ngx_core.h>
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
10 #include <ngx_event.h>
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
12
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
13 /*
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
14 * Although FreeBSD sendfile() allows to pass a header and a trailer,
4133
59b99f217c6d Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents: 3081
diff changeset
15 * it cannot send a header with a part of the file in one packet until
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
16 * FreeBSD 5.3. Besides, over the fast ethernet connection sendfile()
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
17 * may send the partially filled packets, i.e. the 8 file pages may be sent
290
87e73f067470 nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 272
diff changeset
18 * as the 11 full 1460-bytes packets, then one incomplete 324-bytes packet,
87e73f067470 nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 272
diff changeset
19 * and then again the 11 full 1460-bytes packets.
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
20 *
4572
67653855682e Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents: 4499
diff changeset
21 * Therefore we use the TCP_NOPUSH option (similar to Linux's TCP_CORK)
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
22 * to postpone the sending - it not only sends a header and the first part of
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
23 * the file in one packet, but also sends the file pages in the full packets.
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
24 *
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
25 * But until FreeBSD 4.5 turning TCP_NOPUSH off does not flush a pending
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
26 * data that less than MSS, so that data may be sent with 5 second delay.
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
27 * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
28 * for non-keepalive HTTP connections.
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
29 */
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
597
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
32 #if (IOV_MAX > 64)
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
33 #define NGX_HEADERS 64
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
34 #define NGX_TRAILERS 64
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
35 #else
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
36 #define NGX_HEADERS IOV_MAX
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
37 #define NGX_TRAILERS IOV_MAX
9262f520ce21 nginx-0.3.20-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
38 #endif
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
39
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
40
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
41 ngx_chain_t *
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
42 ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 {
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
44 int rc, flags;
290
87e73f067470 nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 272
diff changeset
45 u_char *prev;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
46 off_t size, send, prev_send, aligned, sent, fprev;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
47 size_t header_size, file_size;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
48 ngx_uint_t eintr, eagain, complete;
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 ngx_err_t err;
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
50 ngx_buf_t *file;
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51 ngx_array_t header, trailer;
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
52 ngx_event_t *wev;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
53 ngx_chain_t *cl;
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
54 struct sf_hdtr hdtr;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
55 struct iovec *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS];
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
56
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
57 wev = c->write;
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
58
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
59 if (!wev->ready) {
144
ef8c87afcfc5 nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
60 return in;
ef8c87afcfc5 nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
61 }
ef8c87afcfc5 nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 143
diff changeset
62
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
63 #if (NGX_HAVE_KQUEUE)
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
64
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 581
diff changeset
65 if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
537
c9ad0d9c7d59 nginx-0.1.43-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
66 (void) ngx_connection_error(c, wev->kq_errno,
c9ad0d9c7d59 nginx-0.1.43-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
67 "kevent() reported about an closed connection");
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
68 wev->error = 1;
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
69 return NGX_CHAIN_ERROR;
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
70 }
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
71
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
72 #endif
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
73
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
74 /* the maximum limit size is the maximum size_t value - the page size */
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
75
1354
f69d1aab6a0f make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents: 1182
diff changeset
76 if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
77 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
78 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
79
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
80 send = 0;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
81 eagain = 0;
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
82 flags = 0;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
83
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
84 header.elts = headers;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
85 header.size = sizeof(struct iovec);
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
86 header.nalloc = NGX_HEADERS;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
87 header.pool = c->pool;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
88
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
89 trailer.elts = trailers;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
90 trailer.size = sizeof(struct iovec);
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
91 trailer.nalloc = NGX_TRAILERS;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
92 trailer.pool = c->pool;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
93
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
94 for ( ;; ) {
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
95 file = NULL;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
96 file_size = 0;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
97 header_size = 0;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
98 eintr = 0;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
99 complete = 0;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
100 prev_send = send;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
101
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
102 header.nelts = 0;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
103 trailer.nelts = 0;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
104
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
105 /* create the header iovec and coalesce the neighbouring bufs */
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
106
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
107 prev = NULL;
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
108 iov = NULL;
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
109
4596
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
110 for (cl = in; cl && send < limit; cl = cl->next) {
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
111
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
112 if (ngx_buf_special(cl->buf)) {
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
113 continue;
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
114 }
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
115
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
116 if (!ngx_buf_in_memory_only(cl->buf)) {
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
117 break;
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
118 }
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
119
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
120 size = cl->buf->last - cl->buf->pos;
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
121
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
122 if (send + size > limit) {
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
123 size = limit - send;
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
124 }
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
125
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
126 if (prev == cl->buf->pos) {
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
127 iov->iov_len += (size_t) size;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
128
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
129 } else {
4596
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
130 if (header.nelts >= IOV_MAX){
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
131 break;
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
132 }
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
133
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
134 iov = ngx_array_push(&header);
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
135 if (iov == NULL) {
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
136 return NGX_CHAIN_ERROR;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
137 }
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
138
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
139 iov->iov_base = (void *) cl->buf->pos;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
140 iov->iov_len = (size_t) size;
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
141 }
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
142
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
143 prev = cl->buf->pos + (size_t) size;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
144 header_size += (size_t) size;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
145 send += size;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
146 }
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
147
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
148
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
149 if (cl && cl->buf->in_file && send < limit) {
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
150 file = cl->buf;
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
151
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
152 /* coalesce the neighbouring file bufs */
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
153
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
154 do {
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
155 size = cl->buf->file_last - cl->buf->file_pos;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
156
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
157 if (send + size > limit) {
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
158 size = limit - send;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
159
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
160 aligned = (cl->buf->file_pos + size + ngx_pagesize - 1)
1182
df449f4a8032 fix sendfile on 64-bit Linux and limit_rate on all 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents: 597
diff changeset
161 & ~((off_t) ngx_pagesize - 1);
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
162
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
163 if (aligned <= cl->buf->file_last) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
164 size = aligned - cl->buf->file_pos;
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
165 }
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
166 }
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
167
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
168 file_size += (size_t) size;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
169 send += size;
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
170 fprev = cl->buf->file_pos + size;
155
46eb23d9471d nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents: 154
diff changeset
171 cl = cl->next;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
172
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
173 } while (cl
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
174 && cl->buf->in_file
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
175 && send < limit
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
176 && file->file->fd == cl->buf->file->fd
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
177 && fprev == cl->buf->file_pos);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
178 }
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
179
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
180
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
181 if (file) {
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
182
4499
778ef9c3fd2d Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
183 /* create the trailer iovec and coalesce the neighbouring bufs */
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
184
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
185 prev = NULL;
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
186 iov = NULL;
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
187
4596
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
188 while (cl && send < limit) {
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
189
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
190 if (ngx_buf_special(cl->buf)) {
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
191 cl = cl->next;
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
192 continue;
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
193 }
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
194
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
195 if (!ngx_buf_in_memory_only(cl->buf)) {
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
196 break;
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
197 }
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
198
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
199 size = cl->buf->last - cl->buf->pos;
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
200
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
201 if (send + size > limit) {
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
202 size = limit - send;
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
203 }
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
204
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
205 if (prev == cl->buf->pos) {
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
206 iov->iov_len += (size_t) size;
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
207
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
208 } else {
4596
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
209 if (trailer.nelts >= IOV_MAX){
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
210 break;
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
211 }
089cc5154c1e IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4572
diff changeset
212
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
213 iov = ngx_array_push(&trailer);
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 483
diff changeset
214 if (iov == NULL) {
428
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
215 return NGX_CHAIN_ERROR;
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
216 }
5e73d0ea4dab nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 402
diff changeset
217
343
6bdf858bff8c nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents: 297
diff changeset
218 iov->iov_base = (void *) cl->buf->pos;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
219 iov->iov_len = (size_t) size;
264
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
220 }
cd009bf7400d nginx-0.0.2-2004-02-19-19:48:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
221
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
222 prev = cl->buf->pos + (size_t) size;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
223 send += size;
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
224 cl = cl->next;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
225 }
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
226 }
67
5a7d1aaa1618 nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents: 63
diff changeset
227
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
228 if (file) {
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
230 if (ngx_freebsd_use_tcp_nopush
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
231 && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
232 {
101
2e069b6e6920 nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 99
diff changeset
233 if (ngx_tcp_nopush(c->fd) == NGX_ERROR) {
5557
188481078faf Use ngx_socket_errno where appropriate.
Piotr Sikora <piotr@cloudflare.com>
parents: 5320
diff changeset
234 err = ngx_socket_errno;
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
235
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
236 /*
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
237 * there is a tiny chance to be interrupted, however,
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
238 * we continue a processing without the TCP_NOPUSH
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
239 */
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
240
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
241 if (err != NGX_EINTR) {
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
242 wev->error = 1;
537
c9ad0d9c7d59 nginx-0.1.43-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
243 (void) ngx_connection_error(c, err,
c9ad0d9c7d59 nginx-0.1.43-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
244 ngx_tcp_nopush_n " failed");
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
245 return NGX_CHAIN_ERROR;
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
246 }
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
247
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
248 } else {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
249 c->tcp_nopush = NGX_TCP_NOPUSH_SET;
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 343
diff changeset
250
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
251 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
252 "tcp_nopush");
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
253 }
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
254 }
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
255
4335
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
256 /*
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
257 * sendfile() does unneeded work if sf_hdtr's count is 0,
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
258 * but corresponding pointer is not NULL
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
259 */
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
260
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
261 hdtr.headers = header.nelts ? (struct iovec *) header.elts: NULL;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
262 hdtr.hdr_cnt = header.nelts;
4335
1003326eccc5 Microoptimization of sendfile(2) usage under FreeBSD.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4133
diff changeset
263 hdtr.trailers = trailer.nelts ? (struct iovec *) trailer.elts: NULL;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
264 hdtr.trl_cnt = trailer.nelts;
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
265
153
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 152
diff changeset
266 /*
155
46eb23d9471d nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents: 154
diff changeset
267 * the "nbytes bug" of the old sendfile() syscall:
5727
675bda8dcfdb FreeBSD has migrated to Bugzilla.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5557
diff changeset
268 * http://bugs.freebsd.org/33771
153
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 152
diff changeset
269 */
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 152
diff changeset
270
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
271 if (!ngx_freebsd_sendfile_nbytes_bug) {
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
272 header_size = 0;
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273 }
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274
203
c9da5900c79e nginx-0.0.1-2003-12-02-08:47:29 import
Igor Sysoev <igor@sysoev.ru>
parents: 201
diff changeset
275 sent = 0;
c9da5900c79e nginx-0.0.1-2003-12-02-08:47:29 import
Igor Sysoev <igor@sysoev.ru>
parents: 201
diff changeset
276
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
277 #if (NGX_HAVE_AIO_SENDFILE)
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
278 flags = c->aio_sendfile ? SF_NODISKIO : 0;
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
279 #endif
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
280
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
281 rc = sendfile(file->file->fd, c->fd, file->file_pos,
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
282 file_size + header_size, &hdtr, &sent, flags);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
283
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
284 if (rc == -1) {
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
285 err = ngx_errno;
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
286
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
287 switch (err) {
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
288 case NGX_EAGAIN:
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
289 eagain = 1;
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
290 break;
216
f1d0e5f09c1e nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 214
diff changeset
291
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
292 case NGX_EINTR:
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
293 eintr = 1;
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
294 break;
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
295
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
296 #if (NGX_HAVE_AIO_SENDFILE)
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
297 case NGX_EBUSY:
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
298 c->busy_sendfile = file;
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
299 break;
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
300 #endif
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
301
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
302 default:
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
303 wev->error = 1;
537
c9ad0d9c7d59 nginx-0.1.43-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
304 (void) ngx_connection_error(c, err, "sendfile() failed");
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
305 return NGX_CHAIN_ERROR;
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
306 }
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
307
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
308 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
309 "sendfile() sent only %O bytes", sent);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
310
483
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
311 /*
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
312 * sendfile() in FreeBSD 3.x-4.x may return value >= 0
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
313 * on success, although only 0 is documented
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
314 */
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
315
3080
af427e13cfd7 small optimization
Igor Sysoev <igor@sysoev.ru>
parents: 3065
diff changeset
316 } else if (rc >= 0 && sent == 0) {
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
317
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
318 /*
483
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
319 * if rc is OK and sent equal to zero, then someone
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
320 * has truncated the file, so the offset became beyond
621229427cba nginx-0.1.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
321 * the end of the file
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
322 */
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
323
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
324 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
3081
10bfdd8d5eb9 log offset passed to sendfile()
Igor Sysoev <igor@sysoev.ru>
parents: 3080
diff changeset
325 "sendfile() reported that \"%s\" was truncated at %O",
10bfdd8d5eb9 log offset passed to sendfile()
Igor Sysoev <igor@sysoev.ru>
parents: 3080
diff changeset
326 file->file->name.data, file->file_pos);
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
327
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
328 return NGX_CHAIN_ERROR;
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
329 }
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
330
214
e0c502f15852 nginx-0.0.1-2003-12-22-12:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents: 203
diff changeset
331 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
332 "sendfile: %d, @%O %O:%uz",
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
333 rc, file->file_pos, sent, file_size + header_size);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
334
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
335 } else {
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
336 rc = writev(c->fd, header.elts, header.nelts);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
337
297
ee394e997c77 nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 290
diff changeset
338 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
339 "writev: %d of %uz", rc, header_size);
297
ee394e997c77 nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 290
diff changeset
340
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
341 if (rc == -1) {
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
342 err = ngx_errno;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
343
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
344 switch (err) {
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
345 case NGX_EAGAIN:
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
346 break;
216
f1d0e5f09c1e nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 214
diff changeset
347
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
348 case NGX_EINTR:
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
349 eintr = 1;
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
350 break;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
351
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
352 default:
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
353 wev->error = 1;
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
354 ngx_connection_error(c, err, "writev() failed");
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
355 return NGX_CHAIN_ERROR;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
356 }
3063
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
357
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
358 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
6f6d7ea70805 refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents: 1354
diff changeset
359 "writev() not ready");
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
360 }
89
29bf798b583f nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents: 88
diff changeset
361
143
5526213be452 nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 142
diff changeset
362 sent = rc > 0 ? rc : 0;
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
363 }
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
364
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
365 if (send - prev_send == sent) {
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
366 complete = 1;
361
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
367 }
446782c909b3 nginx-0.0.7-2004-06-20-23:54:15 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
368
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
369 c->sent += sent;
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
370
5850
f9c83484d9ce Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents: 5727
diff changeset
371 in = ngx_handle_sent_chain(in, sent);
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
372
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
373 #if (NGX_HAVE_AIO_SENDFILE)
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
374 if (c->busy_sendfile) {
5320
ad137a80919f Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents: 4596
diff changeset
375 return in;
3065
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
376 }
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
377 #endif
113cd532b328 aio sendfile
Igor Sysoev <igor@sysoev.ru>
parents: 3063
diff changeset
378
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
379 if (eagain) {
155
46eb23d9471d nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents: 154
diff changeset
380
153
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 152
diff changeset
381 /*
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
382 * sendfile() may return EAGAIN, even if it has sent a whole file
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
383 * part, it indicates that the successive sendfile() call would
253
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
384 * return EAGAIN right away and would not send anything.
b6793bc5034b nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 218
diff changeset
385 * We use it as a hint.
153
c71aeb75c071 nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents: 152
diff changeset
386 */
155
46eb23d9471d nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents: 154
diff changeset
387
170
c42be4185301 nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 163
diff changeset
388 wev->ready = 0;
5320
ad137a80919f Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents: 4596
diff changeset
389 return in;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
390 }
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
391
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
392 if (eintr) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
393 continue;
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
394 }
96
a23d010f356d nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 94
diff changeset
395
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
396 if (!complete) {
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
397 wev->ready = 0;
5320
ad137a80919f Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents: 4596
diff changeset
398 return in;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
399 }
152
fb48bf4fea1c nginx-0.0.1-2003-10-21-11:47:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 144
diff changeset
400
5320
ad137a80919f Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents: 4596
diff changeset
401 if (send >= limit || in == NULL) {
ad137a80919f Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents: 4596
diff changeset
402 return in;
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 361
diff changeset
403 }
142
cb77c084acdb nginx-0.0.1-2003-10-09-11:00:45 import
Igor Sysoev <igor@sysoev.ru>
parents: 103
diff changeset
404 }
63
36d2c25cc9bb nginx-0.0.1-2003-02-26-23:21:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
405 }