Mercurial > hg > nginx-quic
annotate src/core/ngx_buf.c @ 6819:4395758d08e6
Fixed spelling of logical AND operator, no functional changes.
Found by PVS-Studio.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 07 Dec 2016 13:54:30 +0300 |
parents | 40c2f3e06d23 |
children | 7cc2d3a96ea3 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
436
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. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
436
diff
changeset
|
6 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
42
cd035a94e0b6
nginx-0.0.1-2002-12-27-10:27:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
8 #include <ngx_config.h> |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
9 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
499 | 12 ngx_buf_t * |
13 ngx_create_temp_buf(ngx_pool_t *pool, size_t size) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 { |
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
|
15 ngx_buf_t *b; |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
16 |
501 | 17 b = ngx_calloc_buf(pool); |
18 if (b == NULL) { | |
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
|
19 return NULL; |
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
|
20 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
501 | 22 b->start = ngx_palloc(pool, size); |
23 if (b->start == NULL) { | |
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
|
24 return NULL; |
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
|
25 } |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
26 |
499 | 27 /* |
28 * set by ngx_calloc_buf(): | |
29 * | |
30 * b->file_pos = 0; | |
31 * b->file_last = 0; | |
32 * b->file = NULL; | |
33 * b->shadow = NULL; | |
34 * b->tag = 0; | |
509 | 35 * and flags |
499 | 36 */ |
37 | |
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
|
38 b->pos = b->start; |
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
|
39 b->last = b->start; |
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
|
40 b->end = b->last + size; |
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
|
41 b->temporary = 1; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 |
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
|
43 return b; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 } |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
76
diff
changeset
|
45 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
46 |
499 | 47 ngx_chain_t * |
507 | 48 ngx_alloc_chain_link(ngx_pool_t *pool) |
49 { | |
50 ngx_chain_t *cl; | |
51 | |
52 cl = pool->chain; | |
53 | |
54 if (cl) { | |
55 pool->chain = cl->next; | |
56 return cl; | |
57 } | |
58 | |
59 cl = ngx_palloc(pool, sizeof(ngx_chain_t)); | |
60 if (cl == NULL) { | |
61 return NULL; | |
62 } | |
63 | |
64 return cl; | |
65 } | |
66 | |
67 | |
68 ngx_chain_t * | |
499 | 69 ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs) |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
70 { |
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
|
71 u_char *p; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
239
diff
changeset
|
72 ngx_int_t i; |
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
|
73 ngx_buf_t *b; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
74 ngx_chain_t *chain, *cl, **ll; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
75 |
501 | 76 p = ngx_palloc(pool, bufs->num * bufs->size); |
77 if (p == NULL) { | |
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
|
78 return NULL; |
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
|
79 } |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
80 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
81 ll = &chain; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
82 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
83 for (i = 0; i < bufs->num; i++) { |
501 | 84 |
85 b = ngx_calloc_buf(pool); | |
86 if (b == NULL) { | |
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
|
87 return NULL; |
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
|
88 } |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
89 |
499 | 90 /* |
91 * set by ngx_calloc_buf(): | |
92 * | |
93 * b->file_pos = 0; | |
94 * b->file_last = 0; | |
95 * b->file = NULL; | |
96 * b->shadow = NULL; | |
97 * b->tag = 0; | |
509 | 98 * and flags |
499 | 99 * |
100 */ | |
101 | |
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
|
102 b->pos = p; |
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
|
103 b->last = p; |
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
|
104 b->temporary = 1; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
105 |
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
|
106 b->start = p; |
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
|
107 p += bufs->size; |
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
|
108 b->end = p; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
109 |
501 | 110 cl = ngx_alloc_chain_link(pool); |
111 if (cl == NULL) { | |
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
|
112 return NULL; |
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
|
113 } |
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
|
114 |
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
|
115 cl->buf = b; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
116 *ll = cl; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
117 ll = &cl->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
118 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
119 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
120 *ll = NULL; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
121 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
122 return chain; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
123 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
124 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
125 |
499 | 126 ngx_int_t |
127 ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in) | |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
128 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
129 ngx_chain_t *cl, **ll; |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
130 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
131 ll = chain; |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
132 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
133 for (cl = *chain; cl; cl = cl->next) { |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
134 ll = &cl->next; |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
135 } |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
136 |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
137 while (in) { |
501 | 138 cl = ngx_alloc_chain_link(pool); |
139 if (cl == NULL) { | |
140 return NGX_ERROR; | |
141 } | |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
142 |
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
|
143 cl->buf = in->buf; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
144 *ll = cl; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
145 ll = &cl->next; |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
146 in = in->next; |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
147 } |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
148 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
154
diff
changeset
|
149 *ll = NULL; |
136
da00cde00e8a
nginx-0.0.1-2003-10-02-09:39:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
150 |
134
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
151 return NGX_OK; |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
152 } |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
153 |
d57c6835225c
nginx-0.0.1-2003-09-26-09:45:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
132
diff
changeset
|
154 |
581 | 155 ngx_chain_t * |
156 ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free) | |
157 { | |
158 ngx_chain_t *cl; | |
159 | |
160 if (*free) { | |
161 cl = *free; | |
162 *free = cl->next; | |
163 cl->next = NULL; | |
164 return cl; | |
165 } | |
166 | |
167 cl = ngx_alloc_chain_link(p); | |
168 if (cl == NULL) { | |
169 return NULL; | |
170 } | |
171 | |
172 cl->buf = ngx_calloc_buf(p); | |
173 if (cl->buf == NULL) { | |
174 return NULL; | |
175 } | |
176 | |
177 cl->next = NULL; | |
178 | |
179 return cl; | |
180 } | |
181 | |
182 | |
499 | 183 void |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
184 ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy, |
499 | 185 ngx_chain_t **out, ngx_buf_tag_t tag) |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
186 { |
499 | 187 ngx_chain_t *cl; |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
188 |
6797
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
189 if (*out) { |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
190 if (*busy == NULL) { |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
191 *busy = *out; |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
192 |
6797
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
193 } else { |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
194 for (cl = *busy; cl->next; cl = cl->next) { /* void */ } |
455 | 195 |
6797
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
196 cl->next = *out; |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
197 } |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
198 |
40c2f3e06d23
Core: slight optimization in ngx_chain_update_chains().
hucongcong <hucong.c@foxmail.com>
parents:
5915
diff
changeset
|
199 *out = NULL; |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
200 } |
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
201 |
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
202 while (*busy) { |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
203 cl = *busy; |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
204 |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
205 if (ngx_buf_size(cl->buf) != 0) { |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
206 break; |
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
207 } |
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
208 |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
209 if (cl->buf->tag != tag) { |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
210 *busy = cl->next; |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
211 ngx_free_chain(p, cl); |
135
e29909bd9b8a
nginx-0.0.1-2003-09-28-23:29:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
134
diff
changeset
|
212 continue; |
e29909bd9b8a
nginx-0.0.1-2003-09-28-23:29:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
134
diff
changeset
|
213 } |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
214 |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
215 cl->buf->pos = cl->buf->start; |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2414
diff
changeset
|
216 cl->buf->last = cl->buf->start; |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
217 |
499 | 218 *busy = cl->next; |
219 cl->next = *free; | |
220 *free = cl; | |
132
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
221 } |
949f45d1589a
nginx-0.0.1-2003-09-24-20:44:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
222 } |
5850
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
223 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
224 |
5915
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
225 off_t |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
226 ngx_chain_coalesce_file(ngx_chain_t **in, off_t limit) |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
227 { |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
228 off_t total, size, aligned, fprev; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
229 ngx_fd_t fd; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
230 ngx_chain_t *cl; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
231 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
232 total = 0; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
233 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
234 cl = *in; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
235 fd = cl->buf->file->fd; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
236 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
237 do { |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
238 size = cl->buf->file_last - cl->buf->file_pos; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
239 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
240 if (size > limit - total) { |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
241 size = limit - total; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
242 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
243 aligned = (cl->buf->file_pos + size + ngx_pagesize - 1) |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
244 & ~((off_t) ngx_pagesize - 1); |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
245 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
246 if (aligned <= cl->buf->file_last) { |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
247 size = aligned - cl->buf->file_pos; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
248 } |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
249 } |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
250 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
251 total += size; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
252 fprev = cl->buf->file_pos + size; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
253 cl = cl->next; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
254 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
255 } while (cl |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
256 && cl->buf->in_file |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
257 && total < limit |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
258 && fd == cl->buf->file->fd |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
259 && fprev == cl->buf->file_pos); |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
260 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
261 *in = cl; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
262 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
263 return total; |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
264 } |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
265 |
ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
5912
diff
changeset
|
266 |
5850
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
267 ngx_chain_t * |
5912
de68ed551bfb
Renamed ngx_handle_sent_chain() to ngx_chain_update_sent().
Valentin Bartenev <vbart@nginx.com>
parents:
5850
diff
changeset
|
268 ngx_chain_update_sent(ngx_chain_t *in, off_t sent) |
5850
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
269 { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
270 off_t size; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
271 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
272 for ( /* void */ ; in; in = in->next) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
273 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
274 if (ngx_buf_special(in->buf)) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
275 continue; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
276 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
277 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
278 if (sent == 0) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
279 break; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
280 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
281 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
282 size = ngx_buf_size(in->buf); |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
283 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
284 if (sent >= size) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
285 sent -= size; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
286 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
287 if (ngx_buf_in_memory(in->buf)) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
288 in->buf->pos = in->buf->last; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
289 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
290 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
291 if (in->buf->in_file) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
292 in->buf->file_pos = in->buf->file_last; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
293 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
294 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
295 continue; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
296 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
297 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
298 if (ngx_buf_in_memory(in->buf)) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
299 in->buf->pos += (size_t) sent; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
300 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
301 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
302 if (in->buf->in_file) { |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
303 in->buf->file_pos += sent; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
304 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
305 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
306 break; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
307 } |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
308 |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
309 return in; |
f9c83484d9ce
Moved the code for adjusting sent buffers in a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
310 } |