comparison src/http/modules/ngx_http_limit_zone_module.c @ 356:b743d290eb3b NGINX_0_6_22

nginx 0.6.22 *) Change: now all ngx_http_perl_module methods return values copied to perl's allocated memory. *) Bugfix: if nginx was built with ngx_http_perl_module, the perl before 5.8.6 was used, and perl supported threads, then during reconfiguration the master process aborted; bug appeared in 0.5.9. Thanks to Boris Zhmurov. *) Bugfix: the ngx_http_perl_module methods may get invalid values of the regex captures. *) Bugfix: a segmentation fault occurred in worker process, if the $r->has_request_body() method was called for a request whose small request body was already received. *) Bugfix: large_client_header_buffers did not freed before going to keep-alive state. Thanks to Olexander Shtepa. *) Bugfix: the last address was missed in the $upstream_addr variable; bug appeared in 0.6.18. *) Bugfix: the "fastcgi_catch_stderr" directive did return error code; now it returns 502 code, that can be rerouted to a next server using the "fastcgi_next_upstream invalid_header" directive. *) Bugfix: a segmentation fault occurred in master process if the "fastcgi_catch_stderr" directive was used; bug appeared in 0.6.10. Thanks to Manlio Perillo.
author Igor Sysoev <http://sysoev.ru>
date Wed, 19 Dec 2007 00:00:00 +0300
parents 390b8f8309d6
children e7dbea1ee115
comparison
equal deleted inserted replaced
355:3ac45897a61c 356:b743d290eb3b
237 237
238 static void 238 static void
239 ngx_http_limit_zone_rbtree_insert_value(ngx_rbtree_node_t *temp, 239 ngx_http_limit_zone_rbtree_insert_value(ngx_rbtree_node_t *temp,
240 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) 240 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
241 { 241 {
242 ngx_http_limit_zone_node_t *lzn, *lznt; 242 ngx_rbtree_node_t **p;
243 ngx_http_limit_zone_node_t *lzn, *lznt;
243 244
244 for ( ;; ) { 245 for ( ;; ) {
245 246
246 if (node->key < temp->key) { 247 if (node->key < temp->key) {
247 248
248 if (temp->left == sentinel) { 249 p = &temp->left;
249 temp->left = node;
250 break;
251 }
252
253 temp = temp->left;
254 250
255 } else if (node->key > temp->key) { 251 } else if (node->key > temp->key) {
256 252
257 if (temp->right == sentinel) { 253 p = &temp->right;
258 temp->right = node;
259 break;
260 }
261
262 temp = temp->right;
263 254
264 } else { /* node->key == temp->key */ 255 } else { /* node->key == temp->key */
265 256
266 lzn = (ngx_http_limit_zone_node_t *) &node->color; 257 lzn = (ngx_http_limit_zone_node_t *) &node->color;
267 lznt = (ngx_http_limit_zone_node_t *) &temp->color; 258 lznt = (ngx_http_limit_zone_node_t *) &temp->color;
268 259
269 if (ngx_memn2cmp(lzn->data, lznt->data, lzn->len, lznt->len) < 0) { 260 p = (ngx_memn2cmp(lzn->data, lznt->data, lzn->len, lznt->len) < 0)
270 261 ? &temp->left : &temp->right;
271 if (temp->left == sentinel) {
272 temp->left = node;
273 break;
274 }
275
276 temp = temp->left;
277
278 } else {
279
280 if (temp->right == sentinel) {
281 temp->right = node;
282 break;
283 }
284
285 temp = temp->right;
286 }
287 } 262 }
288 } 263
289 264 if (*p == sentinel) {
265 break;
266 }
267
268 temp = *p;
269 }
270
271 *p = node;
290 node->parent = temp; 272 node->parent = temp;
291 node->left = sentinel; 273 node->left = sentinel;
292 node->right = sentinel; 274 node->right = sentinel;
293 ngx_rbt_red(node); 275 ngx_rbt_red(node);
294 } 276 }
360 sentinel = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_node_t)); 342 sentinel = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_node_t));
361 if (sentinel == NULL) { 343 if (sentinel == NULL) {
362 return NGX_ERROR; 344 return NGX_ERROR;
363 } 345 }
364 346
365 ngx_rbtree_sentinel_init(sentinel); 347 ngx_rbtree_init(ctx->rbtree, sentinel,
366 348 ngx_http_limit_zone_rbtree_insert_value);
367 ctx->rbtree->root = sentinel;
368 ctx->rbtree->sentinel = sentinel;
369 ctx->rbtree->insert = ngx_http_limit_zone_rbtree_insert_value;
370 349
371 return NGX_OK; 350 return NGX_OK;
372 } 351 }
373 352
374 353