Mercurial > hg > nginx-quic
annotate src/core/ngx_palloc.c @ 8467:2ab7b55ae4a0
Stream: the "fastopen" parameter of the "listen" directive.
Based on a patch by Anbang Wen.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 20 May 2021 19:59:16 +0300 |
parents | ad2360782ecd |
children |
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 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
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:
87
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 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
12 static ngx_inline void *ngx_palloc_small(ngx_pool_t *pool, size_t size, |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
13 ngx_uint_t align); |
2049 | 14 static void *ngx_palloc_block(ngx_pool_t *pool, size_t size); |
15 static void *ngx_palloc_large(ngx_pool_t *pool, size_t size); | |
16 | |
17 | |
501 | 18 ngx_pool_t * |
19 ngx_create_pool(size_t size, ngx_log_t *log) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 { |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
21 ngx_pool_t *p; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
3388 | 23 p = ngx_memalign(NGX_POOL_ALIGNMENT, size, log); |
501 | 24 if (p == NULL) { |
527 | 25 return NULL; |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
26 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 |
2049 | 28 p->d.last = (u_char *) p + sizeof(ngx_pool_t); |
29 p->d.end = (u_char *) p + size; | |
30 p->d.next = NULL; | |
2920
cb7d05c097db
do not test a pool block space if we can not allocated from the block 4 times
Igor Sysoev <igor@sysoev.ru>
parents:
2917
diff
changeset
|
31 p->d.failed = 0; |
2049 | 32 |
2057
24eebb21b5d2
fix max size allocated from pool
Igor Sysoev <igor@sysoev.ru>
parents:
2056
diff
changeset
|
33 size = size - sizeof(ngx_pool_t); |
24eebb21b5d2
fix max size allocated from pool
Igor Sysoev <igor@sysoev.ru>
parents:
2056
diff
changeset
|
34 p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size : NGX_MAX_ALLOC_FROM_POOL; |
24eebb21b5d2
fix max size allocated from pool
Igor Sysoev <igor@sysoev.ru>
parents:
2056
diff
changeset
|
35 |
581 | 36 p->current = p; |
37 p->chain = NULL; | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 p->large = NULL; |
509 | 39 p->cleanup = NULL; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 p->log = log; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 return p; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
45 |
501 | 46 void |
47 ngx_destroy_pool(ngx_pool_t *pool) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 { |
509 | 49 ngx_pool_t *p, *n; |
50 ngx_pool_large_t *l; | |
51 ngx_pool_cleanup_t *c; | |
52 | |
53 for (c = pool->cleanup; c; c = c->next) { | |
54 if (c->handler) { | |
1744 | 55 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
56 "run cleanup: %p", c); | |
509 | 57 c->handler(c->data); |
58 } | |
59 } | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
61 #if (NGX_DEBUG) |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
62 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
63 /* |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
64 * we could allocate the pool->log from this pool |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3388
diff
changeset
|
65 * so we cannot use this log while free()ing the pool |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
66 */ |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
104
diff
changeset
|
67 |
6452
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
68 for (l = pool->large; l; l = l->next) { |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
69 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %p", l->alloc); |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
70 } |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
71 |
2049 | 72 for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) { |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
73 ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
2049 | 74 "free: %p, unused: %uz", p, p->d.end - p->d.last); |
133
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
75 |
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
76 if (n == NULL) { |
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
77 break; |
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
78 } |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
79 } |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
80 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
81 #endif |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
82 |
6452
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
83 for (l = pool->large; l; l = l->next) { |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
84 if (l->alloc) { |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
85 ngx_free(l->alloc); |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
86 } |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
87 } |
6be7e59fdd2c
Core: moved logging before freeing large blocks of pool.
Valentin Bartenev <vbart@nginx.com>
parents:
5742
diff
changeset
|
88 |
2049 | 89 for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) { |
477 | 90 ngx_free(p); |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
91 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
92 if (n == NULL) { |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
93 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
94 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
104
diff
changeset
|
95 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
98 |
2337 | 99 void |
100 ngx_reset_pool(ngx_pool_t *pool) | |
101 { | |
102 ngx_pool_t *p; | |
103 ngx_pool_large_t *l; | |
104 | |
105 for (l = pool->large; l; l = l->next) { | |
106 if (l->alloc) { | |
107 ngx_free(l->alloc); | |
108 } | |
109 } | |
110 | |
111 for (p = pool; p; p = p->d.next) { | |
112 p->d.last = (u_char *) p + sizeof(ngx_pool_t); | |
5521
320abeb364e6
Core: improved ngx_reset_pool() (ticket #490).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
113 p->d.failed = 0; |
2337 | 114 } |
5521
320abeb364e6
Core: improved ngx_reset_pool() (ticket #490).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
115 |
320abeb364e6
Core: improved ngx_reset_pool() (ticket #490).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
116 pool->current = pool; |
320abeb364e6
Core: improved ngx_reset_pool() (ticket #490).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
117 pool->chain = NULL; |
320abeb364e6
Core: improved ngx_reset_pool() (ticket #490).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
118 pool->large = NULL; |
2337 | 119 } |
120 | |
121 | |
501 | 122 void * |
123 ngx_palloc(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
|
124 { |
6455
ad2360782ecd
Core: introduced the NGX_DEBUG_PALLOC macro.
Valentin Bartenev <vbart@nginx.com>
parents:
6454
diff
changeset
|
125 #if !(NGX_DEBUG_PALLOC) |
2049 | 126 if (size <= pool->max) { |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
127 return ngx_palloc_small(pool, size, 1); |
2049 | 128 } |
6455
ad2360782ecd
Core: introduced the NGX_DEBUG_PALLOC macro.
Valentin Bartenev <vbart@nginx.com>
parents:
6454
diff
changeset
|
129 #endif |
2049 | 130 |
131 return ngx_palloc_large(pool, size); | |
132 } | |
133 | |
134 | |
135 void * | |
136 ngx_pnalloc(ngx_pool_t *pool, size_t size) | |
137 { | |
6455
ad2360782ecd
Core: introduced the NGX_DEBUG_PALLOC macro.
Valentin Bartenev <vbart@nginx.com>
parents:
6454
diff
changeset
|
138 #if !(NGX_DEBUG_PALLOC) |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
139 if (size <= pool->max) { |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
140 return ngx_palloc_small(pool, size, 0); |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
141 } |
6455
ad2360782ecd
Core: introduced the NGX_DEBUG_PALLOC macro.
Valentin Bartenev <vbart@nginx.com>
parents:
6454
diff
changeset
|
142 #endif |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
143 |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
144 return ngx_palloc_large(pool, size); |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
145 } |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
146 |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
147 |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
148 static ngx_inline void * |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
149 ngx_palloc_small(ngx_pool_t *pool, size_t size, ngx_uint_t align) |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
150 { |
2049 | 151 u_char *m; |
152 ngx_pool_t *p; | |
153 | |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
154 p = pool->current; |
2049 | 155 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
156 do { |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
157 m = p->d.last; |
2049 | 158 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
159 if (align) { |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
160 m = ngx_align_ptr(m, NGX_ALIGNMENT); |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
161 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
163 if ((size_t) (p->d.end - m) >= size) { |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
164 p->d.last = m + size; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
166 return m; |
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
167 } |
2049 | 168 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
169 p = p->d.next; |
2049 | 170 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
171 } while (p); |
2049 | 172 |
6453
12248fe20689
Core: introduced the ngx_palloc_small() function.
Valentin Bartenev <vbart@nginx.com>
parents:
6452
diff
changeset
|
173 return ngx_palloc_block(pool, size); |
2049 | 174 } |
175 | |
581 | 176 |
2049 | 177 static void * |
178 ngx_palloc_block(ngx_pool_t *pool, size_t size) | |
179 { | |
180 u_char *m; | |
2055 | 181 size_t psize; |
5742
c45c9812cf11
Core: removed meaningless check from ngx_palloc_block().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5521
diff
changeset
|
182 ngx_pool_t *p, *new; |
931
87f456ff13b0
fix segfault in "out of memory" situation
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
183 |
2055 | 184 psize = (size_t) (pool->d.end - (u_char *) pool); |
185 | |
3388 | 186 m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log); |
2056 | 187 if (m == NULL) { |
2049 | 188 return NULL; |
189 } | |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
190 |
2056 | 191 new = (ngx_pool_t *) m; |
192 | |
193 new->d.end = m + psize; | |
2055 | 194 new->d.next = NULL; |
2920
cb7d05c097db
do not test a pool block space if we can not allocated from the block 4 times
Igor Sysoev <igor@sysoev.ru>
parents:
2917
diff
changeset
|
195 new->d.failed = 0; |
2055 | 196 |
2056 | 197 m += sizeof(ngx_pool_data_t); |
2289
857c161d2768
align first allocation from additional pool block, this fixes bus error on sun4v
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
198 m = ngx_align_ptr(m, NGX_ALIGNMENT); |
2056 | 199 new->d.last = m + size; |
200 | |
5742
c45c9812cf11
Core: removed meaningless check from ngx_palloc_block().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5521
diff
changeset
|
201 for (p = pool->current; p->d.next; p = p->d.next) { |
2920
cb7d05c097db
do not test a pool block space if we can not allocated from the block 4 times
Igor Sysoev <igor@sysoev.ru>
parents:
2917
diff
changeset
|
202 if (p->d.failed++ > 4) { |
5742
c45c9812cf11
Core: removed meaningless check from ngx_palloc_block().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5521
diff
changeset
|
203 pool->current = p->d.next; |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
204 } |
2049 | 205 } |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
206 |
2049 | 207 p->d.next = new; |
208 | |
209 return m; | |
210 } | |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
211 |
2049 | 212 |
213 static void * | |
214 ngx_palloc_large(ngx_pool_t *pool, size_t size) | |
215 { | |
216 void *p; | |
2917
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
217 ngx_uint_t n; |
2049 | 218 ngx_pool_large_t *large; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
3328
c16e1213bf96
large allocation should not be aligned to a page size
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
220 p = ngx_alloc(size, pool->log); |
501 | 221 if (p == NULL) { |
347
f48d579daf78
nginx-0.0.3-2004-06-08-20:26:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
222 return NULL; |
f48d579daf78
nginx-0.0.3-2004-06-08-20:26:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
223 } |
2129 | 224 |
2917
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
225 n = 0; |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
226 |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
227 for (large = pool->large; large; large = large->next) { |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
228 if (large->alloc == NULL) { |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
229 large->alloc = p; |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
230 return p; |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
231 } |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
232 |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
233 if (n++ > 3) { |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
234 break; |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
235 } |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
236 } |
62010fa37ead
try to reuse last 4 free large allocation links
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
237 |
6454
f61472978419
Core: use ngx_palloc_small() to allocate ngx_pool_large_t.
Valentin Bartenev <vbart@nginx.com>
parents:
6453
diff
changeset
|
238 large = ngx_palloc_small(pool, sizeof(ngx_pool_large_t), 1); |
2129 | 239 if (large == NULL) { |
240 ngx_free(p); | |
241 return NULL; | |
242 } | |
243 | |
244 large->alloc = p; | |
245 large->next = pool->large; | |
246 pool->large = large; | |
247 | |
248 return p; | |
249 } | |
250 | |
251 | |
252 void * | |
253 ngx_pmemalign(ngx_pool_t *pool, size_t size, size_t alignment) | |
254 { | |
255 void *p; | |
256 ngx_pool_large_t *large; | |
257 | |
258 p = ngx_memalign(alignment, size, pool->log); | |
259 if (p == NULL) { | |
260 return NULL; | |
261 } | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 |
6454
f61472978419
Core: use ngx_palloc_small() to allocate ngx_pool_large_t.
Valentin Bartenev <vbart@nginx.com>
parents:
6453
diff
changeset
|
263 large = ngx_palloc_small(pool, sizeof(ngx_pool_large_t), 1); |
629 | 264 if (large == NULL) { |
1317 | 265 ngx_free(p); |
629 | 266 return NULL; |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
267 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
269 large->alloc = p; |
629 | 270 large->next = pool->large; |
271 pool->large = large; | |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
272 |
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
273 return p; |
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
274 } |
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
275 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
276 |
501 | 277 ngx_int_t |
278 ngx_pfree(ngx_pool_t *pool, void *p) | |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
279 { |
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
280 ngx_pool_large_t *l; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
282 for (l = pool->large; l; l = l->next) { |
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
283 if (p == l->alloc) { |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
284 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
461 | 285 "free: %p", l->alloc); |
477 | 286 ngx_free(l->alloc); |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
287 l->alloc = NULL; |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
288 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
289 return NGX_OK; |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
290 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 } |
436
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
292 |
9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
293 return NGX_DECLINED; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 |
156
afc333135a6b
nginx-0.0.1-2003-10-23-10:13:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
133
diff
changeset
|
296 |
501 | 297 void * |
298 ngx_pcalloc(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
|
299 { |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 void *p; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 p = ngx_palloc(pool, size); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
303 if (p) { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
304 ngx_memzero(p, size); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
305 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 return p; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
308 } |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
309 |
509 | 310 |
311 ngx_pool_cleanup_t * | |
563 | 312 ngx_pool_cleanup_add(ngx_pool_t *p, size_t size) |
509 | 313 { |
314 ngx_pool_cleanup_t *c; | |
315 | |
316 c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t)); | |
317 if (c == NULL) { | |
318 return NULL; | |
319 } | |
320 | |
563 | 321 if (size) { |
322 c->data = ngx_palloc(p, size); | |
323 if (c->data == NULL) { | |
324 return NULL; | |
325 } | |
326 | |
327 } else { | |
328 c->data = NULL; | |
329 } | |
330 | |
331 c->handler = NULL; | |
509 | 332 c->next = p->cleanup; |
333 | |
334 p->cleanup = c; | |
335 | |
563 | 336 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, p->log, 0, "add cleanup: %p", c); |
337 | |
509 | 338 return c; |
339 } | |
340 | |
341 | |
342 void | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
343 ngx_pool_run_cleanup_file(ngx_pool_t *p, ngx_fd_t fd) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
344 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
345 ngx_pool_cleanup_t *c; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
346 ngx_pool_cleanup_file_t *cf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
347 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
348 for (c = p->cleanup; c; c = c->next) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
349 if (c->handler == ngx_pool_cleanup_file) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
350 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
351 cf = c->data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
352 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
353 if (cf->fd == fd) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
354 c->handler(cf); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
355 c->handler = NULL; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
356 return; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
357 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
358 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
359 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
360 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
361 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
362 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2337
diff
changeset
|
363 void |
509 | 364 ngx_pool_cleanup_file(void *data) |
365 { | |
366 ngx_pool_cleanup_file_t *c = data; | |
367 | |
1744 | 368 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, c->log, 0, "file cleanup: fd:%d", |
369 c->fd); | |
563 | 370 |
509 | 371 if (ngx_close_file(c->fd) == NGX_FILE_ERROR) { |
372 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, | |
373 ngx_close_file_n " \"%s\" failed", c->name); | |
374 } | |
375 } | |
376 | |
377 | |
1075
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
378 void |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
379 ngx_pool_delete_file(void *data) |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
380 { |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
381 ngx_pool_cleanup_file_t *c = data; |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
382 |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
383 ngx_err_t err; |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
384 |
1744 | 385 ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, c->log, 0, "file cleanup: fd:%d %s", |
386 c->fd, c->name); | |
1075
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
387 |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
388 if (ngx_delete_file(c->name) == NGX_FILE_ERROR) { |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
389 err = ngx_errno; |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
390 |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
391 if (err != NGX_ENOENT) { |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
392 ngx_log_error(NGX_LOG_CRIT, c->log, err, |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
393 ngx_delete_file_n " \"%s\" failed", c->name); |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
394 } |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
395 } |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
396 |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
397 if (ngx_close_file(c->fd) == NGX_FILE_ERROR) { |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
398 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
399 ngx_close_file_n " \"%s\" failed", c->name); |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
400 } |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
401 } |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
402 |
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
931
diff
changeset
|
403 |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
404 #if 0 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
405 |
501 | 406 static void * |
407 ngx_get_cached_block(size_t size) | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
408 { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
409 void *p; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
410 ngx_cached_block_slot_t *slot; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
411 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
412 if (ngx_cycle->cache == NULL) { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
413 return NULL; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
414 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
415 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
416 slot = &ngx_cycle->cache[(size + ngx_pagesize - 1) / ngx_pagesize]; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
417 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
418 slot->tries++; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
419 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
420 if (slot->number) { |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
421 p = slot->block; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
422 slot->block = slot->block->next; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
423 slot->number--; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
424 return p; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
425 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
426 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
427 return NULL; |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
428 } |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
429 |
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
430 #endif |