comparison src/core/ngx_conf_file.c @ 484:ed5e10fb40fc NGINX_0_7_54

nginx 0.7.54 *) Feature: the ngx_http_image_filter_module. *) Feature: the "proxy_ignore_headers" and "fastcgi_ignore_headers" directives. *) Bugfix: a segmentation fault might occur in worker process, if an "open_file_cache_errors off" directive was used; the bug had appeared in 0.7.53. *) Bugfix: the "port_in_redirect off" directive did not work; the bug had appeared in 0.7.39. *) Bugfix: improve handling of "select" method errors. *) Bugfix: of "select() failed (10022: ...)" error in nginx/Windows. *) Bugfix: in error text descriptions in nginx/Windows; the bug had appeared in 0.7.53.
author Igor Sysoev <http://sysoev.ru>
date Fri, 01 May 2009 00:00:00 +0400
parents 392c16f2d858
children 98143f74eb3d
comparison
equal deleted inserted replaced
483:0a2f4b42ddad 484:ed5e10fb40fc
59 59
60 60
61 char * 61 char *
62 ngx_conf_param(ngx_conf_t *cf) 62 ngx_conf_param(ngx_conf_t *cf)
63 { 63 {
64 char *rv;
64 ngx_str_t *param; 65 ngx_str_t *param;
65 ngx_buf_t b; 66 ngx_buf_t b;
66 ngx_conf_file_t conf_file; 67 ngx_conf_file_t conf_file;
67 68
68 param = &cf->cycle->conf_param; 69 param = &cf->cycle->conf_param;
80 b.last = param->data + param->len; 81 b.last = param->data + param->len;
81 b.end = b.last; 82 b.end = b.last;
82 b.temporary = 1; 83 b.temporary = 1;
83 84
84 conf_file.file.fd = NGX_INVALID_FILE; 85 conf_file.file.fd = NGX_INVALID_FILE;
85 conf_file.file.name.data = (u_char *) "command line"; 86 conf_file.file.name.data = NULL;
86 conf_file.line = 1; 87 conf_file.line = 0;
87 88
88 cf->conf_file = &conf_file; 89 cf->conf_file = &conf_file;
89 cf->conf_file->buffer = &b; 90 cf->conf_file->buffer = &b;
90 91
91 return ngx_conf_parse(cf, NULL); 92 rv = ngx_conf_parse(cf, NULL);
93
94 cf->conf_file = NULL;
95
96 return rv;
92 } 97 }
93 98
94 99
95 char * 100 char *
96 ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename) 101 ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
851 #if (NGX_SUPPRESS_WARN) 856 #if (NGX_SUPPRESS_WARN)
852 full.len = 0; 857 full.len = 0;
853 full.data = NULL; 858 full.data = NULL;
854 #endif 859 #endif
855 860
856 if (name && name->len) { 861 if (name->len) {
857 full = *name; 862 full = *name;
858 863
859 if (ngx_conf_full_name(cycle, &full, 0) != NGX_OK) { 864 if (ngx_conf_full_name(cycle, &full, 0) != NGX_OK) {
860 return NULL; 865 return NULL;
861 } 866 }
887 file = ngx_list_push(&cycle->open_files); 892 file = ngx_list_push(&cycle->open_files);
888 if (file == NULL) { 893 if (file == NULL) {
889 return NULL; 894 return NULL;
890 } 895 }
891 896
892 if (name && name->len) { 897 if (name->len) {
893 file->fd = NGX_INVALID_FILE; 898 file->fd = NGX_INVALID_FILE;
894 file->name = full; 899 file->name = full;
895 900
896 } else { 901 } else {
897 file->fd = ngx_stderr; 902 file->fd = ngx_stderr;
898 file->name.len = 0; 903 file->name = *name;
899 file->name.data = NULL;
900 } 904 }
901 905
902 file->buffer = NULL; 906 file->buffer = NULL;
903 907
904 return file; 908 return file;
959 va_list args; 963 va_list args;
960 964
961 last = errstr + NGX_MAX_CONF_ERRSTR; 965 last = errstr + NGX_MAX_CONF_ERRSTR;
962 966
963 va_start(args, fmt); 967 va_start(args, fmt);
964 p = ngx_vsnprintf(errstr, last - errstr, fmt, args); 968 p = ngx_vslprintf(errstr, last, fmt, args);
965 va_end(args); 969 va_end(args);
966 970
967 if (err) { 971 if (err) {
968 972 p = ngx_log_errno(p, last, err);
969 if (p > last - 50) {
970
971 /* leave a space for an error code */
972
973 p = last - 50;
974 *p++ = '.';
975 *p++ = '.';
976 *p++ = '.';
977 }
978
979 #if (NGX_WIN32)
980 p = ngx_snprintf(p, last - p, ((unsigned) err < 0x80000000)
981 ? " (%d: " : " (%Xd: ", err);
982 #else
983 p = ngx_snprintf(p, last - p, " (%d: ", err);
984 #endif
985
986 p = ngx_strerror_r(err, p, last - p);
987
988 *p++ = ')';
989 } 973 }
990 974
991 if (cf->conf_file == NULL) { 975 if (cf->conf_file == NULL) {
992 ngx_log_error(level, cf->log, 0, "%*s", p - errstr, errstr); 976 ngx_log_error(level, cf->log, 0, "%*s", p - errstr, errstr);
977 return;
978 }
979
980 if (cf->conf_file->file.fd == NGX_INVALID_FILE) {
981 ngx_log_error(level, cf->log, 0, "%*s in command line",
982 p - errstr, errstr);
993 return; 983 return;
994 } 984 }
995 985
996 ngx_log_error(level, cf->log, 0, "%*s in %s:%ui", 986 ngx_log_error(level, cf->log, 0, "%*s in %s:%ui",
997 p - errstr, errstr, 987 p - errstr, errstr,