diff options
| author | NGINX team <nginx@nginx.org> | 2012-02-29 14:54:20 +0000 |
|---|---|---|
| committer | Jon Kolb <jon@b0g.us> | 2012-02-29 14:54:20 +0000 |
| commit | 55ebd600fb4c3d0842a9d7ed29c7b8d3e56f848d (patch) | |
| tree | 04f2471b3a7967b1c5809f6e024da8335f52c024 /src/core | |
| parent | 616d163c4ad4900518e06187809dab9d0dd6e2c9 (diff) | |
| download | nginx-55ebd600fb4c3d0842a9d7ed29c7b8d3e56f848d.tar.gz | |
Changes with nginx 1.1.16 29 Feb 2012v1.1.16
*) Change: the simultaneous subrequest limit has been raised to 200.
*) Feature: the "from" parameter of the "disable_symlinks" directive.
*) Feature: the "return" and "error_page" directives can be used to
return 307 redirections.
*) Bugfix: a segmentation fault might occur in a worker process if the
"resolver" directive was used and there was no "error_log" directive
specified at global level.
Thanks to Roman Arutyunyan.
*) Bugfix: a segmentation fault might occur in a worker process if the
"proxy_http_version 1.1" or "fastcgi_keep_conn on" directives were
used.
*) Bugfix: memory leaks.
Thanks to Lanshun Zhou.
*) Bugfix: in the "disable_symlinks" directive.
*) Bugfix: on ZFS filesystem disk cache size might be calculated
incorrectly; the bug had appeared in 1.0.1.
*) Bugfix: nginx could not be built by the icc 12.1 compiler.
*) Bugfix: nginx could not be built by gcc on Solaris; the bug had
appeared in 1.1.15.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.h | 4 | ||||
| -rw-r--r-- | src/core/ngx_open_file_cache.c | 116 | ||||
| -rw-r--r-- | src/core/ngx_open_file_cache.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_resolver.c | 28 | ||||
| -rw-r--r-- | src/core/ngx_times.c | 2 |
5 files changed, 78 insertions, 74 deletions
diff --git a/src/core/nginx.h b/src/core/nginx.h index a22b37732..fab6ce688 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1001015 -#define NGINX_VERSION "1.1.15" +#define nginx_version 1001016 +#define NGINX_VERSION "1.1.16" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index c871f74b1..c44ac96b8 100644 --- a/src/core/ngx_open_file_cache.c +++ b/src/core/ngx_open_file_cache.c @@ -229,6 +229,7 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, && now - file->created < of->valid #if (NGX_HAVE_OPENAT) && of->disable_symlinks == file->disable_symlinks + && of->disable_symlinks_from == file->disable_symlinks_from #endif )) { @@ -395,6 +396,7 @@ update: file->err = of->err; #if (NGX_HAVE_OPENAT) file->disable_symlinks = of->disable_symlinks; + file->disable_symlinks_from = of->disable_symlinks_from; #endif if (of->err == 0) { @@ -504,8 +506,8 @@ ngx_openat_file_owner(ngx_fd_t at_fd, const u_char *name, fd = ngx_openat_file(at_fd, name, mode, create, access); - if (fd == NGX_FILE_ERROR) { - return NGX_FILE_ERROR; + if (fd == NGX_INVALID_FILE) { + return NGX_INVALID_FILE; } if (ngx_file_at_info(at_fd, name, &atfi, AT_SYMLINK_NOFOLLOW) @@ -565,7 +567,6 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, u_char *p, *cp, *end; ngx_fd_t at_fd; ngx_str_t at_name; - ngx_file_info_t fi; if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_OFF) { fd = ngx_open_file(name->data, mode, create, access); @@ -582,22 +583,45 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, p = name->data; end = p + name->len; - at_fd = AT_FDCWD; at_name = *name; - if (p[0] == '/') { - at_fd = ngx_openat_file(at_fd, "/", - NGX_FILE_RDONLY|NGX_FILE_NONBLOCK, - NGX_FILE_OPEN, 0); + if (of->disable_symlinks_from) { + + cp = p + of->disable_symlinks_from; + + *cp = '\0'; - if (at_fd == NGX_FILE_ERROR) { + at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, + NGX_FILE_OPEN, 0); + + *cp = '/'; + + if (at_fd == NGX_INVALID_FILE) { + of->err = ngx_errno; + of->failed = ngx_open_file_n; + return NGX_INVALID_FILE; + } + + at_name.len = of->disable_symlinks_from; + p = cp + 1; + + } else if (*p == '/') { + + at_fd = ngx_open_file("/", + NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, + NGX_FILE_OPEN, 0); + + if (at_fd == NGX_INVALID_FILE) { of->err = ngx_errno; of->failed = ngx_openat_file_n; - return NGX_FILE_ERROR; + return NGX_INVALID_FILE; } at_name.len = 1; p++; + + } else { + at_fd = NGX_AT_FDCWD; } for ( ;; ) { @@ -615,12 +639,12 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER) { fd = ngx_openat_file_owner(at_fd, p, - NGX_FILE_RDONLY|NGX_FILE_NONBLOCK, + NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, NGX_FILE_OPEN, 0, log); } else { fd = ngx_openat_file(at_fd, p, - NGX_FILE_RDONLY|NGX_FILE_NONBLOCK|NGX_FILE_NOFOLLOW, + NGX_FILE_SEARCH|NGX_FILE_NONBLOCK|NGX_FILE_NOFOLLOW, NGX_FILE_OPEN, 0); } @@ -632,9 +656,9 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, goto failed; } - if (at_fd != AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) { + if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, - ngx_close_file_n " \"%V\" failed", at_name); + ngx_close_file_n " \"%V\" failed", &at_name); } p = cp + 1; @@ -642,47 +666,34 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, at_name.len = cp - at_name.data; } - if (p == end && at_fd != AT_FDCWD) { + if (p == end) { /* - * If pathname ends with a trailing slash, check if last path - * component is a directory; if not, fail with ENOTDIR as per - * POSIX. - * - * We use separate check instead of O_DIRECTORY in the loop above, - * as O_DIRECTORY doesn't work on FreeBSD 8. + * If pathname ends with a trailing slash, assume the last path + * component is a directory and reopen it with requested flags; + * if not, fail with ENOTDIR as per POSIX. * - * Note this returns already opened file descriptor, with different - * mode/create/access. This is believed to be safe as we don't - * use this codepath to create directories. + * We cannot rely on O_DIRECTORY in the loop above to check + * that the last path component is a directory because + * O_DIRECTORY doesn't work on FreeBSD 8. Fortunately, by + * reopening a directory, we don't depend on it at all. */ - if (ngx_fd_info(at_fd, &fi) == NGX_FILE_ERROR) { - of->err = ngx_errno; - of->failed = ngx_fd_info_n; - fd = NGX_INVALID_FILE; - - goto failed; - } - - if (ngx_is_dir(&fi)) { - return at_fd; - } - - of->err = ENOTDIR; - of->failed = ngx_openat_file_n; - fd = NGX_INVALID_FILE; - - goto failed; + fd = ngx_openat_file(at_fd, ".", mode, create, access); + goto done; } - if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER) { + if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER + && !(create & (NGX_FILE_CREATE_OR_OPEN|NGX_FILE_TRUNCATE))) + { fd = ngx_openat_file_owner(at_fd, p, mode, create, access, log); } else { fd = ngx_openat_file(at_fd, p, mode|NGX_FILE_NOFOLLOW, create, access); } +done: + if (fd == NGX_INVALID_FILE) { of->err = ngx_errno; of->failed = ngx_openat_file_n; @@ -690,9 +701,9 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, failed: - if (at_fd != AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) { + if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, - ngx_close_file_n " \"%V\" failed", at_name); + ngx_close_file_n " \"%V\" failed", &at_name); } return fd; @@ -1131,20 +1142,15 @@ ngx_open_file_lookup(ngx_open_file_cache_t *cache, ngx_str_t *name, /* hash == node->key */ - do { - file = (ngx_cached_open_file_t *) node; - - rc = ngx_strcmp(name->data, file->name); + file = (ngx_cached_open_file_t *) node; - if (rc == 0) { - return file; - } + rc = ngx_strcmp(name->data, file->name); - node = (rc < 0) ? node->left : node->right; - - } while (node != sentinel && hash == node->key); + if (rc == 0) { + return file; + } - break; + node = (rc < 0) ? node->left : node->right; } return NULL; diff --git a/src/core/ngx_open_file_cache.h b/src/core/ngx_open_file_cache.h index 0ff345318..d119c1296 100644 --- a/src/core/ngx_open_file_cache.h +++ b/src/core/ngx_open_file_cache.h @@ -33,6 +33,7 @@ typedef struct { ngx_uint_t min_uses; #if (NGX_HAVE_OPENAT) + size_t disable_symlinks_from; unsigned disable_symlinks:2; #endif @@ -69,6 +70,7 @@ struct ngx_cached_open_file_s { uint32_t uses; #if (NGX_HAVE_OPENAT) + size_t disable_symlinks_from; unsigned disable_symlinks:2; #endif diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index 5a0ade729..2e3047135 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -189,11 +189,6 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n) uc->sockaddr = u.addrs->sockaddr; uc->socklen = u.addrs->socklen; uc->server = u.addrs->name; - - uc->log = cf->cycle->new_log; - uc->log.handler = ngx_resolver_log_error; - uc->log.data = uc; - uc->log.action = "resolving"; } return r; @@ -876,6 +871,12 @@ ngx_resolver_send_query(ngx_resolver_t *r, ngx_resolver_node_t *rn) } if (uc->connection == NULL) { + + uc->log = *r->log; + uc->log.handler = ngx_resolver_log_error; + uc->log.data = uc; + uc->log.action = "resolving"; + if (ngx_udp_connect(uc) != NGX_OK) { return NGX_ERROR; } @@ -1688,20 +1689,15 @@ ngx_resolver_lookup_name(ngx_resolver_t *r, ngx_str_t *name, uint32_t hash) /* hash == node->key */ - do { - rn = (ngx_resolver_node_t *) node; - - rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen); + rn = (ngx_resolver_node_t *) node; - if (rc == 0) { - return rn; - } + rc = ngx_memn2cmp(name->data, rn->name, name->len, rn->nlen); - node = (rc < 0) ? node->left : node->right; - - } while (node != sentinel && hash == node->key); + if (rc == 0) { + return rn; + } - break; + node = (rc < 0) ? node->left : node->right; } /* not found */ diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 745a4bd1b..6a5808fe2 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -287,7 +287,7 @@ ngx_gmtime(time_t t, ngx_tm_t *tp) days = n / 86400; - /* Jaunary 1, 1970 was Thursday */ + /* January 1, 1970 was Thursday */ wday = (4 + days) % 7; |
