comparison src/core/ngx_rbtree.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 052a7b1d40e5
children 9121a0a91f47
comparison
equal deleted inserted replaced
355:3ac45897a61c 356:b743d290eb3b
95 95
96 void 96 void
97 ngx_rbtree_insert_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, 97 ngx_rbtree_insert_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node,
98 ngx_rbtree_node_t *sentinel) 98 ngx_rbtree_node_t *sentinel)
99 { 99 {
100 ngx_rbtree_node_t **p;
101
100 for ( ;; ) { 102 for ( ;; ) {
101 103
102 if (node->key < temp->key) { 104 p = (node->key < temp->key) ? &temp->left : &temp->right;
103 105
104 if (temp->left == sentinel) { 106 if (*p == sentinel) {
105 temp->left = node; 107 break;
106 break; 108 }
107 } 109
108 110 temp = *p;
109 temp = temp->left; 111 }
110 112
111 } else { 113 *p = node;
112
113 if (temp->right == sentinel) {
114 temp->right = node;
115 break;
116 }
117
118 temp = temp->right;
119 }
120 }
121
122 node->parent = temp; 114 node->parent = temp;
123 node->left = sentinel; 115 node->left = sentinel;
124 node->right = sentinel; 116 node->right = sentinel;
125 ngx_rbt_red(node); 117 ngx_rbt_red(node);
126 } 118 }
128 120
129 void 121 void
130 ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, 122 ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node,
131 ngx_rbtree_node_t *sentinel) 123 ngx_rbtree_node_t *sentinel)
132 { 124 {
125 ngx_rbtree_node_t **p;
126
133 for ( ;; ) { 127 for ( ;; ) {
134 128
135 /* 129 /*
136 * Timer values 130 * Timer values
137 * 1) are spread in small range, usually several minutes, 131 * 1) are spread in small range, usually several minutes,
138 * 2) and overflow each 49 days, if milliseconds are stored in 32 bits. 132 * 2) and overflow each 49 days, if milliseconds are stored in 32 bits.
139 * The comparison takes into account that overflow. 133 * The comparison takes into account that overflow.
140 */ 134 */
141 135
142 if ((ngx_rbtree_key_int_t) node->key - (ngx_rbtree_key_int_t) temp->key 136 /* node->key < temp->key */
143 < 0) 137
144 { 138 p = ((ngx_rbtree_key_int_t) node->key - (ngx_rbtree_key_int_t) temp->key
145 /* node->key < temp->key */ 139 < 0)
146 140 ? &temp->left : &temp->right;
147 if (temp->left == sentinel) { 141
148 temp->left = node; 142 if (*p == sentinel) {
149 break; 143 break;
150 } 144 }
151 145
152 temp = temp->left; 146 temp = *p;
153 147 }
154 } else { 148
155 149 *p = node;
156 if (temp->right == sentinel) {
157 temp->right = node;
158 break;
159 }
160
161 temp = temp->right;
162 }
163 }
164
165 node->parent = temp; 150 node->parent = temp;
166 node->left = sentinel; 151 node->left = sentinel;
167 node->right = sentinel; 152 node->right = sentinel;
168 ngx_rbt_red(node); 153 ngx_rbt_red(node);
169 } 154 }