Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_solaris_sendfilev_chain.c @ 8084:eece8e35e64d quic
QUIC: allowed old DCID for initial packets until first ACK.
If a packet sent in response to an initial client packet was lost, then
successive client initial packets were dropped by nginx with the unexpected
dcid message logged. This was because the new DCID generated by the server was
not available to the client.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 09 Sep 2020 16:35:29 +0300 |
parents | 646985c55393 |
children |
rev | line source |
---|---|
272
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
1 |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
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 | 4 * Copyright (C) Nginx, Inc. |
272
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
5 */ |
d4e65d74db9f
nginx-0.0.2-2004-03-01-00:03:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
6 |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
473 | 13 #if (NGX_TEST_BUILD_SOLARIS_SENDFILEV) |
14 | |
15 /* Solaris declarations */ | |
16 | |
17 typedef struct sendfilevec { | |
18 int sfv_fd; | |
19 u_int sfv_flag; | |
20 off_t sfv_off; | |
21 size_t sfv_len; | |
22 } sendfilevec_t; | |
23 | |
24 #define SFV_FD_SELF -2 | |
25 | |
26 static ssize_t sendfilev(int fd, const struct sendfilevec *vec, | |
585 | 27 int sfvcnt, size_t *xferred) |
473 | 28 { |
29 return -1; | |
30 } | |
31 | |
4759
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4596
diff
changeset
|
32 ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, |
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4596
diff
changeset
|
33 off_t limit); |
4c36e15651f7
Fixed compilation with -Wmissing-prototypes.
Ruslan Ermilov <ru@nginx.com>
parents:
4596
diff
changeset
|
34 |
473 | 35 #endif |
36 | |
37 | |
5854
b63e829621ab
Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents:
5851
diff
changeset
|
38 #define NGX_SENDFILEVECS NGX_IOVS_PREALLOCATE |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
39 |
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
40 |
585 | 41 ngx_chain_t * |
42 ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 { |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 int fd; |
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 | 46 off_t size, send, prev_send, aligned, fprev; |
47 size_t sent; | |
48 ssize_t n; | |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
49 ngx_int_t eintr; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
197
diff
changeset
|
50 ngx_err_t err; |
6438
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
51 ngx_buf_t *file; |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
52 ngx_uint_t nsfv; |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
53 sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS]; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 ngx_event_t *wev; |
501 | 55 ngx_chain_t *cl; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 wev = c->write; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 if (!wev->ready) { |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 return in; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 |
452 | 63 if (!c->sendfile) { |
64 return ngx_writev_chain(c, in, limit); | |
65 } | |
66 | |
473 | 67 |
68 /* the maximum limit size is the maximum size_t value - the page size */ | |
69 | |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1182
diff
changeset
|
70 if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) { |
477 | 71 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize; |
473 | 72 } |
73 | |
74 | |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
75 send = 0; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
76 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
77 for ( ;; ) { |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 fd = SFV_FD_SELF; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 prev = NULL; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
197
diff
changeset
|
80 fprev = 0; |
6438
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
81 file = NULL; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 sfv = NULL; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 eintr = 0; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 sent = 0; |
473 | 85 prev_send = send; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
87 nsfv = 0; |
198
34995c5ec6c4
nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
197
diff
changeset
|
88 |
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:
290
diff
changeset
|
89 /* create the sendfilevec and coalesce the neighbouring bufs */ |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
91 for (cl = in; cl && send < limit; cl = cl->next) { |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
92 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
93 if (ngx_buf_special(cl->buf)) { |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 continue; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
97 if (ngx_buf_in_memory_only(cl->buf)) { |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 fd = SFV_FD_SELF; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
100 size = cl->buf->last - cl->buf->pos; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
101 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
102 if (send + size > limit) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
103 size = limit - send; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
104 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
105 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
106 if (prev == cl->buf->pos) { |
473 | 107 sfv->sfv_len += (size_t) size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 } else { |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
110 if (nsfv == NGX_SENDFILEVECS) { |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
111 break; |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
112 } |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
113 |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
114 sfv = &sfvs[nsfv++]; |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
115 |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 sfv->sfv_fd = SFV_FD_SELF; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 sfv->sfv_flag = 0; |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
118 sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos; |
473 | 119 sfv->sfv_len = (size_t) size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 |
473 | 122 prev = cl->buf->pos + (size_t) size; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
123 send += size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 } else { |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 prev = NULL; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 |
473 | 128 size = cl->buf->file_last - cl->buf->file_pos; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
129 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
130 if (send + size > limit) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
131 size = limit - send; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
132 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
133 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
|
134 & ~((off_t) ngx_pagesize - 1); |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
135 |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
136 if (aligned <= cl->buf->file_last) { |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
137 size = aligned - cl->buf->file_pos; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
138 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
139 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
140 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
141 if (fd == cl->buf->file->fd && fprev == cl->buf->file_pos) { |
473 | 142 sfv->sfv_len += (size_t) size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 } else { |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
145 if (nsfv == NGX_SENDFILEVECS) { |
4596
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
146 break; |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
147 } |
089cc5154c1e
IOV_MAX handling microoptimization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4595
diff
changeset
|
148 |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
149 sfv = &sfvs[nsfv++]; |
428
5e73d0ea4dab
nginx-0.0.11-2004-09-16-20:10:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
150 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
151 fd = cl->buf->file->fd; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 sfv->sfv_fd = fd; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 sfv->sfv_flag = 0; |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
154 sfv->sfv_off = cl->buf->file_pos; |
473 | 155 sfv->sfv_len = (size_t) size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 |
6438
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
158 file = cl->buf; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
159 fprev = cl->buf->file_pos + size; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
160 send += size; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 |
5914
4dd67e5d958e
Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
164 n = sendfilev(c->fd, sfvs, nsfv, &sent); |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 if (n == -1) { |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 err = ngx_errno; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
169 switch (err) { |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
170 case NGX_EAGAIN: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
171 break; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
173 case NGX_EINTR: |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
174 eintr = 1; |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
175 break; |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
176 |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
177 default: |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 wev->error = 1; |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
179 ngx_connection_error(c, err, "sendfilev() failed"); |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 return NGX_CHAIN_ERROR; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 } |
3063
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
182 |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
183 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err, |
6f6d7ea70805
refactor EAGAIN/EINTR processing
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
184 "sendfilev() sent only %uz bytes", sent); |
6438
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
185 |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
186 } else if (n == 0 && sent == 0) { |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
187 |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
188 /* |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
189 * sendfilev() is documented to return -1 with errno |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
190 * set to EINVAL if svf_len is greater than the file size, |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
191 * but at least Solaris 11 returns 0 instead |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
192 */ |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
193 |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
194 if (file) { |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
195 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
196 "sendfilev() reported that \"%s\" was truncated at %O", |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
197 file->file->name.data, file->file_pos); |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
198 |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
199 } else { |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
200 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
201 "sendfilev() returned 0 with memory buffers"); |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
202 } |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
203 |
646985c55393
Truncation detection in sendfilev() on Solaris.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5914
diff
changeset
|
204 return NGX_CHAIN_ERROR; |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
198
diff
changeset
|
207 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
461 | 208 "sendfilev: %z %z", n, sent); |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 c->sent += sent; |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5868
diff
changeset
|
212 in = ngx_chain_update_sent(in, sent); |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
214 if (eintr) { |
5868
6bbad2e73245
Fixed counting of sent bytes in the send chain functions on EINTR.
Valentin Bartenev <vbart@nginx.com>
parents:
5854
diff
changeset
|
215 send = prev_send + sent; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
216 continue; |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
217 } |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 |
5851
150df089fe47
Removed the "complete" variable from various send chain functions.
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
219 if (send - prev_send != (off_t) sent) { |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
220 wev->ready = 0; |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4759
diff
changeset
|
221 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
222 } |
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
223 |
5320
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4759
diff
changeset
|
224 if (send >= limit || in == NULL) { |
ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
Gleb Smirnoff <glebius@nginx.com>
parents:
4759
diff
changeset
|
225 return in; |
362
7650aea1816f
nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
344
diff
changeset
|
226 } |
197
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 } |