Mercurial > hg > nginx-ranges
comparison src/core/ngx_conf_file.c @ 410:a094317ba307 NGINX_0_7_14
nginx 0.7.14
*) Change: now the ssl_certificate and ssl_certificate_key directives
have not default values.
*) Feature: the "listen" directive supports the "ssl" parameter.
*) Feature: now nginx takes into account a time zone change while
reconfiguration on FreeBSD and Linux.
*) Bugfix: the "listen" directive parameters such as "backlog",
"rcvbuf", etc. were not set, if a default server was not the first
one.
*) Bugfix: if URI part captured by a "rewrite" directive was used as a
query string, then the query string was not escaped.
*) Bugfix: configuration file validity test improvements.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 01 Sep 2008 00:00:00 +0400 |
parents | 12defd37f578 |
children | ff86d646f9df |
comparison
equal
deleted
inserted
replaced
409:d46814b99ca0 | 410:a094317ba307 |
---|---|
5 | 5 |
6 | 6 |
7 #include <ngx_config.h> | 7 #include <ngx_config.h> |
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 | 9 |
10 #define NGX_CONF_BUFFER 4096 | |
10 | 11 |
11 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last); | 12 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last); |
12 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf); | 13 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf); |
13 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 14 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
14 static void ngx_conf_flush_files(ngx_cycle_t *cycle); | 15 static void ngx_conf_flush_files(ngx_cycle_t *cycle); |
41 NULL, /* exit master */ | 42 NULL, /* exit master */ |
42 NGX_MODULE_V1_PADDING | 43 NGX_MODULE_V1_PADDING |
43 }; | 44 }; |
44 | 45 |
45 | 46 |
46 /* The ten fixed arguments */ | 47 /* The eight fixed arguments */ |
47 | 48 |
48 static int argument_number[] = { | 49 static ngx_uint_t argument_number[] = { |
49 NGX_CONF_NOARGS, | 50 NGX_CONF_NOARGS, |
50 NGX_CONF_TAKE1, | 51 NGX_CONF_TAKE1, |
51 NGX_CONF_TAKE2, | 52 NGX_CONF_TAKE2, |
52 NGX_CONF_TAKE3, | 53 NGX_CONF_TAKE3, |
53 NGX_CONF_TAKE4, | 54 NGX_CONF_TAKE4, |
139 return NGX_CONF_ERROR; | 140 return NGX_CONF_ERROR; |
140 } | 141 } |
141 | 142 |
142 cf->conf_file->buffer = b; | 143 cf->conf_file->buffer = b; |
143 | 144 |
144 b->start = ngx_alloc(ngx_pagesize, cf->log); | 145 b->start = ngx_alloc(NGX_CONF_BUFFER, cf->log); |
145 if (b->start == NULL) { | 146 if (b->start == NULL) { |
146 return NGX_CONF_ERROR; | 147 return NGX_CONF_ERROR; |
147 } | 148 } |
148 | 149 |
149 b->pos = b->start; | 150 b->pos = b->start; |
150 b->last = b->start; | 151 b->last = b->start; |
151 b->end = b->last + ngx_pagesize; | 152 b->end = b->last + NGX_CONF_BUFFER; |
152 b->temporary = 1; | 153 b->temporary = 1; |
153 | 154 |
154 cf->conf_file->file.fd = fd; | 155 cf->conf_file->file.fd = fd; |
155 cf->conf_file->file.name.len = filename->len; | 156 cf->conf_file->file.name.len = filename->len; |
156 cf->conf_file->file.name.data = filename->data; | 157 cf->conf_file->file.name.data = filename->data; |
431 | 432 |
432 static ngx_int_t | 433 static ngx_int_t |
433 ngx_conf_read_token(ngx_conf_t *cf) | 434 ngx_conf_read_token(ngx_conf_t *cf) |
434 { | 435 { |
435 u_char *start, ch, *src, *dst; | 436 u_char *start, ch, *src, *dst; |
436 int len; | 437 off_t file_size; |
437 int found, need_space, last_space, sharp_comment, variable; | 438 size_t len; |
438 int quoted, s_quoted, d_quoted; | 439 ssize_t n, size; |
439 ssize_t n; | 440 ngx_uint_t found, need_space, last_space, sharp_comment, variable; |
441 ngx_uint_t quoted, s_quoted, d_quoted, start_line; | |
440 ngx_str_t *word; | 442 ngx_str_t *word; |
441 ngx_buf_t *b; | 443 ngx_buf_t *b; |
442 | 444 |
443 found = 0; | 445 found = 0; |
444 need_space = 0; | 446 need_space = 0; |
448 quoted = s_quoted = d_quoted = 0; | 450 quoted = s_quoted = d_quoted = 0; |
449 | 451 |
450 cf->args->nelts = 0; | 452 cf->args->nelts = 0; |
451 b = cf->conf_file->buffer; | 453 b = cf->conf_file->buffer; |
452 start = b->pos; | 454 start = b->pos; |
455 start_line = cf->conf_file->line; | |
456 | |
457 file_size = ngx_file_size(&cf->conf_file->file.info); | |
453 | 458 |
454 for ( ;; ) { | 459 for ( ;; ) { |
455 | 460 |
456 if (b->pos >= b->last) { | 461 if (b->pos >= b->last) { |
457 | 462 |
458 if (cf->conf_file->file.offset | 463 if (cf->conf_file->file.offset >= file_size) { |
459 >= ngx_file_size(&cf->conf_file->file.info)) | 464 |
460 { | |
461 if (cf->args->nelts > 0) { | 465 if (cf->args->nelts > 0) { |
462 | 466 |
463 if (cf->conf_file->file.fd == NGX_INVALID_FILE) { | 467 if (cf->conf_file->file.fd == NGX_INVALID_FILE) { |
464 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 468 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
465 "unexpected end of parameter, " | 469 "unexpected end of parameter, " |
474 } | 478 } |
475 | 479 |
476 return NGX_CONF_FILE_DONE; | 480 return NGX_CONF_FILE_DONE; |
477 } | 481 } |
478 | 482 |
479 if (b->pos - start) { | 483 len = b->pos - start; |
480 ngx_memcpy(b->start, start, b->pos - start); | 484 |
481 } | 485 if (len == NGX_CONF_BUFFER) { |
482 | 486 cf->conf_file->line = start_line; |
483 n = ngx_read_file(&cf->conf_file->file, | 487 |
484 b->start + (b->pos - start), | 488 if (d_quoted) { |
485 b->end - (b->start + (b->pos - start)), | 489 ch = '"'; |
490 | |
491 } else if (s_quoted) { | |
492 ch = '\''; | |
493 | |
494 } else { | |
495 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
496 "too long parameter \"%*s...\" started", | |
497 10, start); | |
498 return NGX_ERROR; | |
499 } | |
500 | |
501 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
502 "too long parameter, probably " | |
503 "missing terminating \"%c\" character", ch); | |
504 return NGX_ERROR; | |
505 } | |
506 | |
507 if (len) { | |
508 ngx_memcpy(b->start, start, len); | |
509 } | |
510 | |
511 size = (ssize_t) (file_size - cf->conf_file->file.offset); | |
512 | |
513 if (size > b->end - (b->start + len)) { | |
514 size = b->end - (b->start + len); | |
515 } | |
516 | |
517 n = ngx_read_file(&cf->conf_file->file, b->start + len, size, | |
486 cf->conf_file->file.offset); | 518 cf->conf_file->file.offset); |
487 | 519 |
488 if (n == NGX_ERROR) { | 520 if (n == NGX_ERROR) { |
489 return NGX_ERROR; | 521 return NGX_ERROR; |
490 } | 522 } |
491 | 523 |
492 b->pos = b->start + (b->pos - start); | 524 if (n != size) { |
525 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
526 ngx_read_file_n " returned " | |
527 "only %z bytes instead of %z", | |
528 n, size); | |
529 return NGX_ERROR; | |
530 } | |
531 | |
532 b->pos = b->start + len; | |
533 b->last = b->pos + n; | |
493 start = b->start; | 534 start = b->start; |
494 b->last = b->pos + n; | |
495 } | 535 } |
496 | 536 |
497 ch = *b->pos++; | 537 ch = *b->pos++; |
498 | 538 |
499 if (ch == LF) { | 539 if (ch == LF) { |
543 if (ch == ' ' || ch == '\t' || ch == CR || ch == LF) { | 583 if (ch == ' ' || ch == '\t' || ch == CR || ch == LF) { |
544 continue; | 584 continue; |
545 } | 585 } |
546 | 586 |
547 start = b->pos - 1; | 587 start = b->pos - 1; |
588 start_line = cf->conf_file->line; | |
548 | 589 |
549 switch (ch) { | 590 switch (ch) { |
550 | 591 |
551 case ';': | 592 case ';': |
552 case '{': | 593 case '{': |