comparison src/event/ngx_event_accept.c @ 122:d25a1d6034f1 NGINX_0_3_8

nginx 0.3.8 *) Security: nginx now checks URI got from a backend in "X-Accel-Redirect" header line or in SSI file for the "/../" paths and zeroes. *) Change: nginx now does not treat the empty user name in the "Authorization" header line as valid one. *) Feature: the "ssl_session_timeout" directives of the ngx_http_ssl_module and ngx_imap_ssl_module. *) Feature: the "auth_http_header" directive of the ngx_imap_auth_http_module. *) Feature: the "add_header" directive. *) Feature: the ngx_http_realip_module. *) Feature: the new variables to use in the "log_format" directive: $bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri, $request_time, $request_length, $upstream_status, $upstream_response_time, $gzip_ratio, $uid_got, $uid_set, $connection, $pipe, and $msec. The parameters in the "%name" form will be canceled soon. *) Change: now the false variable values in the "if" directive are the empty string "" and string starting with "0". *) Bugfix: while using proxied or FastCGI-server nginx may leave connections and temporary files with client requests in open state. *) Bugfix: the worker processes did not flush the buffered logs on graceful exit. *) Bugfix: if the request URI was changes by the "rewrite" directive and the request was proxied in location given by regular expression, then the incorrect request was transferred to backend; bug appeared in 0.2.6. *) Bugfix: the "expires" directive did not remove the previous "Expires" header. *) Bugfix: nginx may stop to accept requests if the "rtsig" method and several worker processes were used. *) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in SSI commands. *) Bugfix: if the response was ended just after the SSI command and gzipping was used, then the response did not transferred complete or did not transferred at all.
author Igor Sysoev <http://sysoev.ru>
date Wed, 09 Nov 2005 00:00:00 +0300
parents dad2fe8ecf08
children df17fbafec8f
comparison
equal deleted inserted replaced
121:737953b238a4 122:d25a1d6034f1
11 11
12 /* the buffer size is enough to hold "struct sockaddr_un" */ 12 /* the buffer size is enough to hold "struct sockaddr_un" */
13 #define NGX_SOCKLEN 512 13 #define NGX_SOCKLEN 512
14 14
15 15
16 static ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle);
17 static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle);
16 static void ngx_close_accepted_connection(ngx_connection_t *c); 18 static void ngx_close_accepted_connection(ngx_connection_t *c);
17 19
18 20
19 void 21 void
20 ngx_event_accept(ngx_event_t *ev) 22 ngx_event_accept(ngx_event_t *ev)
260 && ngx_atomic_cmp_set(ngx_accept_mutex, 0, ngx_pid)) 262 && ngx_atomic_cmp_set(ngx_accept_mutex, 0, ngx_pid))
261 { 263 {
262 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, 264 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
263 "accept mutex locked"); 265 "accept mutex locked");
264 266
265 if (!ngx_accept_mutex_held) { 267 if (ngx_accept_mutex_held
266 if (ngx_enable_accept_events(cycle) == NGX_ERROR) { 268 && (!(ngx_event_flags & NGX_USE_RTSIG_EVENT)
267 *ngx_accept_mutex = 0; 269 || *ngx_accept_mutex_last_owner == (ngx_atomic_t) ngx_pid))
268 return NGX_ERROR; 270 {
269 } 271 return NGX_OK;
270 272 }
271 ngx_accept_mutex_held = 1; 273
272 } 274 if (ngx_enable_accept_events(cycle) == NGX_ERROR) {
275 *ngx_accept_mutex = 0;
276 return NGX_ERROR;
277 }
278
279 ngx_accept_mutex_held = 1;
273 280
274 return NGX_OK; 281 return NGX_OK;
275 } 282 }
276 283
277 if (ngx_accept_mutex_held) { 284 if (ngx_accept_mutex_held) {
284 291
285 return NGX_OK; 292 return NGX_OK;
286 } 293 }
287 294
288 295
289 ngx_int_t 296 static ngx_int_t
290 ngx_enable_accept_events(ngx_cycle_t *cycle) 297 ngx_enable_accept_events(ngx_cycle_t *cycle)
291 { 298 {
292 ngx_uint_t i; 299 ngx_uint_t i;
293 ngx_listening_t *ls; 300 ngx_listening_t *ls;
294 ngx_connection_t *c; 301 ngx_connection_t *c;
297 for (i = 0; i < cycle->listening.nelts; i++) { 304 for (i = 0; i < cycle->listening.nelts; i++) {
298 305
299 c = ls[i].connection; 306 c = ls[i].connection;
300 307
301 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { 308 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
309
310 if (ngx_accept_mutex_held) {
311 c->read->disabled = 1;
312 }
313
302 if (ngx_add_conn(c) == NGX_ERROR) { 314 if (ngx_add_conn(c) == NGX_ERROR) {
303 return NGX_ERROR; 315 return NGX_ERROR;
304 } 316 }
317
318 *ngx_accept_mutex_last_owner = ngx_pid;
305 319
306 } else { 320 } else {
307 if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) { 321 if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) {
308 return NGX_ERROR; 322 return NGX_ERROR;
309 } 323 }
312 326
313 return NGX_OK; 327 return NGX_OK;
314 } 328 }
315 329
316 330
317 ngx_int_t 331 static ngx_int_t
318 ngx_disable_accept_events(ngx_cycle_t *cycle) 332 ngx_disable_accept_events(ngx_cycle_t *cycle)
319 { 333 {
320 ngx_uint_t i; 334 ngx_uint_t i;
321 ngx_listening_t *ls; 335 ngx_listening_t *ls;
322 ngx_connection_t *c; 336 ngx_connection_t *c;