diff src/core/ngx_conf_file.c @ 384:09b703ae3ba5 NGINX_0_6_36

nginx 0.6.36 *) Change: now the "Invalid argument" error returned by setsockopt(TCP_NODELAY) on Solaris, is ignored. *) Change: now POSTs without "Content-Length" header line are allowed. *) Feature: the "try_files" directive. *) Feature: the --with-pcre option in the configure. *) Feature: the "if_modified_since" directive. *) Feature: the "$cookie_..." variables. *) Feature: the "$arg_..." variables. *) Bugfix: compatibility with Tru64 UNIX. Thanks to Dustin Marquess. *) Bugfix: a "ssl_engine" directive did not use a SSL-accelerator for asymmetric ciphers. Thanks to Marcin Gozdalik. *) Bugfix: in a redirect rewrite directive original arguments were concatenated with new arguments by a "?" rather than an "&"; the bug had appeared in 0.1.18. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on AIX. *) Bugfix: a double response might be returned if the epoll or rtsig methods are used and a redirect was returned to a request with body. Thanks to Eden Li. *) Bugfix: a segmentation fault might occur in worker process if "resolver" directive was used in SMTP proxy. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: nginx did not process a FastCGI server response, if the server send too many messages to stderr before response.
author Igor Sysoev <http://sysoev.ru>
date Thu, 02 Apr 2009 00:00:00 +0400
parents fc497c1dfb7c
children
line wrap: on
line diff
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -201,14 +201,14 @@ done:
     if (filename) {
         ngx_free(cf->conf_file->buffer->start);
 
-        cf->conf_file = prev;
-
         if (ngx_close_file(fd) == NGX_FILE_ERROR) {
             ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
                           ngx_close_file_n " %s failed",
                           cf->conf_file->file.name.data);
             return NGX_CONF_ERROR;
         }
+
+        cf->conf_file = prev;
     }
 
     if (rc == NGX_ERROR) {
@@ -853,31 +853,47 @@ void ngx_cdecl
 ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
     char *fmt, ...)
 {
-    u_char   errstr[NGX_MAX_CONF_ERRSTR], *buf, *last;
+    u_char   errstr[NGX_MAX_CONF_ERRSTR], *p, *last;
     va_list  args;
 
     last = errstr + NGX_MAX_CONF_ERRSTR;
 
     va_start(args, fmt);
-    buf = ngx_vsnprintf(errstr, last - errstr, fmt, args);
+    p = ngx_vsnprintf(errstr, last - errstr, fmt, args);
     va_end(args);
 
-    *buf = '\0';
+    if (err) {
+
+        if (p > last - 50) {
+
+            /* leave a space for an error code */
 
-    if (err) {
-        buf = ngx_snprintf(buf, last - buf - 1, " (%d: ", err);
-        buf = ngx_strerror_r(err, buf, last - buf - 1);
-        *buf++ = ')';
-        *buf = '\0';
+            p = last - 50;
+            *p++ = '.';
+            *p++ = '.';
+            *p++ = '.';
+        }
+
+#if (NGX_WIN32)
+        p = ngx_snprintf(p, last - p, ((unsigned) err < 0x80000000)
+                                           ? " (%d: " : " (%Xd: ", err);
+#else
+        p = ngx_snprintf(p, last - p, " (%d: ", err);
+#endif
+
+        p = ngx_strerror_r(err, p, last - p);
+
+        *p++ = ')';
     }
 
     if (cf->conf_file == NULL) {
-        ngx_log_error(level, cf->log, 0, "%s", errstr);
+        ngx_log_error(level, cf->log, 0, "%*s", p - errstr, errstr);
         return;
     }
 
-    ngx_log_error(level, cf->log, 0, "%s in %s:%ui",
-                  errstr, cf->conf_file->file.name.data, cf->conf_file->line);
+    ngx_log_error(level, cf->log, 0, "%*s in %s:%ui",
+                  p - errstr, errstr,
+                  cf->conf_file->file.name.data, cf->conf_file->line);
 }