Quantcast
Channel: Nginx Forum
Viewing all 53287 articles
Browse latest View live

Re: Upstream module usage to process data

$
0
0
Hello!

On Wed, May 31, 2017 at 08:22:07AM -0400, isolomka wrote:

> Does upstream works correctly with thread pool enabled?

Yes, it does.

> I see some strange validation in ngx_http_upstream_init_request()
> if (r->aio) {
> return;
> }
> that flag is set when thread pool is enabled.

The flag indicates that an aio operation (or thread operation) is
in progress. In ngx_http_upstream_init_request() it means that
reading of cache file header is currently in progress, and not yet
complete. The flag will be cleared once reading is complete.

Note that if you are trying to use thread pools in your own code,
it might be tricky to do it correctly, especially if you are
trying to do so from an input filter (likely won't be possible).

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Upstream module usage to process data

$
0
0
So I have my own module which is working with thread pool enabled.
ngx_http_upstream_init is called from my thread_event_handler, flag r->aio is enabled.
In fact, upstream is not initialized at all.

When i set aio flag to false and call to ngx_http_upstream_init, i'm getting a core dump in ngx_epoll_process_events.

Re: [njs] Lexer support for hexadecimal literal values.

$
0
0
Hi Дмитрий

Thanx for this. This is great.

I'm going to update and test.

Best regards to all nginx team,

--------------------------------------
Paulo Pacheco | Паулу Пашеку


On Wed, May 31, 2017 at 12:56 PM, Dmitry Volyntsev <xeioex@nginx.com> wrote:

> Hi, Paulo
>
> the support for hexadecimal literal values was committed in
> http://hg.nginx.org/njs/rev/a38c33e9f728
>
> Thank you for prodding.
>
> On 21.05.2017 20:52, Paulo Pacheco wrote:
>
>> # HG changeset patch
>> # User Paulo Pacheco <fooinha@gmail.com <mailto:fooinha@gmail.com>>
>>
>> # Date 1495388206 0
>> # Sun May 21 17:36:46 2017 +0000
>> # Node ID 22db6b6a3a0eebff8453fb22035628410c05c5c8
>> # Parent 96fda9957427e1ea78d0096b019a3f3183db7346
>> [njs] Lexer support for hexadecimal literal values.
>>
>> diff -r 96fda9957427 -r 22db6b6a3a0e njs/njs_lexer.c
>> --- a/njs/njs_lexer.c Wed Apr 19 17:48:56 2017 +0300
>> +++ b/njs/njs_lexer.c Sun May 21 17:36:46 2017 +0000
>> @@ -19,7 +19,7 @@
>> #include <njs_variable.h>
>> #include <njs_parser.h>
>> #include <string.h>
>> -
>> +#include <stdlib.h>
>>
>> typedef struct njs_lexer_multi_s njs_lexer_multi_t;
>>
>> @@ -539,10 +539,28 @@
>> {
>> u_char c, *p;
>> double num, frac, scale;
>> + char *endptr;
>>
>> /* TODO: "1e2" */
>>
>> p = lexer->start;
>> +
>> + /* Hexadecimal literal values */
>> + if ( (lexer->end - lexer->start) > 2
>> + && (*p == 'x' || *p == 'X')
>> + && (lexer->prev_token > 0
>> + || ((lexer->start - 1) == lexer->text.start)
>> + )
>> + && (*(p-1) == '0')) {
>> +
>> + lexer->number = strtod((const char *) p-1, &endptr);
>> + if ((u_char *) endptr <= lexer->end) {
>> + lexer->start = (u_char *) endptr;
>> + return NJS_TOKEN_NUMBER;
>> + }
>> + lexer->number = 0;
>> + }
>> +
>> c = p[-1];
>>
>> /* Values below '0' become >= 208. */
>> diff -r 96fda9957427 -r 22db6b6a3a0e njs/test/njs_unit_test.c
>> --- a/njs/test/njs_unit_test.c Wed Apr 19 17:48:56 2017 +0300
>> +++ b/njs/test/njs_unit_test.c Sun May 21 17:36:46 2017 +0000
>> @@ -112,6 +112,18 @@
>> { nxt_string("+1"),
>> nxt_string("1") },
>>
>> + { nxt_string("var a = 0x01; a"),
>> + nxt_string("1") },
>> +
>> + { nxt_string("var x = 0xffff; x"),
>> + nxt_string("65535") },
>> +
>> + { nxt_string("0x01"),
>> + nxt_string("1") },
>> +
>> + { nxt_string("0xffff"),
>> + nxt_string("65535") },
>> +
>> { nxt_string("+1\n"),
>> nxt_string("1") },
>>
>>
>> ---------------------------------- CUT HERE
>> --------------------------------------
>> Paulo Pacheco | Паулу Пашеку
>>
>>
>>
>>
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>>
>>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: Upstream module usage to process data

$
0
0
Hello!

On Wed, May 31, 2017 at 09:00:42AM -0400, isolomka wrote:

> So I have my own module which is working with thread pool enabled.
> ngx_http_upstream_init is called from my thread_event_handler, flag r->aio
> is enabled.
> In fact, upstream is not initialized at all.
>
> When i set aio flag to false and call to ngx_http_upstream_init, i'm getting
> a core dump in ngx_epoll_process_events.

You certainly should not try to call upstream before your module's
thread operation is complete.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Upstream module usage to process data

$
0
0
So my design seems to be wrong. Thanks a lot for assistance.

Re: Rewrite to remove htm extension

$
0
0
Never mind I've worked it out

Put this in the server block


rewrite ^(/.*)\.htm(\?.*)?$ $1$2 permanent;

Pete

[njs] Fixed parseInt() zero radix parsing.

$
0
0
details: http://hg.nginx.org/njs/rev/b592f24c9ac6
branches:
changeset: 348:b592f24c9ac6
user: Andrey Zelenkov <zelenkov@nginx.com>
date: Wed May 31 20:25:44 2017 +0300
description:
Fixed parseInt() zero radix parsing.

diffstat:

njs/njs_number.c | 16 ++++++++++------
njs/test/njs_unit_test.c | 6 ++++++
2 files changed, 16 insertions(+), 6 deletions(-)

diffs (49 lines):

diff -r a38c33e9f728 -r b592f24c9ac6 njs/njs_number.c
--- a/njs/njs_number.c Tue May 30 19:35:08 2017 +0300
+++ b/njs/njs_number.c Wed May 31 20:25:44 2017 +0300
@@ -733,19 +733,23 @@ njs_number_parse_int(njs_vm_t *vm, njs_v
}

test_prefix = (end - p > 1);
+ radix = 0;

if (nargs > 2) {
radix = args[2].data.u.number;

- if (radix < 2 || radix > 36) {
- goto done;
- }
+ if (radix != 0) {
+ if (radix < 2 || radix > 36) {
+ goto done;
+ }

- if (radix != 16) {
- test_prefix = 0;
+ if (radix != 16) {
+ test_prefix = 0;
+ }
}
+ }

- } else {
+ if (radix == 0) {
radix = 10;
}

diff -r a38c33e9f728 -r b592f24c9ac6 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue May 30 19:35:08 2017 +0300
+++ b/njs/test/njs_unit_test.c Wed May 31 20:25:44 2017 +0300
@@ -7144,6 +7144,12 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("parseInt('12345abc')"),
nxt_string("12345") },

+ { nxt_string("parseInt('123', 0)"),
+ nxt_string("123") },
+
+ { nxt_string("parseInt('0XaBc', 0)"),
+ nxt_string("2748") },
+
{ nxt_string("parseInt('1010', 2)"),
nxt_string("10") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: fastcgi cache background update ssi подзапросов

$
0
0
Патч был закоммичен: http://hg.nginx.org/nginx/rev/9552758a786e (1.13.1)

On Thu, May 11, 2017 at 03:58:58AM -0400, metalfm1 wrote:
> Роман, огромное вам спасибо! Приложенный патч полностью решает мои проблемы.
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?21,274142,274154#msg-274154
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru

--
Roman Arutyunyan
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru

[njs] Fixed parseInt() leading white space ignoring.

$
0
0
details: http://hg.nginx.org/njs/rev/559d256dd65b
branches:
changeset: 349:559d256dd65b
user: Andrey Zelenkov <zelenkov@nginx.com>
date: Wed May 31 20:36:01 2017 +0300
description:
Fixed parseInt() leading white space ignoring.

diffstat:

njs/njs_number.c | 3 +--
njs/test/njs_unit_test.c | 3 +++
2 files changed, 4 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r b592f24c9ac6 -r 559d256dd65b njs/njs_number.c
--- a/njs/njs_number.c Wed May 31 20:25:44 2017 +0300
+++ b/njs/njs_number.c Wed May 31 20:36:01 2017 +0300
@@ -709,10 +709,9 @@ njs_number_parse_int(njs_vm_t *vm, njs_v
if (nargs > 1) {
(void) njs_string_prop(&string, &args[1]);

- p = string.start;
end = string.start + string.size;

- while (p < end) {
+ for (p = string.start; p < end; p++) {
if (*p != ' ') {
goto found;
}
diff -r b592f24c9ac6 -r 559d256dd65b njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed May 31 20:25:44 2017 +0300
+++ b/njs/test/njs_unit_test.c Wed May 31 20:36:01 2017 +0300
@@ -7150,6 +7150,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("parseInt('0XaBc', 0)"),
nxt_string("2748") },

+ { nxt_string("parseInt(' 123')"),
+ nxt_string("123") },
+
{ nxt_string("parseInt('1010', 2)"),
nxt_string("10") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

map to use regex or not

$
0
0
Hello,
I have a setup where I need to override backend's content type and was wondering which approach (without too much digging into source and/or doing microbenchmarks) is better (less cpu) from performance point of view?


map $uri $custom_content_type {
hostnames;
*.jpg "image/jpeg";
}

or with regex

map $uri $custom_content_type {
~\.jpg$ "image/jpeg";
}


(in general just for theoretical knowledge since the difference as I imagine is most likely very minimal/unnoticable)

rr

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

[PATCH] Headers filter: style

$
0
0
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1496263895 25200
# Wed May 31 13:51:35 2017 -0700
# Node ID 057ec63be834988b6435b4ef64a1c3bd0cc23959
# Parent ab6ef3037840393752d82fac01ea1eb4f972301c
Headers filter: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r ab6ef3037840 -r 057ec63be834 src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -98,7 +98,7 @@ static ngx_command_t ngx_http_headers_f
ngx_http_headers_expires,
NGX_HTTP_LOC_CONF_OFFSET,
0,
- NULL},
+ NULL },

{ ngx_string("add_header"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
@@ -106,7 +106,7 @@ static ngx_command_t ngx_http_headers_f
ngx_http_headers_add,
NGX_HTTP_LOC_CONF_OFFSET,
0,
- NULL},
+ NULL },

ngx_null_command
};
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

[PATCH] Upstream: style

$
0
0
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1496263896 25200
# Wed May 31 13:51:36 2017 -0700
# Node ID e7219bf8bc3781d3912a951f09553bb2f0a53b70
# Parent ab6ef3037840393752d82fac01ea1eb4f972301c
Upstream: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r ab6ef3037840 -r e7219bf8bc37 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2729,7 +2729,7 @@ ngx_http_upstream_process_body_in_memory
rev = c->read;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
- "http upstream process body on memory");
+ "http upstream process body in memory");

if (rev->timedout) {
ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out");
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: [PATCH] HTTP/2: reject HTTP/2 requests without ":scheme" pseudo-header

$
0
0
Hey Valentin,

> As the 1.11 branch is going to be stable soon, it's a good idea to postpone
> any changes that explicitly affect interoperability (at least till 1.13).

Any thoughts on this now that 1.12 branched?

Best regards,
Piotr Sikora
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: [PATCH] HTTP/2: reject HTTP/2 requests with "Connection" header

$
0
0
Hey,

> # HG changeset patch
> # User Piotr Sikora <piotrsikora@google.com>
> # Date 1490516709 25200
> # Sun Mar 26 01:25:09 2017 -0700
> # Node ID b8daccea5fde213d4b7a10fa9f57070ab3b6a1ec
> # Parent 22be63bf21edaa1b8ea916c7d8cd4e5fe4892061
> HTTP/2: reject HTTP/2 requests with "Connection" header.
>
> While there, populate r->headers_in.connection.
>
> Signed-off-by: Piotr Sikora <piotrsikora@google.com>

Ping.

Best regards,
Piotr Sikora
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

[PATCH] HTTP/2: reject HTTP/2 requests with invalid "TE" header value

$
0
0
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1496272340 25200
# Wed May 31 16:12:20 2017 -0700
# Node ID a8050d50338bf127d57f820744a498517bf44b68
# Parent ab6ef3037840393752d82fac01ea1eb4f972301c
HTTP/2: reject HTTP/2 requests with invalid "TE" header value.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r ab6ef3037840 -r a8050d50338b src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -27,6 +27,8 @@ static ngx_int_t ngx_http_process_host(n
ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
+static ngx_int_t ngx_http_process_te(ngx_http_request_t *r,
+ ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);

@@ -128,6 +130,10 @@ ngx_http_header_t ngx_http_headers_in[]
offsetof(ngx_http_headers_in_t, if_range),
ngx_http_process_unique_header_line },

+ { ngx_string("TE"),
+ offsetof(ngx_http_headers_in_t, te),
+ ngx_http_process_te },
+
{ ngx_string("Transfer-Encoding"),
offsetof(ngx_http_headers_in_t, transfer_encoding),
ngx_http_process_header_line },
@@ -1690,6 +1696,41 @@ ngx_http_process_connection(ngx_http_req


static ngx_int_t
+ngx_http_process_te(ngx_http_request_t *r, ngx_table_elt_t *h,
+ ngx_uint_t offset)
+{
+ if (r->headers_in.te == NULL) {
+ r->headers_in.te = h;
+ }
+
+ if (r->http_version <= NGX_HTTP_VERSION_11) {
+ return NGX_OK;
+ }
+
+ if (h->value.len == sizeof("trailers") - 1
+ && ngx_memcmp(h->value.data, "trailers", sizeof("trailers") - 1) == 0)
+ {
+ return NGX_OK;
+ }
+
+#if (NGX_HTTP_V2)
+
+ if (r->http_version >= NGX_HTTP_VERSION_20) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent HTTP/2 request with invalid header value: "
+ "\"TE: %V\"", &h->value);
+
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+#endif
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
diff -r ab6ef3037840 -r a8050d50338b src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -196,6 +196,7 @@ typedef struct {
ngx_table_elt_t *range;
ngx_table_elt_t *if_range;

+ ngx_table_elt_t *te;
ngx_table_elt_t *transfer_encoding;
ngx_table_elt_t *expect;
ngx_table_elt_t *upgrade;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: Use primes for hashtable size

$
0
0
Hi, Maxim!

2017-05-30 18:01 GMT+05:00 Maxim Dounin <mdounin@mdounin.ru>:
>
> The maximum size of hash table as specified by the hinit->max_size
> field is indeed maximum size, and not the size of the hash table.
> Following code in the ngx_hash_init() will try hard to find to
> find out an optimal hash size for a given set of values within the
> maximum size specified, and will test all the prime numbers as
> well.
>
> I see no reasons to additionally limit the maximum size to a prime
> number. If you think there are some, please be more specific.
>
> You are right. I've modified patch to checkout primes first, then proceed
to "hard work" . Also I've kolhozed some perf prove of improvement.
This test creates a hash table of 5000 semirandom strings (not very random,
just bytes permutated).
On my Ubuntu VM without patch hash creation is 92-96ms, with patch it's
strictly 0. "hard work" search tries about 2k sizes before success, primes
search hits at second.

Docs say some words about startup speed and I wanted to apply primes
somewhere, so here we go.

Best regards, Andrey Borodin.
diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c
index 1944c7a21d..4e733c4625 100644
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -244,6 +244,152 @@ ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key, u_char *name,
return NULL;
}

+static ngx_uint_t ngx_hash_min_prime(ngx_uint_t value) {
+ static ngx_uint_t primes[] =
+ {
+ 3,
+ 7,
+ 11,
+ 17,
+ 23,
+ 29,
+ 37,
+ 47,
+ 59,
+ 71,
+ 89,
+ 107,
+ 131,
+ 163,
+ 197,
+ 239,
+ 293,
+ 353,
+ 431,
+ 521,
+ 631,
+ 761,
+ 919,
+ 1103,
+ 1327,
+ 1597,
+ 1931,
+ 2333,
+ 2801,
+ 3371,
+ 4049,
+ 4861,
+ 5839,
+ 7013,
+ 8419,
+ 10103,
+ 12143,
+ 14591,
+ 17519,
+ 21023,
+ 25229,
+ 30293,
+ 36353,
+ 43627,
+ 52361,
+ 62851,
+ 75431,
+ 90523,
+ 108631,
+ 130363,
+ 156437,
+ 187751,
+ 225307,
+ 270371,
+ 324449,
+ 389357,
+ 467237,
+ 560689,
+ 672827,
+ 807403,
+ 968897,
+ 1162687,
+ 1395263,
+ 1674319,
+ 2009191,
+ 2411033,
+ 2893249,
+ 3471899,
+ 4166287,
+ 4999559,
+ 5999471,
+ 7199369,
+ 7919311,
+ 8711267,
+ 9582409,
+ 10540661,
+ 11594729,
+ 12754219,
+ 14029643,
+ 15432619,
+ 16975891,
+ 18673483,
+ 20540831,
+ 22594919,
+ 24854419,
+ 27339863,
+ 30073853,
+ 33081239,
+ 36389369,
+ 40028333,
+ 44031179,
+ 48434303,
+ 53277769,
+ 58605563,
+ 64466147,
+ 70912783,
+ 78004061,
+ 85804471,
+ 94384919,
+ 103823417,
+ 114205771,
+ 125626351,
+ 138189017,
+ 152007971,
+ 167208817,
+ 183929719,
+ 202322693,
+ 222554977,
+ 244810487,
+ 269291537,
+ 296220709,
+ 325842779,
+ 358427071,
+ 394269781,
+ 433696759,
+ 477066449,
+ 524773133,
+ 577250461,
+ 634975519,
+ 698473099,
+ 768320467,
+ 845152513,
+ 929667799,
+ 1022634581,
+ 1124898043,
+ 1237387859,
+ 1361126671,
+ 1497239377,
+ 1646963321,
+ 1811659669,
+ 1992825643,
+ };
+
+ for (size_t i = 0; i < sizeof(primes)/sizeof(*primes); ++i)
+ {
+ ngx_uint_t prime = primes[i];
+ if (prime > value)
+ {
+ return prime;
+ }
+ }
+ return value;
+}

#define NGX_HASH_ELT_SIZE(name) \
(sizeof(void *) + ngx_align((name)->key.len + 2, sizeof(void *)))
@@ -283,6 +429,36 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)

bucket_size = hinit->bucket_size - sizeof(void *);

+ /*
+ * For hash size check primes first, then try others.
+ * There cannot be more than log(max_size) primes to test
+ */
+
+ for (size = ngx_hash_min_prime(nelts); size <= hinit->max_size; size = ngx_hash_min_prime(size)) {
+
+ ngx_memzero(test, size * sizeof(u_short));
+
+ for (n = 0; n < nelts; n++) {
+ if (names[n].key.data == NULL) {
+ continue;
+ }
+
+ key = names[n].key_hash % size;
+ test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
+
+ if (test[key] > (u_short) bucket_size) {
+ goto next_prime;
+ }
+ }
+
+ goto found;
+
+ next_prime:
+
+ continue;
+ }
+
+
start = nelts / (bucket_size / (2 * sizeof(void *)));
start = start ? start : 1;

diff --git a/src/core/nginx.c b/src/core/nginx.c
index abaa50d618..904a11fb76 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -8,6 +8,8 @@
#include <ngx_config.h>
#include <ngx_core.h>
#include <nginx.h>
+#include <sys/time.h>
+#include <sys/resource.h>


static void ngx_show_version_info(void);
@@ -282,6 +284,49 @@ main(int argc, char *const *argv)
}

cycle = ngx_init_cycle(&init_cycle);
+
+
+ /* Here will be hash tests */
+ {
+ size_t elementscount = 5000;
+ ngx_hash_t hashx;
+ ngx_hash_key_t *elements;
+ ngx_hash_init_t hash;
+ struct rusage start,end;
+ ngx_log_stderr(0,"doing tests");
+
+
+ elements = ngx_alloc(sizeof(ngx_hash_key_t)*elementscount,log);
+
+ hash.hash = &hashx;
+ hash.key = ngx_hash_key;
+ hash.max_size = 10000;
+ hash.bucket_size = 64;
+ hash.name = "test_hash";
+ hash.pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
+ hash.temp_pool = NULL;
+
+ srand(42);
+ for(size_t i=0;i<elementscount;i++){
+ elements[i].key.len = 4;
+ elements[i].key.data = ngx_alloc(4,log);
+
+ ((u_char*)elements[i].key.data)[3] = 'a' + (i%16);
+ ((u_char*)elements[i].key.data)[1] = 'a' + ((i>>4)%16);
+ ((u_char*)elements[i].key.data)[2] = 'a' + ((i>>8)%16);
+ ((u_char*)elements[i].key.data)[0] = 'a' + ((i>>16)%16);
+ elements[i].key_hash = ngx_hash_key(elements[i].key.data,4);
+ }
+
+ ngx_log_stderr(0, "before init");
+ getrusage(RUSAGE_SELF,&start);
+ ngx_hash_init(&hash, elements , elementscount);
+ getrusage(RUSAGE_SELF,&end);
+ ngx_log_stderr(0, "after init");
+ ngx_log_stderr(0, "time %d",end.ru_utime.tv_usec - start.ru_utime.tv_usec);
+ return 0;
+ }
+
if (cycle == NULL) {
if (ngx_test_config) {
ngx_log_stderr(0, "configuration file %s test failed",
@@ -317,6 +362,7 @@ main(int argc, char *const *argv)
return 0;
}

+
if (ngx_signal) {
return ngx_signal_process(cycle, ngx_signal);
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

[nginx] Headers filter: style.

$
0
0
details: http://hg.nginx.org/nginx/rev/057ec63be834
branches:
changeset: 7017:057ec63be834
user: Piotr Sikora <piotrsikora@google.com>
date: Wed May 31 13:51:35 2017 -0700
description:
Headers filter: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diffstat:

src/http/modules/ngx_http_headers_filter_module.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -98,7 +98,7 @@ static ngx_command_t ngx_http_headers_f
ngx_http_headers_expires,
NGX_HTTP_LOC_CONF_OFFSET,
0,
- NULL},
+ NULL },

{ ngx_string("add_header"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
@@ -106,7 +106,7 @@ static ngx_command_t ngx_http_headers_f
ngx_http_headers_add,
NGX_HTTP_LOC_CONF_OFFSET,
0,
- NULL},
+ NULL },

ngx_null_command
};
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

[nginx] Upstream: style.

$
0
0
details: http://hg.nginx.org/nginx/rev/610a219b28f6
branches:
changeset: 7018:610a219b28f6
user: Piotr Sikora <piotrsikora@google.com>
date: Wed May 31 13:51:36 2017 -0700
description:
Upstream: style.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diffstat:

src/http/ngx_http_upstream.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2729,7 +2729,7 @@ ngx_http_upstream_process_body_in_memory
rev = c->read;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
- "http upstream process body on memory");
+ "http upstream process body in memory");

if (rev->timedout) {
ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out");
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

[nginx] Style.

$
0
0
details: http://hg.nginx.org/nginx/rev/8ce1a34f160b
branches:
changeset: 7019:8ce1a34f160b
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Jun 01 16:49:14 2017 +0300
description:
Style.

diffstat:

src/os/unix/ngx_udp_sendmsg_chain.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diffs (20 lines):

diff --git a/src/os/unix/ngx_udp_sendmsg_chain.c b/src/os/unix/ngx_udp_sendmsg_chain.c
--- a/src/os/unix/ngx_udp_sendmsg_chain.c
+++ b/src/os/unix/ngx_udp_sendmsg_chain.c
@@ -206,13 +206,13 @@ ngx_sendmsg(ngx_connection_t *c, ngx_iov
#if (NGX_HAVE_MSGHDR_MSG_CONTROL)

#if (NGX_HAVE_IP_SENDSRCADDR)
- u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))];
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))];
#elif (NGX_HAVE_IP_PKTINFO)
- u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))];
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))];
#endif

#if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
- u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+ u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
#endif

#endif
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Re: [PATCH] Headers filter: style

$
0
0
Hello!

On Wed, May 31, 2017 at 01:54:00PM -0700, Piotr Sikora via nginx-devel wrote:

> # HG changeset patch
> # User Piotr Sikora <piotrsikora@google.com>
> # Date 1496263895 25200
> # Wed May 31 13:51:35 2017 -0700
> # Node ID 057ec63be834988b6435b4ef64a1c3bd0cc23959
> # Parent ab6ef3037840393752d82fac01ea1eb4f972301c
> Headers filter: style.
>
> Signed-off-by: Piotr Sikora <piotrsikora@google.com>
>
> diff -r ab6ef3037840 -r 057ec63be834 src/http/modules/ngx_http_headers_filter_module.c
> --- a/src/http/modules/ngx_http_headers_filter_module.c
> +++ b/src/http/modules/ngx_http_headers_filter_module.c
> @@ -98,7 +98,7 @@ static ngx_command_t ngx_http_headers_f
> ngx_http_headers_expires,
> NGX_HTTP_LOC_CONF_OFFSET,
> 0,
> - NULL},
> + NULL },
>
> { ngx_string("add_header"),
> NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
> @@ -106,7 +106,7 @@ static ngx_command_t ngx_http_headers_f
> ngx_http_headers_add,
> NGX_HTTP_LOC_CONF_OFFSET,
> 0,
> - NULL},
> + NULL },
>
> ngx_null_command
> };

Committed, thanks.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Viewing all 53287 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>