comparison src/core/ngx_conf_file.c @ 10:46833bd150cb NGINX_0_1_5

nginx 0.1.5 *) Bugfix: on Solaris and Linux there may be too many "recvmsg() returned not enough data" alerts. *) Bugfix: there were the "writev() failed (22: Invalid argument)" errors on Solaris in proxy mode without sendfile. On other platforms that do not support sendfile at all the process got caught in an endless loop. *) Bugfix: segmentation fault on Solaris in proxy mode and using sendfile. *) Bugfix: segmentation fault on Solaris. *) Bugfix: on-line upgrade did not work on Linux. *) Bugfix: the ngx_http_autoindex_module module did not escape the spaces, the quotes, and the percent signs in the directory listing. *) Change: the decrease of the copy operations. *) Feature: the userid_p3p directive.
author Igor Sysoev <http://sysoev.ru>
date Thu, 11 Nov 2004 00:00:00 +0300
parents 4b2dafa26fe2
children da8c190bdaba
comparison
equal deleted inserted replaced
9:77eee314ddbd 10:46833bd150cb
71 /* open configuration file */ 71 /* open configuration file */
72 72
73 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN); 73 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
74 if (fd == NGX_INVALID_FILE) { 74 if (fd == NGX_INVALID_FILE) {
75 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno, 75 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
76 ngx_open_file_n " %s failed", filename->data); 76 ngx_open_file_n " \"%s\" failed", filename->data);
77 return NGX_CONF_ERROR; 77 return NGX_CONF_ERROR;
78 } 78 }
79 79
80 prev = cf->conf_file; 80 prev = cf->conf_file;
81 if (!(cf->conf_file = ngx_palloc(cf->pool, sizeof(ngx_conf_file_t)))) { 81 if (!(cf->conf_file = ngx_palloc(cf->pool, sizeof(ngx_conf_file_t)))) {
82 return NGX_CONF_ERROR; 82 return NGX_CONF_ERROR;
83 } 83 }
84 84
85 if (ngx_fd_info(fd, &cf->conf_file->file.info) == -1) { 85 if (ngx_fd_info(fd, &cf->conf_file->file.info) == -1) {
86 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno, 86 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
87 ngx_fd_info_n " %s failed", filename->data); 87 ngx_fd_info_n " \"%s\" failed", filename->data);
88 } 88 }
89 89
90 if (!(cf->conf_file->buffer = ngx_create_temp_buf(cf->pool, 1024))) { 90 if (!(cf->conf_file->buffer = ngx_create_temp_buf(cf->pool, 1024))) {
91 return NGX_CONF_ERROR; 91 return NGX_CONF_ERROR;
92 } 92 }
101 101
102 for ( ;; ) { 102 for ( ;; ) {
103 rc = ngx_conf_read_token(cf); 103 rc = ngx_conf_read_token(cf);
104 104
105 /* 105 /*
106 * ngx_conf_read_token() returns NGX_OK, NGX_ERROR, 106 * ngx_conf_read_token() may return
107 * NGX_CONF_FILE_DONE or NGX_CONF_BLOCK_DONE 107 * NGX_ERROR there is error
108 * NGX_OK the token terminated by ";" was found
109 * NGX_CONF_BLOCK_START the token terminated by "{" was found
110 * NGX_CONF_BLOCK_DONE the "}" was found
111 * NGX_CONF_FILE_DONE the configuration file is done
108 */ 112 */
109 113
110 #if 0 114 #if 0
111 ngx_log_debug(cf->log, "token %d" _ rc); 115 ngx_log_debug(cf->log, "token %d" _ rc);
112 #endif 116 #endif
113 117
114 if (rc == NGX_ERROR) { 118 if (rc == NGX_ERROR) {
115 break; 119 break;
116 } 120 }
117 121
118 if (rc != NGX_OK) { 122 if (rc != NGX_OK && rc != NGX_CONF_BLOCK_START) {
119 break; 123 break;
120 } 124 }
121 125
122 if (cf->handler) { 126 if (cf->handler) {
123 127
124 /* custom handler, i.e. used in http "types { ... }" directive */ 128 /*
129 * the custom handler, i.e., that is used in the http's
130 * "types { ... }" directive
131 */
125 132
126 rv = (*cf->handler)(cf, NULL, cf->handler_conf); 133 rv = (*cf->handler)(cf, NULL, cf->handler_conf);
127 if (rv == NGX_CONF_OK) { 134 if (rv == NGX_CONF_OK) {
128 continue; 135 continue;
129 136
180 cf->conf_file->line); 187 cf->conf_file->line);
181 rc = NGX_ERROR; 188 rc = NGX_ERROR;
182 break; 189 break;
183 } 190 }
184 191
192 if (!(cmd->type & NGX_CONF_BLOCK) && rc != NGX_OK)
193 {
194 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
195 "directive \"%s\" in %s:%d "
196 "is not terminated by \";\"",
197 name->data,
198 cf->conf_file->file.name.data,
199 cf->conf_file->line);
200 rc = NGX_ERROR;
201 break;
202 }
203
204 if ((cmd->type & NGX_CONF_BLOCK)
205 && rc != NGX_CONF_BLOCK_START)
206 {
207 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
208 "directive \"%s\" in %s:%d "
209 "has not the opening \"{\"",
210 name->data,
211 cf->conf_file->file.name.data,
212 cf->conf_file->line);
213 rc = NGX_ERROR;
214 break;
215 }
216
185 /* is the directive's argument count right ? */ 217 /* is the directive's argument count right ? */
186 218
187 if (cmd->type & NGX_CONF_ANY) { 219 if (cmd->type & NGX_CONF_ANY) {
188 valid = 1; 220 valid = 1;
189 221
394 last_space = 1; 426 last_space = 1;
395 need_space = 0; 427 need_space = 0;
396 continue; 428 continue;
397 } 429 }
398 430
399 if (ch == ';' || ch == '{') { 431 if (ch == ';') {
400 return NGX_OK; 432 return NGX_OK;
433 }
434
435 if (ch == '{') {
436 return NGX_CONF_BLOCK_START;
401 } 437 }
402 438
403 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 439 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
404 "unexpected '%c' in %s:%d", 440 "unexpected '%c' in %s:%d",
405 ch, cf->conf_file->file.name.data, 441 ch, cf->conf_file->file.name.data,
423 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 459 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
424 "unexpected '%c' in %s:%d", 460 "unexpected '%c' in %s:%d",
425 ch, cf->conf_file->file.name.data, 461 ch, cf->conf_file->file.name.data,
426 cf->conf_file->line); 462 cf->conf_file->line);
427 return NGX_ERROR; 463 return NGX_ERROR;
464 }
465
466 if (ch == '{') {
467 return NGX_CONF_BLOCK_START;
428 } 468 }
429 469
430 return NGX_OK; 470 return NGX_OK;
431 471
432 case '}': 472 case '}':
536 576
537 #if 0 577 #if 0
538 ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data); 578 ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data);
539 #endif 579 #endif
540 580
541 if (ch == ';' || ch == '{') { 581 if (ch == ';') {
542 return NGX_OK; 582 return NGX_OK;
583 }
584
585 if (ch == '{') {
586 return NGX_CONF_BLOCK_START;
543 } 587 }
544 588
545 found = 0; 589 found = 0;
546 } 590 }
547 } 591 }
572 ngx_str_t old; 616 ngx_str_t old;
573 617
574 if (name->data[0] == '/') { 618 if (name->data[0] == '/') {
575 return NGX_OK; 619 return NGX_OK;
576 } 620 }
621
622 #if (NGX_WIN32)
623
624 if (name->len > 2
625 && name->data[1] == ':'
626 && ((name->data[0] >= 'a' && name->data[0] <= 'z')
627 || (name->data[0] >= 'A' && name->data[0] <= 'Z')))
628 {
629 return NGX_OK;
630 }
631
632 #endif
577 633
578 old = *name; 634 old = *name;
579 635
580 name->len = cycle->root.len + old.len; 636 name->len = cycle->root.len + old.len;
581 637
662 718
663 719
664 void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, 720 void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
665 char *fmt, ...) 721 char *fmt, ...)
666 { 722 {
667 int len; 723 u_char errstr[NGX_MAX_CONF_ERRSTR], *buf, *last;
668 char errstr[NGX_MAX_CONF_ERRSTR];
669 va_list args; 724 va_list args;
670 725
726 last = errstr + NGX_MAX_CONF_ERRSTR;
727
671 va_start(args, fmt); 728 va_start(args, fmt);
672 len = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); 729 buf = ngx_vsnprintf(errstr, last - errstr, fmt, args);
673 va_end(args); 730 va_end(args);
674 731
732 *buf = '\0';
733
675 if (err) { 734 if (err) {
676 len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1, 735 buf = ngx_snprintf(buf, last - buf - 1, " (%d: ", err);
677 " (%d: ", err); 736 buf = ngx_strerror_r(err, buf, last - buf - 1);
678 len += ngx_strerror_r(err, errstr + len, sizeof(errstr) - len - 1); 737 *buf++ = ')';
679 errstr[len++] = ')'; 738 *buf = '\0';
680 errstr[len] = '\0';
681 } 739 }
682 740
683 ngx_log_error(level, cf->log, 0, "%s in %s:%d", 741 ngx_log_error(level, cf->log, 0, "%s in %s:%d",
684 errstr, cf->conf_file->file.name.data, cf->conf_file->line); 742 errstr, cf->conf_file->file.name.data, cf->conf_file->line);
685 } 743 }