Mercurial > hg > nginx-mail
comparison src/core/ngx_connection.c @ 92:45945fa8b8ba NGINX_0_2_0
nginx 0.2.0
*) The pid-file names used during online upgrade was changed and now is
not required a manual rename operation. The old master process adds
the ".oldbin" suffix to its pid-file and executes a new binary file.
The new master process creates usual pid-file without the ".newbin"
suffix. If the master process exits, then old master process renames
back its pid-file with the ".oldbin" suffix to the pid-file without
suffix.
*) Change: the "worker_connections" directive, new name of the
"connections" directive; now the directive specifies maximum number
of connections, but not maximum socket descriptor number.
*) Feature: SSL supports the session cache inside one worker process.
*) Feature: the "satisfy_any" directive.
*) Change: the ngx_http_access_module and ngx_http_auth_basic_module do
not run for subrequests.
*) Feature: the "worker_rlimit_nofile" and "worker_rlimit_sigpending"
directives.
*) Bugfix: if all backend using in load-balancing failed after one
error, then nginx did not try do connect to them during 60 seconds.
*) Bugfix: in IMAP/POP3 command argument parsing.
Thanks to Rob Mueller.
*) Bugfix: errors while using SSL in IMAP/POP3 proxy.
*) Bugfix: errors while using SSI and gzipping.
*) Bugfix: the "Expires" and "Cache-Control" header lines were omitted
from the 304 responses.
Thanks to Alexandr Kukushkin.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 23 Sep 2005 00:00:00 +0400 |
parents | 71c46860eb55 |
children | dad2fe8ecf08 |
comparison
equal
deleted
inserted
replaced
91:c3eee83ea942 | 92:45945fa8b8ba |
---|---|
235 ngx_socket_n " %V failed", &ls[i].addr_text); | 235 ngx_socket_n " %V failed", &ls[i].addr_text); |
236 return NGX_ERROR; | 236 return NGX_ERROR; |
237 } | 237 } |
238 | 238 |
239 #if (NGX_WIN32) | 239 #if (NGX_WIN32) |
240 | |
240 /* | 241 /* |
241 * Winsock assignes a socket number divisible by 4 | 242 * Winsock assignes a socket number divisible by 4 |
242 * so to find a connection we divide a socket number by 4. | 243 * so to find a connection we divide a socket number by 4. |
243 */ | 244 */ |
244 | 245 |
245 if (s % 4) { | 246 if (s % 4) { |
246 ngx_log_error(NGX_LOG_EMERG, ls->log, 0, | 247 ngx_log_error(NGX_LOG_EMERG, log, 0, |
247 ngx_socket_n " created socket %d", s); | 248 ngx_socket_n " created socket %d", s); |
248 return NGX_ERROR; | 249 return NGX_ERROR; |
249 } | 250 } |
250 #endif | 251 #endif |
251 | 252 |
327 | 328 |
328 | 329 |
329 void | 330 void |
330 ngx_close_listening_sockets(ngx_cycle_t *cycle) | 331 ngx_close_listening_sockets(ngx_cycle_t *cycle) |
331 { | 332 { |
332 ngx_uint_t i; | 333 ngx_uint_t i; |
333 ngx_socket_t fd; | 334 ngx_listening_t *ls; |
334 ngx_listening_t *ls; | 335 ngx_connection_t *c; |
335 | 336 |
336 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { | 337 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
337 return; | 338 return; |
338 } | 339 } |
339 | 340 |
340 ngx_accept_mutex_held = 0; | 341 ngx_accept_mutex_held = 0; |
341 ngx_accept_mutex = NULL; | 342 ngx_accept_mutex = NULL; |
342 | 343 |
343 ls = cycle->listening.elts; | 344 ls = cycle->listening.elts; |
344 for (i = 0; i < cycle->listening.nelts; i++) { | 345 for (i = 0; i < cycle->listening.nelts; i++) { |
345 fd = ls[i].fd; | 346 |
346 | 347 c = ls[i].connection; |
347 #if (NGX_WIN32) | |
348 /* | |
349 * Winsock assignes a socket number divisible by 4 | |
350 * so to find a connection we divide a socket number by 4. | |
351 */ | |
352 | |
353 fd /= 4; | |
354 #endif | |
355 | 348 |
356 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { | 349 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { |
357 if (cycle->connections[fd].read->active) { | 350 if (c->read->active) { |
358 ngx_del_conn(&cycle->connections[fd], NGX_CLOSE_EVENT); | 351 ngx_del_conn(c, NGX_CLOSE_EVENT); |
359 } | 352 } |
360 | 353 |
361 } else { | 354 } else { |
362 if (cycle->read_events[fd].active) { | 355 if (c->read->active) { |
363 ngx_del_event(&cycle->read_events[fd], | 356 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); |
364 NGX_READ_EVENT, NGX_CLOSE_EVENT); | 357 } |
365 } | 358 } |
366 } | 359 |
367 | 360 ngx_free_connection(c); |
368 if (ngx_close_socket(fd) == -1) { | 361 |
362 c->fd = (ngx_socket_t) -1; | |
363 | |
364 if (ngx_close_socket(ls[i].fd) == -1) { | |
369 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, | 365 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, |
370 ngx_close_socket_n " %V failed", &ls[i].addr_text); | 366 ngx_close_socket_n " %V failed", &ls[i].addr_text); |
371 } | 367 } |
372 | 368 } |
373 cycle->connections[fd].fd = (ngx_socket_t) -1; | 369 } |
370 | |
371 | |
372 ngx_connection_t * | |
373 ngx_get_connection(ngx_socket_t s, ngx_log_t *log) | |
374 { | |
375 ngx_connection_t *c; | |
376 | |
377 /* disable warning: Win32 SOCKET is u_int while UNIX socket is int */ | |
378 | |
379 if (ngx_cycle->files && (ngx_uint_t) s >= ngx_cycle->files_n) { | |
380 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
381 "the new socket has number %d, " | |
382 "but only %ui files are available", | |
383 s, ngx_cycle->files_n); | |
384 return NULL; | |
385 } | |
386 | |
387 /* ngx_mutex_lock */ | |
388 | |
389 c = ngx_cycle->free_connections; | |
390 | |
391 if (c == NULL) { | |
392 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
393 "%ui worker_connections is not enough", | |
394 ngx_cycle->connection_n); | |
395 | |
396 /* ngx_mutex_unlock */ | |
397 | |
398 return NULL; | |
399 } | |
400 | |
401 ngx_cycle->free_connections = c->data; | |
402 ngx_cycle->free_connection_n--; | |
403 | |
404 /* ngx_mutex_unlock */ | |
405 | |
406 if (ngx_cycle->files) { | |
407 ngx_cycle->files[s] = c; | |
408 } | |
409 | |
410 return c; | |
411 } | |
412 | |
413 | |
414 void | |
415 ngx_free_connection(ngx_connection_t *c) | |
416 { | |
417 /* ngx_mutex_lock */ | |
418 | |
419 c->data = ngx_cycle->free_connections; | |
420 ngx_cycle->free_connections = c; | |
421 ngx_cycle->free_connection_n++; | |
422 | |
423 /* ngx_mutex_unlock */ | |
424 | |
425 if (ngx_cycle->files) { | |
426 ngx_cycle->files[c->fd] = NULL; | |
374 } | 427 } |
375 } | 428 } |
376 | 429 |
377 | 430 |
378 void | 431 void |
449 c->read->closed = 1; | 502 c->read->closed = 1; |
450 c->write->closed = 1; | 503 c->write->closed = 1; |
451 | 504 |
452 #endif | 505 #endif |
453 | 506 |
507 ngx_free_connection(c); | |
508 | |
454 fd = c->fd; | 509 fd = c->fd; |
455 c->fd = (ngx_socket_t) -1; | 510 c->fd = (ngx_socket_t) -1; |
456 c->data = NULL; | |
457 | 511 |
458 if (ngx_close_socket(fd) == -1) { | 512 if (ngx_close_socket(fd) == -1) { |
459 | 513 |
460 /* we use ngx_cycle->log because c->log was in c->pool */ | 514 /* we use ngx_cycle->log because c->log was in c->pool */ |
461 | 515 |