comparison src/core/nginx.c @ 50:72eb30262aac NGINX_0_1_25

nginx 0.1.25 *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 19 Mar 2005 00:00:00 +0300
parents 6cfc63e68377
children 0d75d65c642f
comparison
equal deleted inserted replaced
49:93dabbc9efb9 50:72eb30262aac
139 ngx_regex_init(); 139 ngx_regex_init();
140 #endif 140 #endif
141 141
142 ngx_pid = ngx_getpid(); 142 ngx_pid = ngx_getpid();
143 143
144 if (!(log = ngx_log_init())) { 144 log = ngx_log_init();
145 if (log == NULL) {
145 return 1; 146 return 1;
146 } 147 }
147 148
148 #if (NGX_OPENSSL) 149 #if (NGX_OPENSSL)
149 ngx_ssl_init(log); 150 ngx_ssl_init(log);
153 154
154 ngx_memzero(&init_cycle, sizeof(ngx_cycle_t)); 155 ngx_memzero(&init_cycle, sizeof(ngx_cycle_t));
155 init_cycle.log = log; 156 init_cycle.log = log;
156 ngx_cycle = &init_cycle; 157 ngx_cycle = &init_cycle;
157 158
158 if (!(init_cycle.pool = ngx_create_pool(1024, log))) { 159 init_cycle.pool = ngx_create_pool(1024, log);
160 if (init_cycle.pool == NULL) {
159 return 1; 161 return 1;
160 } 162 }
161 163
162 if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) { 164 if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) {
163 return 1; 165 return 1;
253 255
254 256
255 static ngx_int_t 257 static ngx_int_t
256 ngx_add_inherited_sockets(ngx_cycle_t *cycle) 258 ngx_add_inherited_sockets(ngx_cycle_t *cycle)
257 { 259 {
258 u_char *p, *v, *inherited; 260 u_char *p, *v, *inherited;
259 ngx_socket_t s; 261 ngx_int_t s;
260 ngx_listening_t *ls; 262 ngx_listening_t *ls;
261 263
262 inherited = (u_char *) getenv(NGINX_VAR); 264 inherited = (u_char *) getenv(NGINX_VAR);
263 265
264 if (inherited == NULL) { 266 if (inherited == NULL) {
265 return NGX_OK; 267 return NGX_OK;
285 break; 287 break;
286 } 288 }
287 289
288 v = p + 1; 290 v = p + 1;
289 291
290 if (!(ls = ngx_array_push(&cycle->listening))) { 292 ls = ngx_array_push(&cycle->listening);
293 if (ls == NULL) {
291 return NGX_ERROR; 294 return NGX_ERROR;
292 } 295 }
293 296
294 ls->fd = s; 297 ls->fd = (ngx_socket_t) s;
295 } 298 }
296 } 299 }
297 300
298 ngx_inherited = 1; 301 ngx_inherited = 1;
299 302
313 ctx.path = argv[0]; 316 ctx.path = argv[0];
314 ctx.name = "new binary process"; 317 ctx.name = "new binary process";
315 ctx.argv = argv; 318 ctx.argv = argv;
316 319
317 var = ngx_alloc(sizeof(NGINX_VAR) 320 var = ngx_alloc(sizeof(NGINX_VAR)
318 + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2, 321 + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,
319 cycle->log); 322 cycle->log);
320 323
321 p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR)); 324 p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));
322 325
323 ls = cycle->listening.elts; 326 ls = cycle->listening.elts;
409 412
410 413
411 static ngx_int_t 414 static ngx_int_t
412 ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv) 415 ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
413 { 416 {
417 #if (NGX_FREEBSD)
418
419 ngx_os_argv = (char **) argv;
420 ngx_argc = argc;
421 ngx_argv = (char **) argv;
422
423 #else
414 size_t len; 424 size_t len;
415 ngx_int_t i; 425 ngx_int_t i;
416 426
417 ngx_os_argv = (char **) argv; 427 ngx_os_argv = (char **) argv;
418
419 ngx_argc = argc; 428 ngx_argc = argc;
420 429
421 #if (NGX_FREEBSD) 430 ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log);
422 431 if (ngx_argv == NULL) {
423 ngx_argv = (char **) argv;
424
425 #else
426
427 if (!(ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log))) {
428 return NGX_ERROR; 432 return NGX_ERROR;
429 } 433 }
430 434
431 for (i = 0; i < argc; i++) { 435 for (i = 0; i < argc; i++) {
432 len = ngx_strlen(argv[i]) + 1; 436 len = ngx_strlen(argv[i]) + 1;
433 437
434 if (!(ngx_argv[i] = ngx_alloc(len, cycle->log))) { 438 ngx_argv[i] = ngx_alloc(len, cycle->log);
439 if (ngx_argv[i] == NULL) {
435 return NGX_ERROR; 440 return NGX_ERROR;
436 } 441 }
437 442
438 ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len); 443 ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len);
439 } 444 }
449 static void * 454 static void *
450 ngx_core_module_create_conf(ngx_cycle_t *cycle) 455 ngx_core_module_create_conf(ngx_cycle_t *cycle)
451 { 456 {
452 ngx_core_conf_t *ccf; 457 ngx_core_conf_t *ccf;
453 458
454 if (!(ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t)))) { 459 ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t));
460 if (ccf == NULL) {
455 return NULL; 461 return NULL;
456 } 462 }
457 463
458 /* 464 /*
459 * set by pcalloc() 465 * set by pcalloc()
532 return NGX_CONF_ERROR; 538 return NGX_CONF_ERROR;
533 } 539 }
534 540
535 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT); 541 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
536 542
537 if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) { 543 ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len);
544 if (ccf->newpid.data == NULL) {
538 return NGX_CONF_ERROR; 545 return NGX_CONF_ERROR;
539 } 546 }
540 547
541 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len), 548 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
542 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT)); 549 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));