[-]
[+]
|
Changed |
nginx-1.9.changes
|
|
[-]
[+]
|
Changed |
nginx-1.9.spec
^
|
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/CHANGES
^
|
@@ -1,4 +1,30 @@
+Changes with nginx 1.9.6 27 Oct 2015
+
+ *) Bugfix: a segmentation fault might occur in a worker process when
+ using HTTP/2.
+ Thanks to Piotr Sikora and Denis Andzakovic.
+
+ *) Bugfix: the $server_protocol variable was empty when using HTTP/2.
+
+ *) Bugfix: backend SSL connections in the stream module might be timed
+ out unexpectedly.
+
+ *) Bugfix: a segmentation fault might occur in a worker process if
+ different ssl_session_cache settings were used in different virtual
+ servers.
+
+ *) Bugfix: nginx/Windows could not be built with MinGW gcc; the bug had
+ appeared in 1.9.4.
+ Thanks to Kouhei Sutou.
+
+ *) Bugfix: time was not updated when the timer_resolution directive was
+ used on Windows.
+
+ *) Miscellaneous minor fixes and improvements.
+ Thanks to Markus Linnala, Kurtis Nusbaum and Piotr Sikora.
+
+
Changes with nginx 1.9.5 22 Sep 2015
*) Feature: the ngx_http_v2_module (replaces ngx_http_spdy_module).
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/CHANGES.ru
^
|
@@ -1,4 +1,31 @@
+Изменения в nginx 1.9.6 27.10.2015
+
+ *) Исправление: при использовании HTTP/2 в рабочем процессе мог
+ произойти segmentation fault.
+ Спасибо Piotr Sikora и Denis Andzakovic.
+
+ *) Исправление: при использовании HTTP/2 переменная $server_protocol
+ была пустой.
+
+ *) Исправление: SSL-соединения к бэкендам в модуле stream могли
+ неожиданно завершаться по таймауту.
+
+ *) Исправление: при использовании различных настроек ssl_session_cache в
+ разных виртуальных серверах в рабочем процессе мог произойти
+ segmentation fault.
+
+ *) Исправление: nginx/Windows не собирался с MinGW gcc; ошибка появилась
+ в 1.9.4.
+ Спасибо Kouhei Sutou.
+
+ *) Исправление: при использовании директивы timer_resolution на Windows
+ время не обновлялось.
+
+ *) Незначительные исправления и улучшения.
+ Спасибо Markus Linnala, Kurtis Nusbaum и Piotr Sikora.
+
+
Изменения в nginx 1.9.5 22.09.2015
*) Добавление: модуль ngx_http_v2_module (заменяет модуль
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/auto/endianness
^
|
@@ -4,8 +4,13 @@
echo $ngx_n "checking for system byte ordering ...$ngx_c"
-echo >> $NGX_ERR
-echo "checking for system byte ordering" >> $NGX_ERR
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for system byte ordering
+
+END
cat << END > $NGX_AUTOTEST.c
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/auto/types/uintptr_t
^
|
@@ -4,8 +4,13 @@
echo $ngx_n "checking for uintptr_t ...$ngx_c"
-echo >> $NGX_AUTOCONF_ERR
-echo "checking for uintptr_t" >> $NGX_AUTOCONF_ERR
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for uintptr_t
+
+END
found=no
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/core/nginx.c
^
|
@@ -10,6 +10,7 @@
#include <nginx.h>
+static void ngx_show_version_info();
static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle);
static ngx_int_t ngx_get_options(int argc, char *const *argv);
static ngx_int_t ngx_process_options(ngx_cycle_t *cycle);
@@ -194,64 +195,7 @@
}
if (ngx_show_version) {
- ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED);
-
- if (ngx_show_help) {
- ngx_write_stderr(
- "Usage: nginx [-?hvVtTq] [-s signal] [-c filename] "
- "[-p prefix] [-g directives]" NGX_LINEFEED
- NGX_LINEFEED
- "Options:" NGX_LINEFEED
- " -?,-h : this help" NGX_LINEFEED
- " -v : show version and exit" NGX_LINEFEED
- " -V : show version and configure options then exit"
- NGX_LINEFEED
- " -t : test configuration and exit" NGX_LINEFEED
- " -T : test configuration, dump it and exit"
- NGX_LINEFEED
- " -q : suppress non-error messages "
- "during configuration testing" NGX_LINEFEED
- " -s signal : send signal to a master process: "
- "stop, quit, reopen, reload" NGX_LINEFEED
-#ifdef NGX_PREFIX
- " -p prefix : set prefix path (default: "
- NGX_PREFIX ")" NGX_LINEFEED
-#else
- " -p prefix : set prefix path (default: NONE)" NGX_LINEFEED
-#endif
- " -c filename : set configuration file (default: "
- NGX_CONF_PATH ")" NGX_LINEFEED
- " -g directives : set global directives out of configuration "
- "file" NGX_LINEFEED NGX_LINEFEED
- );
- }
-
- if (ngx_show_configure) {
-
-#ifdef NGX_COMPILER
- ngx_write_stderr("built by " NGX_COMPILER NGX_LINEFEED);
-#endif
-
-#if (NGX_SSL)
- if (SSLeay() == SSLEAY_VERSION_NUMBER) {
- ngx_write_stderr("built with " OPENSSL_VERSION_TEXT
- NGX_LINEFEED);
- } else {
- ngx_write_stderr("built with " OPENSSL_VERSION_TEXT
- " (running with ");
- ngx_write_stderr((char *) (uintptr_t)
- SSLeay_version(SSLEAY_VERSION));
- ngx_write_stderr(")" NGX_LINEFEED);
- }
-#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
- ngx_write_stderr("TLS SNI support enabled" NGX_LINEFEED);
-#else
- ngx_write_stderr("TLS SNI support disabled" NGX_LINEFEED);
-#endif
-#endif
-
- ngx_write_stderr("configure arguments:" NGX_CONFIGURE NGX_LINEFEED);
- }
+ ngx_show_version_info();
if (!ngx_test_config) {
return 0;
@@ -419,6 +363,69 @@
}
+static void
+ngx_show_version_info()
+{
+ ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED);
+
+ if (ngx_show_help) {
+ ngx_write_stderr(
+ "Usage: nginx [-?hvVtTq] [-s signal] [-c filename] "
+ "[-p prefix] [-g directives]" NGX_LINEFEED
+ NGX_LINEFEED
+ "Options:" NGX_LINEFEED
+ " -?,-h : this help" NGX_LINEFEED
+ " -v : show version and exit" NGX_LINEFEED
+ " -V : show version and configure options then exit"
+ NGX_LINEFEED
+ " -t : test configuration and exit" NGX_LINEFEED
+ " -T : test configuration, dump it and exit"
+ NGX_LINEFEED
+ " -q : suppress non-error messages "
+ "during configuration testing" NGX_LINEFEED
+ " -s signal : send signal to a master process: "
+ "stop, quit, reopen, reload" NGX_LINEFEED
+#ifdef NGX_PREFIX
+ " -p prefix : set prefix path (default: " NGX_PREFIX ")"
+ NGX_LINEFEED
+#else
+ " -p prefix : set prefix path (default: NONE)" NGX_LINEFEED
+#endif
+ " -c filename : set configuration file (default: " NGX_CONF_PATH
+ ")" NGX_LINEFEED
+ " -g directives : set global directives out of configuration "
+ "file" NGX_LINEFEED NGX_LINEFEED
+ );
+ }
+
+ if (ngx_show_configure) {
+
+#ifdef NGX_COMPILER
+ ngx_write_stderr("built by " NGX_COMPILER NGX_LINEFEED);
+#endif
+
+#if (NGX_SSL)
+ if (SSLeay() == SSLEAY_VERSION_NUMBER) {
+ ngx_write_stderr("built with " OPENSSL_VERSION_TEXT NGX_LINEFEED);
+ } else {
+ ngx_write_stderr("built with " OPENSSL_VERSION_TEXT
+ " (running with ");
+ ngx_write_stderr((char *) (uintptr_t)
+ SSLeay_version(SSLEAY_VERSION));
+ ngx_write_stderr(")" NGX_LINEFEED);
+ }
+#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
+ ngx_write_stderr("TLS SNI support enabled" NGX_LINEFEED);
+#else
+ ngx_write_stderr("TLS SNI support disabled" NGX_LINEFEED);
+#endif
+#endif
+
+ ngx_write_stderr("configure arguments:" NGX_CONFIGURE NGX_LINEFEED);
+ }
+}
+
+
static ngx_int_t
ngx_add_inherited_sockets(ngx_cycle_t *cycle)
{
@@ -1139,7 +1146,7 @@
return NGX_CONF_OK;
}
- value = (ngx_str_t *) cf->args->elts;
+ value = cf->args->elts;
ccf->username = (char *) value[1].data;
@@ -1345,7 +1352,7 @@
return "is duplicate";
}
- value = (ngx_str_t *) cf->args->elts;
+ value = cf->args->elts;
if (ngx_strcmp(value[1].data, "auto") == 0) {
ccf->worker_processes = ngx_ncpu;
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/core/nginx.h
^
|
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1009005
-#define NGINX_VERSION "1.9.5"
+#define nginx_version 1009006
+#define NGINX_VERSION "1.9.6"
#define NGINX_VER "nginx/" NGINX_VERSION
#ifdef NGX_BUILD
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/core/ngx_connection.c
^
|
@@ -1175,7 +1175,7 @@
/* THREAD: lock */
- if (c[i].fd != -1 && c[i].idle) {
+ if (c[i].fd != (ngx_socket_t) -1 && c[i].idle) {
c[i].close = 1;
c[i].read->handler(c[i].read);
}
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/core/ngx_rwlock.c
^
|
@@ -111,7 +111,7 @@
#else
-#if (NGX_HTTP_UPSTREAM_ZONE)
+#if (NGX_HTTP_UPSTREAM_ZONE || NGX_STREAM_UPSTREAM_ZONE)
#error ngx_atomic_cmp_set() is not defined!
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/event/ngx_event.c
^
|
@@ -670,6 +670,15 @@
}
}
+#else
+
+ if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) {
+ ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
+ "the \"timer_resolution\" directive is not supported "
+ "with the configured event method, ignored");
+ ngx_timer_resolution = 0;
+ }
+
#endif
cycle->connections =
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/event/ngx_event_openssl.c
^
|
@@ -1038,6 +1038,8 @@
sc->buffer = ((flags & NGX_SSL_BUFFER) != 0);
sc->buffer_size = ssl->buffer_size;
+ sc->session_ctx = ssl->ctx;
+
sc->connection = SSL_new(ssl->ctx);
if (sc->connection == NULL) {
@@ -1158,6 +1160,7 @@
c->recv_chain = ngx_ssl_recv_chain;
c->send_chain = ngx_ssl_send_chain;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
#ifdef SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
/* initial handshake done, disable renegotiation (CVE-2009-3555) */
@@ -1166,6 +1169,7 @@
}
#endif
+#endif
return NGX_OK;
}
@@ -2043,7 +2047,7 @@
(void) ERR_get_error();
}
- ngx_log_error(level, log, err, "%s)", errstr);
+ ngx_log_error(level, log, err, "%*s)", p - errstr, errstr);
}
@@ -2303,7 +2307,7 @@
c = ngx_ssl_get_connection(ssl_conn);
- ssl_ctx = SSL_get_SSL_CTX(ssl_conn);
+ ssl_ctx = c->ssl->session_ctx;
shm_zone = SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_session_cache_index);
cache = shm_zone->data;
@@ -2441,21 +2445,17 @@
ngx_ssl_sess_id_t *sess_id;
ngx_ssl_session_cache_t *cache;
u_char buf[NGX_SSL_MAX_SESSION_SIZE];
-#if (NGX_DEBUG)
ngx_connection_t *c;
-#endif
hash = ngx_crc32_short(id, (size_t) len);
*copy = 0;
-#if (NGX_DEBUG)
c = ngx_ssl_get_connection(ssl_conn);
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"ssl get session: %08XD:%d", hash, len);
-#endif
- shm_zone = SSL_CTX_get_ex_data(SSL_get_SSL_CTX(ssl_conn),
+ shm_zone = SSL_CTX_get_ex_data(c->ssl->session_ctx,
ngx_ssl_session_cache_index);
cache = shm_zone->data;
@@ -2834,13 +2834,14 @@
SSL_CTX *ssl_ctx;
ngx_uint_t i;
ngx_array_t *keys;
+ ngx_connection_t *c;
ngx_ssl_session_ticket_key_t *key;
#if (NGX_DEBUG)
u_char buf[32];
- ngx_connection_t *c;
#endif
- ssl_ctx = SSL_get_SSL_CTX(ssl_conn);
+ c = ngx_ssl_get_connection(ssl_conn);
+ ssl_ctx = c->ssl->session_ctx;
keys = SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_session_ticket_keys_index);
if (keys == NULL) {
@@ -2849,10 +2850,6 @@
key = keys->elts;
-#if (NGX_DEBUG)
- c = ngx_ssl_get_connection(ssl_conn);
-#endif
-
if (enc == 1) {
/* encrypt session ticket */
@@ -2861,7 +2858,7 @@
ngx_hex_dump(buf, key[0].name, 16) - buf, buf,
SSL_session_reused(ssl_conn) ? "reused" : "new");
- RAND_pseudo_bytes(iv, 16);
+ RAND_bytes(iv, 16);
EVP_EncryptInit_ex(ectx, EVP_aes_128_cbc(), NULL, key[0].aes_key, iv);
HMAC_Init_ex(hctx, key[0].hmac_key, 16,
ngx_ssl_session_ticket_md(), NULL);
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/event/ngx_event_openssl.h
^
|
@@ -46,6 +46,7 @@
typedef struct {
ngx_ssl_conn_t *connection;
+ SSL_CTX *session_ctx;
ngx_int_t last;
ngx_buf_t *buf;
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/http/ngx_http_core_module.c
^
|
@@ -4489,7 +4489,9 @@
clcf->alias = alias ? clcf->name.len : 0;
clcf->root = value[1];
- if (!alias && clcf->root.data[clcf->root.len - 1] == '/') {
+ if (!alias && clcf->root.len > 0
+ && clcf->root.data[clcf->root.len - 1] == '/')
+ {
clcf->root.len--;
}
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/http/ngx_http_variables.c
^
|
@@ -575,7 +575,7 @@
return NULL;
}
- if (ngx_strncmp(name->data, "http_", 5) == 0) {
+ if (name->len >= 5 && ngx_strncmp(name->data, "http_", 5) == 0) {
if (ngx_http_variable_unknown_header_in(r, vv, (uintptr_t) name)
== NGX_OK)
@@ -586,7 +586,7 @@
return NULL;
}
- if (ngx_strncmp(name->data, "sent_http_", 10) == 0) {
+ if (name->len >= 10 && ngx_strncmp(name->data, "sent_http_", 10) == 0) {
if (ngx_http_variable_unknown_header_out(r, vv, (uintptr_t) name)
== NGX_OK)
@@ -597,7 +597,7 @@
return NULL;
}
- if (ngx_strncmp(name->data, "upstream_http_", 14) == 0) {
+ if (name->len >= 14 && ngx_strncmp(name->data, "upstream_http_", 14) == 0) {
if (ngx_http_upstream_header_variable(r, vv, (uintptr_t) name)
== NGX_OK)
@@ -608,7 +608,7 @@
return NULL;
}
- if (ngx_strncmp(name->data, "cookie_", 7) == 0) {
+ if (name->len >= 7 && ngx_strncmp(name->data, "cookie_", 7) == 0) {
if (ngx_http_variable_cookie(r, vv, (uintptr_t) name) == NGX_OK) {
return vv;
@@ -617,7 +617,9 @@
return NULL;
}
- if (ngx_strncmp(name->data, "upstream_cookie_", 16) == 0) {
+ if (name->len >= 16
+ && ngx_strncmp(name->data, "upstream_cookie_", 16) == 0)
+ {
if (ngx_http_upstream_cookie_variable(r, vv, (uintptr_t) name)
== NGX_OK)
@@ -628,7 +630,7 @@
return NULL;
}
- if (ngx_strncmp(name->data, "arg_", 4) == 0) {
+ if (name->len >= 4 && ngx_strncmp(name->data, "arg_", 4) == 0) {
if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) {
return vv;
@@ -2535,21 +2537,27 @@
}
}
- if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) {
+ if (v[i].name.len >= 5
+ && ngx_strncmp(v[i].name.data, "http_", 5) == 0)
+ {
v[i].get_handler = ngx_http_variable_unknown_header_in;
v[i].data = (uintptr_t) &v[i].name;
continue;
}
- if (ngx_strncmp(v[i].name.data, "sent_http_", 10) == 0) {
+ if (v[i].name.len >= 10
+ && ngx_strncmp(v[i].name.data, "sent_http_", 10) == 0)
+ {
v[i].get_handler = ngx_http_variable_unknown_header_out;
v[i].data = (uintptr_t) &v[i].name;
continue;
}
- if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) {
+ if (v[i].name.len >= 14
+ && ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0)
+ {
v[i].get_handler = ngx_http_upstream_header_variable;
v[i].data = (uintptr_t) &v[i].name;
v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
@@ -2557,14 +2565,18 @@
continue;
}
- if (ngx_strncmp(v[i].name.data, "cookie_", 7) == 0) {
+ if (v[i].name.len >= 7
+ && ngx_strncmp(v[i].name.data, "cookie_", 7) == 0)
+ {
v[i].get_handler = ngx_http_variable_cookie;
v[i].data = (uintptr_t) &v[i].name;
continue;
}
- if (ngx_strncmp(v[i].name.data, "upstream_cookie_", 16) == 0) {
+ if (v[i].name.len >= 16
+ && ngx_strncmp(v[i].name.data, "upstream_cookie_", 16) == 0)
+ {
v[i].get_handler = ngx_http_upstream_cookie_variable;
v[i].data = (uintptr_t) &v[i].name;
v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
@@ -2572,7 +2584,9 @@
continue;
}
- if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) {
+ if (v[i].name.len >= 4
+ && ngx_strncmp(v[i].name.data, "arg_", 4) == 0)
+ {
v[i].get_handler = ngx_http_variable_argument;
v[i].data = (uintptr_t) &v[i].name;
v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/http/v2/ngx_http_v2.c
^
|
@@ -870,6 +870,8 @@
return ngx_http_v2_state_skip_padded(h2c, pos, end);
}
+ stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG;
+
h2c->state.stream = stream;
return ngx_http_v2_state_read_data(h2c, pos, end);
@@ -897,8 +899,6 @@
}
if (stream->skip_data) {
- stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG;
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
"skipping http2 DATA frame, reason: %d",
stream->skip_data);
@@ -988,9 +988,7 @@
ngx_http_v2_state_read_data);
}
- if (h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG) {
- stream->in_closed = 1;
-
+ if (stream->in_closed) {
if (r->headers_in.content_length_n < 0) {
r->headers_in.content_length_n = rb->rest;
@@ -1133,6 +1131,22 @@
h2c->last_sid = h2c->state.sid;
+ if (depend == h2c->state.sid) {
+ ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
+ "client sent HEADERS frame for stream %ui "
+ "with incorrect dependency", h2c->state.sid);
+
+ if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid,
+ NGX_HTTP_V2_PROTOCOL_ERROR)
+ != NGX_OK)
+ {
+ return ngx_http_v2_connection_error(h2c,
+ NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+
+ return ngx_http_v2_state_skip_headers(h2c, pos, end);
+ }
+
h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
ngx_http_v2_module);
@@ -1233,7 +1247,7 @@
} else {
/* literal header field without indexing */
- prefix = ngx_http_v2_prefix(3);
+ prefix = ngx_http_v2_prefix(4);
}
value = ngx_http_v2_parse_int(h2c, &pos, end, prefix);
@@ -2361,12 +2375,6 @@
ngx_debug_point();
}
- if (h2c->state.stream) {
- h2c->state.stream->out_closed = 1;
- h2c->state.pool = NULL;
- ngx_http_v2_close_stream(h2c->state.stream, NGX_HTTP_BAD_REQUEST);
- }
-
ngx_http_v2_finalize_connection(h2c, err);
return NULL;
@@ -2396,8 +2404,8 @@
return value;
}
- if (end - p > NGX_HTTP_V2_INT_OCTETS - 1) {
- end = p + NGX_HTTP_V2_INT_OCTETS - 1;
+ if (end - start > NGX_HTTP_V2_INT_OCTETS) {
+ end = start + NGX_HTTP_V2_INT_OCTETS;
}
for (shift = 0; p != end; shift += 7) {
@@ -2417,14 +2425,14 @@
}
}
- if ((size_t) (end - start) >= NGX_HTTP_V2_INT_OCTETS) {
- return NGX_DECLINED;
- }
-
if ((size_t) (end - start) >= h2c->state.length) {
return NGX_ERROR;
}
+ if (end == start + NGX_HTTP_V2_INT_OCTETS) {
+ return NGX_DECLINED;
+ }
+
return NGX_AGAIN;
}
@@ -2762,6 +2770,8 @@
return NULL;
}
+ ngx_str_set(&r->http_protocol, "HTTP/2.0");
+
r->http_version = NGX_HTTP_VERSION_20;
r->valid_location = 1;
@@ -2896,11 +2906,14 @@
weight += child->weight;
}
+ parent = node->parent;
+
for (q = ngx_queue_head(&node->children);
q != ngx_queue_sentinel(&node->children);
q = ngx_queue_next(q))
{
child = ngx_queue_data(q, ngx_http_v2_node_t, queue);
+ child->parent = parent;
child->weight = node->weight * child->weight / weight;
if (child->weight == 0) {
@@ -2908,8 +2921,6 @@
}
}
- parent = node->parent;
-
if (parent == NGX_HTTP_V2_ROOT) {
node->rank = 0;
node->rel_weight = 1.0;
@@ -3795,6 +3806,12 @@
c = h2c->connection;
+ if (h2c->state.stream) {
+ h2c->state.stream->out_closed = 1;
+ h2c->state.pool = NULL;
+ ngx_http_v2_close_stream(h2c->state.stream, NGX_HTTP_BAD_REQUEST);
+ }
+
h2c->blocked = 1;
if (!c->error && ngx_http_v2_send_goaway(h2c, status) != NGX_ERROR) {
@@ -3922,8 +3939,8 @@
ngx_http_v2_set_dependency(ngx_http_v2_connection_t *h2c,
ngx_http_v2_node_t *node, ngx_uint_t depend, ngx_uint_t exclusive)
{
- ngx_queue_t *children;
- ngx_http_v2_node_t *parent, *next;
+ ngx_queue_t *children, *q;
+ ngx_http_v2_node_t *parent, *child, *next;
parent = depend ? ngx_http_v2_get_node_by_id(h2c, depend, 0) : NULL;
@@ -3985,6 +4002,14 @@
}
if (exclusive) {
+ for (q = ngx_queue_head(children);
+ q != ngx_queue_sentinel(children);
+ q = ngx_queue_next(q))
+ {
+ child = ngx_queue_data(q, ngx_http_v2_node_t, queue);
+ child->parent = node;
+ }
+
ngx_queue_add(&node->children, children);
ngx_queue_init(children);
}
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/http/v2/ngx_http_v2.h
^
|
@@ -21,7 +21,8 @@
#define NGX_HTTP_V2_MAX_FRAME_SIZE ((1 << 24) - 1)
#define NGX_HTTP_V2_INT_OCTETS 4
-#define NGX_HTTP_V2_MAX_FIELD ((1 << NGX_HTTP_V2_INT_OCTETS * 7) - 1)
+#define NGX_HTTP_V2_MAX_FIELD \
+ (127 + (1 << (NGX_HTTP_V2_INT_OCTETS - 1) * 7) - 1)
#define NGX_HTTP_V2_DATA_DISCARD 1
#define NGX_HTTP_V2_DATA_ERROR 2
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/http/v2/ngx_http_v2_filter_module.c
^
|
@@ -12,7 +12,12 @@
#include <ngx_http_v2_module.h>
-#define ngx_http_v2_integer_octets(v) (((v) + 127) / 128)
+/*
+ * This returns precise number of octets for values in range 0..253
+ * and estimate number for the rest, but not smaller than required.
+ */
+
+#define ngx_http_v2_integer_octets(v) (1 + (v) / 127)
#define ngx_http_v2_literal_size(h) \
(ngx_http_v2_integer_octets(sizeof(h) - 1) + sizeof(h) - 1)
@@ -20,6 +25,8 @@
#define ngx_http_v2_indexed(i) (128 + (i))
#define ngx_http_v2_inc_indexed(i) (64 + (i))
+#define NGX_HTTP_V2_ENCODE_RAW 0
+#define NGX_HTTP_V2_ENCODE_HUFF 0x80
#define NGX_HTTP_V2_STATUS_INDEX 8
#define NGX_HTTP_V2_STATUS_200_INDEX 8
@@ -41,10 +48,8 @@
static u_char *ngx_http_v2_write_int(u_char *pos, ngx_uint_t prefix,
ngx_uint_t value);
-static void ngx_http_v2_write_headers_head(u_char *pos, size_t length,
- ngx_uint_t sid, ngx_uint_t end_headers, ngx_uint_t end_stream);
-static void ngx_http_v2_write_continuation_head(u_char *pos, size_t length,
- ngx_uint_t sid, ngx_uint_t end_headers);
+static ngx_http_v2_out_frame_t *ngx_http_v2_create_headers_frame(
+ ngx_http_request_t *r, u_char *pos, u_char *end);
static ngx_chain_t *ngx_http_v2_send_chain(ngx_connection_t *fc,
ngx_chain_t *in, off_t limit);
@@ -114,17 +119,14 @@
static ngx_int_t
ngx_http_v2_header_filter(ngx_http_request_t *r)
{
- u_char status, *p, *head;
- size_t len, rest, frame_size;
- ngx_buf_t *b;
+ u_char status, *pos, *start, *p;
+ size_t len;
ngx_str_t host, location;
- ngx_uint_t i, port, continuation;
- ngx_chain_t *cl;
+ ngx_uint_t i, port;
ngx_list_part_t *part;
ngx_table_elt_t *header;
ngx_connection_t *fc;
ngx_http_cleanup_t *cln;
- ngx_http_v2_stream_t *stream;
ngx_http_v2_out_frame_t *frame;
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;
@@ -222,7 +224,7 @@
}
if (r->headers_out.content_type.len) {
- len += NGX_HTTP_V2_INT_OCTETS + r->headers_out.content_type.len;
+ len += 1 + NGX_HTTP_V2_INT_OCTETS + r->headers_out.content_type.len;
if (r->headers_out.content_type_len == r->headers_out.content_type.len
&& r->headers_out.charset.len)
@@ -386,134 +388,117 @@
+ NGX_HTTP_V2_INT_OCTETS + header[i].value.len;
}
- stream = r->stream;
- frame_size = stream->connection->frame_size;
-
- len += NGX_HTTP_V2_FRAME_HEADER_SIZE
- * ((len + frame_size - 1) / frame_size);
-
- b = ngx_create_temp_buf(r->pool, len);
- if (b == NULL) {
+ pos = ngx_palloc(r->pool, len);
+ if (pos == NULL) {
return NGX_ERROR;
}
- b->last_buf = r->header_only;
-
- b->last += NGX_HTTP_V2_FRAME_HEADER_SIZE;
+ start = pos;
if (status) {
- *b->last++ = status;
+ *pos++ = status;
} else {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_STATUS_INDEX);
- *b->last++ = 3;
- b->last = ngx_sprintf(b->last, "%03ui", r->headers_out.status);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_STATUS_INDEX);
+ *pos++ = NGX_HTTP_V2_ENCODE_RAW | 3;
+ pos = ngx_sprintf(pos, "%03ui", r->headers_out.status);
}
if (r->headers_out.server == NULL) {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SERVER_INDEX);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SERVER_INDEX);
if (clcf->server_tokens) {
- *b->last++ = sizeof(NGINX_VER) - 1;
- b->last = ngx_cpymem(b->last, NGINX_VER, sizeof(NGINX_VER) - 1);
+ *pos++ = NGX_HTTP_V2_ENCODE_RAW | (sizeof(NGINX_VER) - 1);
+ pos = ngx_cpymem(pos, NGINX_VER, sizeof(NGINX_VER) - 1);
} else {
- *b->last++ = sizeof("nginx") - 1;
- b->last = ngx_cpymem(b->last, "nginx", sizeof("nginx") - 1);
+ *pos++ = NGX_HTTP_V2_ENCODE_RAW | (sizeof("nginx") - 1);
+ pos = ngx_cpymem(pos, "nginx", sizeof("nginx") - 1);
}
}
if (r->headers_out.date == NULL) {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_DATE_INDEX);
- *b->last++ = (u_char) ngx_cached_http_time.len;
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_DATE_INDEX);
+ *pos++ = (u_char) ngx_cached_http_time.len;
- b->last = ngx_cpymem(b->last, ngx_cached_http_time.data,
- ngx_cached_http_time.len);
+ pos = ngx_cpymem(pos, ngx_cached_http_time.data,
+ ngx_cached_http_time.len);
}
if (r->headers_out.content_type.len) {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_CONTENT_TYPE_INDEX);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_CONTENT_TYPE_INDEX);
if (r->headers_out.content_type_len == r->headers_out.content_type.len
&& r->headers_out.charset.len)
{
- *b->last = 0;
- b->last = ngx_http_v2_write_int(b->last, ngx_http_v2_prefix(7),
- r->headers_out.content_type.len
- + sizeof("; charset=") - 1
- + r->headers_out.charset.len);
-
- p = b->last;
+ *pos = NGX_HTTP_V2_ENCODE_RAW;
+ pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(7),
+ r->headers_out.content_type.len
+ + sizeof("; charset=") - 1
+ + r->headers_out.charset.len);
+
+ p = pos;
- b->last = ngx_cpymem(p, r->headers_out.content_type.data,
- r->headers_out.content_type.len);
+ pos = ngx_cpymem(pos, r->headers_out.content_type.data,
+ r->headers_out.content_type.len);
- b->last = ngx_cpymem(b->last, "; charset=",
- sizeof("; charset=") - 1);
+ pos = ngx_cpymem(pos, "; charset=", sizeof("; charset=") - 1);
- b->last = ngx_cpymem(b->last, r->headers_out.charset.data,
- r->headers_out.charset.len);
+ pos = ngx_cpymem(pos, r->headers_out.charset.data,
+ r->headers_out.charset.len);
/* update r->headers_out.content_type for possible logging */
- r->headers_out.content_type.len = b->last - p;
+ r->headers_out.content_type.len = pos - p;
r->headers_out.content_type.data = p;
} else {
- *b->last = 0;
- b->last = ngx_http_v2_write_int(b->last, ngx_http_v2_prefix(7),
- r->headers_out.content_type.len);
- b->last = ngx_cpymem(b->last, r->headers_out.content_type.data,
- r->headers_out.content_type.len);
+ *pos = NGX_HTTP_V2_ENCODE_RAW;
+ pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(7),
+ r->headers_out.content_type.len);
+ pos = ngx_cpymem(pos, r->headers_out.content_type.data,
+ r->headers_out.content_type.len);
}
}
if (r->headers_out.content_length == NULL
&& r->headers_out.content_length_n >= 0)
{
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_CONTENT_LENGTH_INDEX);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_CONTENT_LENGTH_INDEX);
- p = b->last;
- b->last = ngx_sprintf(b->last + 1, "%O",
- r->headers_out.content_length_n);
- *p = (u_char) (b->last - p - 1);
+ p = pos;
+ pos = ngx_sprintf(pos + 1, "%O", r->headers_out.content_length_n);
+ *p = NGX_HTTP_V2_ENCODE_RAW | (u_char) (pos - p - 1);
}
if (r->headers_out.last_modified == NULL
&& r->headers_out.last_modified_time != -1)
{
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_LAST_MODIFIED_INDEX);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_LAST_MODIFIED_INDEX);
- p = b->last;
- b->last = ngx_http_time(b->last + 1, r->headers_out.last_modified_time);
- *p = (u_char) (b->last - p - 1);
+ *pos++ = NGX_HTTP_V2_ENCODE_RAW
+ | (sizeof("Wed, 31 Dec 1986 18:00:00 GMT") - 1);
+ pos = ngx_http_time(pos, r->headers_out.last_modified_time);
}
if (r->headers_out.location && r->headers_out.location->value.len) {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_LOCATION_INDEX);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_LOCATION_INDEX);
- *b->last = 0;
- b->last = ngx_http_v2_write_int(b->last, ngx_http_v2_prefix(7),
- r->headers_out.location->value.len);
- b->last = ngx_cpymem(b->last, r->headers_out.location->value.data,
- r->headers_out.location->value.len);
+ *pos = NGX_HTTP_V2_ENCODE_RAW;
+ pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(7),
+ r->headers_out.location->value.len);
+ pos = ngx_cpymem(pos, r->headers_out.location->value.data,
+ r->headers_out.location->value.len);
}
#if (NGX_HTTP_GZIP)
if (r->gzip_vary) {
- *b->last++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_VARY_INDEX);
- *b->last++ = sizeof("Accept-Encoding") - 1;
- b->last = ngx_cpymem(b->last, "Accept-Encoding",
- sizeof("Accept-Encoding") - 1);
+ *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_VARY_INDEX);
+ *pos++ = NGX_HTTP_V2_ENCODE_RAW | (sizeof("Accept-Encoding") - 1);
+ pos = ngx_cpymem(pos, "Accept-Encoding", sizeof("Accept-Encoding") - 1);
}
#endif
- continuation = 0;
- head = b->pos;
-
- len = b->last - head - NGX_HTTP_V2_FRAME_HEADER_SIZE;
- rest = frame_size - len;
-
part = &r->headers_out.headers.part;
header = part->elts;
@@ -533,82 +518,26 @@
continue;
}
- len = 1 + NGX_HTTP_V2_INT_OCTETS * 2
- + header[i].key.len
- + header[i].value.len;
-
- if (len > rest) {
- len = b->last - head - NGX_HTTP_V2_FRAME_HEADER_SIZE;
-
- if (continuation) {
- ngx_http_v2_write_continuation_head(head, len,
- stream->node->id, 0);
- } else {
- continuation = 1;
- ngx_http_v2_write_headers_head(head, len, stream->node->id, 0,
- r->header_only);
- }
-
- rest = frame_size;
- head = b->last;
-
- b->last += NGX_HTTP_V2_FRAME_HEADER_SIZE;
- }
-
- p = b->last;
-
- *p++ = 0;
+ *pos++ = 0;
- *p = 0;
- p = ngx_http_v2_write_int(p, ngx_http_v2_prefix(7), header[i].key.len);
- ngx_strlow(p, header[i].key.data, header[i].key.len);
- p += header[i].key.len;
+ *pos = NGX_HTTP_V2_ENCODE_RAW;
+ pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(7),
+ header[i].key.len);
+ ngx_strlow(pos, header[i].key.data, header[i].key.len);
+ pos += header[i].key.len;
- *p = 0;
- p = ngx_http_v2_write_int(p, ngx_http_v2_prefix(7),
- header[i].value.len);
- p = ngx_cpymem(p, header[i].value.data, header[i].value.len);
-
- rest -= p - b->last;
- b->last = p;
- }
-
- len = b->last - head - NGX_HTTP_V2_FRAME_HEADER_SIZE;
-
- if (continuation) {
- ngx_http_v2_write_continuation_head(head, len, stream->node->id, 1);
-
- } else {
- ngx_http_v2_write_headers_head(head, len, stream->node->id, 1,
- r->header_only);
- }
-
- cl = ngx_alloc_chain_link(r->pool);
- if (cl == NULL) {
- return NGX_ERROR;
+ *pos = NGX_HTTP_V2_ENCODE_RAW;
+ pos = ngx_http_v2_write_int(pos, ngx_http_v2_prefix(7),
+ header[i].value.len);
+ pos = ngx_cpymem(pos, header[i].value.data, header[i].value.len);
}
- cl->buf = b;
- cl->next = NULL;
-
- frame = ngx_palloc(r->pool, sizeof(ngx_http_v2_out_frame_t));
+ frame = ngx_http_v2_create_headers_frame(r, start, pos);
if (frame == NULL) {
return NGX_ERROR;
}
- frame->first = cl;
- frame->last = cl;
- frame->handler = ngx_http_v2_headers_frame_handler;
- frame->stream = stream;
- frame->length = b->last - b->pos - NGX_HTTP_V2_FRAME_HEADER_SIZE;
- frame->blocked = 1;
- frame->fin = r->header_only;
-
- ngx_log_debug3(NGX_LOG_DEBUG_HTTP, stream->request->connection->log, 0,
- "http2:%ui create HEADERS frame %p: len:%uz",
- stream->node->id, frame, frame->length);
-
- ngx_http_v2_queue_blocked_frame(stream->connection, frame);
+ ngx_http_v2_queue_blocked_frame(r->stream->connection, frame);
cln = ngx_http_cleanup_add(r, 0);
if (cln == NULL) {
@@ -616,14 +545,14 @@
}
cln->handler = ngx_http_v2_filter_cleanup;
- cln->data = stream;
+ cln->data = r->stream;
- stream->queued = 1;
+ r->stream->queued = 1;
fc->send_chain = ngx_http_v2_send_chain;
fc->need_last_buf = 1;
- return ngx_http_v2_filter_send(fc, stream);
+ return ngx_http_v2_filter_send(fc, r->stream);
}
@@ -649,41 +578,104 @@
}
-static void
-ngx_http_v2_write_headers_head(u_char *pos, size_t length, ngx_uint_t sid,
- ngx_uint_t end_headers, ngx_uint_t end_stream)
+static ngx_http_v2_out_frame_t *
+ngx_http_v2_create_headers_frame(ngx_http_request_t *r, u_char *pos,
+ u_char *end)
{
- u_char flags;
+ u_char type, flags;
+ size_t rest, frame_size;
+ ngx_buf_t *b;
+ ngx_chain_t *cl, **ll;
+ ngx_http_v2_stream_t *stream;
+ ngx_http_v2_out_frame_t *frame;
- pos = ngx_http_v2_write_len_and_type(pos, length,
- NGX_HTTP_V2_HEADERS_FRAME);
-
- flags = NGX_HTTP_V2_NO_FLAG;
+ stream = r->stream;
+ rest = end - pos;
- if (end_headers) {
- flags |= NGX_HTTP_V2_END_HEADERS_FLAG;
+ frame = ngx_palloc(r->pool, sizeof(ngx_http_v2_out_frame_t));
+ if (frame == NULL) {
+ return NULL;
}
- if (end_stream) {
- flags |= NGX_HTTP_V2_END_STREAM_FLAG;
- }
+ frame->handler = ngx_http_v2_headers_frame_handler;
+ frame->stream = stream;
+ frame->length = rest;
+ frame->blocked = 1;
+ frame->fin = r->header_only;
- *pos++ = flags;
+ ll = &frame->first;
- (void) ngx_http_v2_write_sid(pos, sid);
-}
+ type = NGX_HTTP_V2_HEADERS_FRAME;
+ flags = r->header_only ? NGX_HTTP_V2_END_STREAM_FLAG : NGX_HTTP_V2_NO_FLAG;
+ frame_size = stream->connection->frame_size;
+ for ( ;; ) {
+ if (rest <= frame_size) {
+ frame_size = rest;
+ flags |= NGX_HTTP_V2_END_HEADERS_FLAG;
+ }
-static void
-ngx_http_v2_write_continuation_head(u_char *pos, size_t length, ngx_uint_t sid,
- ngx_uint_t end_headers)
-{
- pos = ngx_http_v2_write_len_and_type(pos, length,
- NGX_HTTP_V2_CONTINUATION_FRAME);
+ b = ngx_create_temp_buf(r->pool, NGX_HTTP_V2_FRAME_HEADER_SIZE);
+ if (b == NULL) {
+ return NULL;
+ }
+
+ b->last = ngx_http_v2_write_len_and_type(b->last, frame_size, type);
+ *b->last++ = flags;
+ b->last = ngx_http_v2_write_sid(b->last, stream->node->id);
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NULL;
+ }
- *pos++ = end_headers ? NGX_HTTP_V2_END_HEADERS_FLAG : NGX_HTTP_V2_NO_FLAG;
+ cl->buf = b;
- (void) ngx_http_v2_write_sid(pos, sid);
+ *ll = cl;
+ ll = &cl->next;
+
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
+ return NULL;
+ }
+
+ b->pos = pos;
+
+ pos += frame_size;
+
+ b->last = pos;
+ b->start = b->pos;
+ b->end = b->last;
+ b->temporary = 1;
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NULL;
+ }
+
+ cl->buf = b;
+
+ *ll = cl;
+ ll = &cl->next;
+
+ rest -= frame_size;
+
+ if (rest) {
+ type = NGX_HTTP_V2_CONTINUATION_FRAME;
+ flags = NGX_HTTP_V2_NO_FLAG;
+ continue;
+ }
+
+ b->last_buf = r->header_only;
+ cl->next = NULL;
+ frame->last = cl;
+
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http2:%ui create HEADERS frame %p: len:%uz",
+ stream->node->id, frame, frame->length);
+
+ return frame;
+ }
}
|
[-]
[+]
|
Changed |
nginx-1.9.6.tar.bz2/src/stream/ngx_stream_proxy_module.c
^
|
@@ -759,6 +759,10 @@
u->peer.save_session(&u->peer, u->peer.data);
}
+ if (pc->write->timer_set) {
+ ngx_del_timer(pc->write);
+ }
+
ngx_stream_proxy_init_upstream(s);
return;
|