Mercurial > hg > nginx-vendor-current
annotate src/core/ngx_queue.c @ 558:2da4537168f8 NGINX_0_8_31
nginx 0.8.31
*) Feature: now the "error_page" directive may redirect the 301 and 302
responses.
*) Feature: the $geoip_city_continent_code, $geoip_latitude, and
$geoip_longitude variables.
Thanks to Arvind Sundararajan.
*) Feature: now the ngx_http_image_filter_module deletes always EXIF
and other application specific data if the data consume more than 5%
of a JPEG file.
*) Bugfix: nginx closed a connection if a cached response had an empty
body.
Thanks to Piotr Sikora.
*) Bugfix: nginx might not be built by gcc 4.x if the -O2 or higher
optimization option was used.
Thanks to Maxim Dounin and Denis F. Latypoff.
*) Bugfix: regular expressions in location were always tested in
case-sensitive mode; the bug had appeared in 0.8.25.
*) Bugfix: nginx cached a 304 response if there was the "If-None-Match"
header line in a proxied request.
Thanks to Tim Dettrick and David Kostal.
*) Bugfix: nginx/Windows tried to delete a temporary file twice if the
file should replace an already existent file.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 23 Dec 2009 00:00:00 +0300 |
parents | 820f6378fc00 |
children | d0f7a625f27c |
rev | line source |
---|---|
378 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
11 /* | |
12 * find the middle queue element if the queue has odd number of elements | |
13 * or the first element of the queue's second part otherwise | |
14 */ | |
15 | |
16 ngx_queue_t * | |
17 ngx_queue_middle(ngx_queue_t *queue) | |
18 { | |
19 ngx_queue_t *middle, *next; | |
20 | |
21 middle = ngx_queue_head(queue); | |
22 | |
23 if (middle == ngx_queue_last(queue)) { | |
24 return middle; | |
25 } | |
26 | |
27 next = ngx_queue_head(queue); | |
28 | |
29 for ( ;; ) { | |
30 middle = ngx_queue_next(middle); | |
31 | |
32 next = ngx_queue_next(next); | |
33 | |
34 if (next == ngx_queue_last(queue)) { | |
35 return middle; | |
36 } | |
37 | |
38 next = ngx_queue_next(next); | |
39 | |
40 if (next == ngx_queue_last(queue)) { | |
41 return middle; | |
42 } | |
43 } | |
44 } | |
45 | |
46 | |
47 /* the stable insertion sort */ | |
48 | |
49 void | |
50 ngx_queue_sort(ngx_queue_t *queue, | |
51 ngx_int_t (*cmp)(const ngx_queue_t *, const ngx_queue_t *)) | |
52 { | |
53 ngx_queue_t *q, *prev, *next; | |
54 | |
55 q = ngx_queue_head(queue); | |
56 | |
57 if (q == ngx_queue_last(queue)) { | |
58 return; | |
59 } | |
60 | |
61 for (q = ngx_queue_next(q); q != ngx_queue_sentinel(queue); q = next) { | |
62 | |
63 prev = ngx_queue_prev(q); | |
64 next = ngx_queue_next(q); | |
65 | |
66 ngx_queue_remove(q); | |
67 | |
68 do { | |
69 if (cmp(prev, q) <= 0) { | |
70 break; | |
71 } | |
72 | |
73 prev = ngx_queue_prev(prev); | |
74 | |
75 } while (prev != ngx_queue_sentinel(queue)); | |
76 | |
77 ngx_queue_insert_after(prev, q); | |
78 } | |
79 } |