summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES16
-rw-r--r--CHANGES.ru16
-rw-r--r--auto/os/features4
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_buf.h3
-rw-r--r--src/core/ngx_open_file_cache.c6
-rw-r--r--src/core/ngx_open_file_cache.h1
-rw-r--r--src/core/ngx_output_chain.c41
-rw-r--r--src/http/modules/ngx_http_log_module.c1
-rw-r--r--src/http/modules/perl/nginx.pm2
-rw-r--r--src/http/ngx_http_request.c3
-rw-r--r--src/http/ngx_http_upstream.c12
-rw-r--r--src/http/ngx_http_variables.c26
-rw-r--r--src/os/unix/ngx_files.c17
-rw-r--r--src/os/unix/ngx_files.h19
15 files changed, 153 insertions, 16 deletions
diff --git a/CHANGES b/CHANGES
index 6f54854d4..c910c170d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,20 @@
+Changes with nginx 0.7.17 15 Sep 2008
+
+ *) Feature: now the "directio" directive works on Linux.
+
+ *) Feature: the $pid variable.
+
+ *) Bugfix: the "directio" optimization that had appeared in 0.7.15 did
+ not work with open_file_cache.
+
+ *) Bugfix: the "access_log" with variables did not work on Linux; the
+ bug had appeared in 0.7.7.
+
+ *) Bugfix: the ngx_http_charset_module did not understand quoted
+ charset name received from backend.
+
+
Changes with nginx 0.7.16 08 Sep 2008
*) Bugfix: nginx could not be built on 64-bit platforms; the bug had
diff --git a/CHANGES.ru b/CHANGES.ru
index 3863f4afc..34a90c257 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,20 @@
+Изменения в nginx 0.7.17 15.09.2008
+
+ *) Добавление: директива directio теперь работает на Linux.
+
+ *) Добавление: переменная $pid.
+
+ *) Исправление: оптимизация directio, появившаяся в 0.7.15, не работала
+ при использовании open_file_cache.
+
+ *) Исправление: access_log с переменными не работал на Linux; ошибка
+ появилась в 0.7.7.
+
+ *) Исправление: модуль ngx_http_charset_module не понимал название
+ кодировки в кавычках, полученное от бэкенда.
+
+
Изменения в nginx 0.7.16 08.09.2008
*) Исправление: nginx не собирался на 64-битных платформах; ошибка
diff --git a/auto/os/features b/auto/os/features
index 8efed75a2..5fcbf7f6b 100644
--- a/auto/os/features
+++ b/auto/os/features
@@ -182,6 +182,10 @@ ngx_feature_test="fcntl(0, F_SETFL, O_DIRECT);"
. auto/feature
+if [ $ngx_found = yes -a "$NGX_SYSTEM" = "Linux" ]; then
+ have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
+fi
+
ngx_feature="F_NOCACHE"
ngx_feature_name="NGX_HAVE_F_NOCACHE"
ngx_feature_run=no
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 1111e6ccc..e86bae6ca 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VERSION "0.7.16"
+#define NGINX_VERSION "0.7.17"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index d16656d6b..ce26c630e 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -79,6 +79,9 @@ typedef struct {
unsigned sendfile;
unsigned directio;
+#if (NGX_HAVE_ALIGNED_DIRECTIO)
+ unsigned unaligned;
+#endif
unsigned need_in_memory;
unsigned need_in_temp;
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
index 614484d93..f9c6a459a 100644
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -205,6 +205,7 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
of->is_file = file->is_file;
of->is_link = file->is_link;
of->is_exec = file->is_exec;
+ of->is_directio = file->is_directio;
if (!file->is_dir) {
file->count++;
@@ -360,6 +361,7 @@ update:
file->is_file = of->is_file;
file->is_link = of->is_link;
file->is_exec = of->is_exec;
+ file->is_directio = of->is_directio;
if (!of->is_dir) {
file->count++;
@@ -499,9 +501,9 @@ ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log)
of->fd = fd;
if (of->directio <= ngx_file_size(&fi)) {
- if (ngx_directio(fd) == -1) {
+ if (ngx_directio_on(fd) == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
- ngx_directio_n " \"%s\" failed", name);
+ ngx_directio_on_n " \"%s\" failed", name);
} else {
of->is_directio = 1;
diff --git a/src/core/ngx_open_file_cache.h b/src/core/ngx_open_file_cache.h
index b15de1d13..af39094a3 100644
--- a/src/core/ngx_open_file_cache.h
+++ b/src/core/ngx_open_file_cache.h
@@ -63,6 +63,7 @@ struct ngx_cached_open_file_s {
unsigned is_file:1;
unsigned is_link:1;
unsigned is_exec:1;
+ unsigned is_directio:1;
ngx_event_t *event;
};
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 3d5ae1db5..391852ffe 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -355,6 +355,10 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
* to reuse the buf via ctx->free list
*/
+#if (NGX_HAVE_ALIGNED_DIRECTIO)
+ ctx->unaligned = 1;
+#endif
+
return NGX_OK;
}
@@ -491,8 +495,41 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
}
} else {
+
+#if (NGX_HAVE_ALIGNED_DIRECTIO)
+
+ if (ctx->unaligned) {
+ if (ngx_directio_off(src->file->fd) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno,
+ ngx_directio_off_n " \"%s\" failed",
+ src->file->name.data);
+ }
+ }
+
+#endif
+
n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos);
+#if (NGX_HAVE_ALIGNED_DIRECTIO)
+
+ if (ctx->unaligned) {
+ ngx_err_t err;
+
+ err = ngx_errno;
+
+ if (ngx_directio_on(src->file->fd) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno,
+ ngx_directio_on_n " \"%s\" failed",
+ src->file->name.data);
+ }
+
+ ngx_set_errno(err);
+
+ ctx->unaligned = 0;
+ }
+
+#endif
+
if (n == NGX_ERROR) {
return (ngx_int_t) n;
}
@@ -505,8 +542,8 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
if (n != size) {
ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0,
- ngx_read_file_n " read only %z of %O from file",
- n, size);
+ ngx_read_file_n " read only %z of %O from \"%s\"",
+ n, size, src->file->name.data);
if (n == 0) {
return NGX_ERROR;
}
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index 4448363c5..775279c88 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -430,6 +430,7 @@ ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
of.log = 1;
of.valid = llcf->open_file_cache_valid;
of.min_uses = llcf->open_file_cache_min_uses;
+ of.directio = NGX_MAX_OFF_T_VALUE;
if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
!= NGX_OK)
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index d7c0bdfe5..c837bd8b2 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -47,7 +47,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '0.7.16';
+our $VERSION = '0.7.17';
require XSLoader;
XSLoader::load('nginx', $VERSION);
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index e163fd8ef..ae3bb03d5 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1751,6 +1751,9 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
}
}
+ c->read->handler = ngx_http_request_handler;
+ c->write->handler = ngx_http_request_handler;
+
ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
return;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index ae86b9858..6bbf872c1 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2632,7 +2632,17 @@ ngx_http_upstream_copy_content_type(ngx_http_request_t *r, ngx_table_elt_t *h,
r->headers_out.content_type_len = last - h->value.data;
- r->headers_out.charset.len = h->value.data + h->value.len - p;
+ if (*p == '"') {
+ p++;
+ }
+
+ last = h->value.data + h->value.len;
+
+ if (*(last - 1) == '"') {
+ last--;
+ }
+
+ r->headers_out.charset.len = last - p;
r->headers_out.charset.data = p;
return NGX_OK;
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index f61482f4c..08343b8e8 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -78,6 +78,8 @@ static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
/*
* TODO:
@@ -227,6 +229,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
{ ngx_string("hostname"), NULL, ngx_http_variable_hostname,
0, 0, 0 },
+ { ngx_string("pid"), NULL, ngx_http_variable_pid,
+ 0, 0, 0 },
+
{ ngx_null_string, NULL, NULL, 0, 0, 0 }
};
@@ -1353,6 +1358,27 @@ ngx_http_variable_hostname(ngx_http_request_t *r,
}
+static ngx_int_t
+ngx_http_variable_pid(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+
+ p = ngx_pnalloc(r->pool, NGX_INT64_LEN);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ v->len = ngx_sprintf(p, "%P", ngx_pid) - p;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
ngx_int_t
ngx_http_variables_add_core_vars(ngx_conf_t *cf)
{
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index ab861467e..661ecaa4e 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -389,7 +389,7 @@ ngx_unlock_fd(ngx_fd_t fd)
#if (NGX_HAVE_O_DIRECT)
ngx_int_t
-ngx_directio(ngx_fd_t fd)
+ngx_directio_on(ngx_fd_t fd)
{
int flags;
@@ -402,4 +402,19 @@ ngx_directio(ngx_fd_t fd)
return fcntl(fd, F_SETFL, flags | O_DIRECT);
}
+
+ngx_int_t
+ngx_directio_off(ngx_fd_t fd)
+{
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+
+ if (flags == -1) {
+ return -1;
+ }
+
+ return fcntl(fd, F_SETFL, flags & ~O_DIRECT);
+}
+
#endif
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 9988bcc30..d7a38d95a 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -222,23 +222,26 @@ ngx_err_t ngx_unlock_fd(ngx_fd_t fd);
#if (NGX_HAVE_O_DIRECT)
-ngx_int_t ngx_directio(ngx_fd_t fd);
-#define ngx_directio_n "fcntl(O_DIRECT)"
+ngx_int_t ngx_directio_on(ngx_fd_t fd);
+#define ngx_directio_on_n "fcntl(O_DIRECT)"
+
+ngx_int_t ngx_directio_off(ngx_fd_t fd);
+#define ngx_directio_off_n "fcntl(!O_DIRECT)"
#elif (NGX_HAVE_F_NOCACHE)
-#define ngx_directio(fd) fcntl(fd, F_NOCACHE, 1)
-#define ngx_directio_n "fcntl(F_NOCACHE)"
+#define ngx_directio_on(fd) fcntl(fd, F_NOCACHE, 1)
+#define ngx_directio_on_n "fcntl(F_NOCACHE, 1)"
#elif (NGX_HAVE_DIRECTIO)
-#define ngx_directio(fd) directio(fd, DIRECTIO_ON)
-#define ngx_directio_n "directio(DIRECTIO_ON)"
+#define ngx_directio_on(fd) directio(fd, DIRECTIO_ON)
+#define ngx_directio_on_n "directio(DIRECTIO_ON)"
#else
-#define ngx_directio(fd) 0
-#define ngx_directio_n "ngx_directio_n"
+#define ngx_directio_on(fd) 0
+#define ngx_directio_on_n "ngx_directio_on_n"
#endif