Re: Module connecting outside
Hello, I have a module connecting to the outside through SSL with the usage of ngx_event_connect_peer and the SSL primitives of nginx. My next question is, it is better to have a separate peer and its connection for each worker, or share the same connection among all the workers? My idea is to send some information to the outside world and both ways may work, but I want to be sure to make the correct design decision. Thanks a lot, Antonio 2017-03-21 14:57 GMT+01:00 Maxim Dounin: > Hello! > > On Tue, Mar 21, 2017 at 02:42:01PM +0100, Antonio Nappa wrote: > > > By checking the ngx_http_upstream I don't see any kind of handling in > case > > the ngx_ssl_handshake returns NGX_ERROR, I am trying to catch this error > in > > order to handle network outages and subsequent reconnections attempts > from > > my module. Do you think this could be a good way to trigger reconnection > > timer? At the moment I am handling reconnections also in the read and > write > > events when if(wev->timedout || c->error || c->close). > > The ngx_http_upstream_ssl_handshake() function checks if > c->ssl->handshaked is set. If it's not, there was an error or a > timeout. > > -- > Maxim Dounin > http://nginx.org/ > ___ > 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
[njs] Array.of() method.
details: http://hg.nginx.org/njs/rev/b7d65eb7d6fa branches: changeset: 324:b7d65eb7d6fa user: Andrey Zelenkovdate: Thu Mar 30 22:01:17 2017 +0300 description: Array.of() method. diffstat: njs/njs_array.c | 34 ++ njs/test/njs_unit_test.c | 12 2 files changed, 46 insertions(+), 0 deletions(-) diffs (73 lines): diff -r 90743d1bb614 -r b7d65eb7d6fa njs/njs_array.c --- a/njs/njs_array.c Wed Mar 29 15:54:37 2017 +0300 +++ b/njs/njs_array.c Thu Mar 30 22:01:17 2017 +0300 @@ -291,6 +291,32 @@ njs_array_is_array(njs_vm_t *vm, njs_val } +static njs_ret_t +njs_array_of(njs_vm_t *vm, njs_value_t *args, +nxt_uint_t nargs, njs_index_t unused) +{ +uint32_t length, i; +njs_array_t *array; + +length = nargs > 1 ? nargs - 1 : 0; + +array = njs_array_alloc(vm, length, NJS_ARRAY_SPARE); +if (nxt_slow_path(array == NULL)) { +return NXT_ERROR; +} + +vm->retval.data.u.array = array; +vm->retval.type = NJS_ARRAY; +vm->retval.data.truth = 1; + +for (i = 0; i < length; i++) { +array->start[i] = args[i + 1]; +} + +return NXT_OK; +} + + static const njs_object_prop_t njs_array_constructor_properties[] = { /* Array.name == "Array". */ @@ -320,6 +346,14 @@ static const njs_object_prop_t njs_arra .name = njs_string("isArray"), .value = njs_native_function(njs_array_is_array, 0, 0), }, + +/* ES6. */ +/* Array.of(). */ +{ +.type = NJS_METHOD, +.name = njs_string("of"), +.value = njs_native_function(njs_array_of, 0, 0), +}, }; diff -r 90743d1bb614 -r b7d65eb7d6fa njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Wed Mar 29 15:54:37 2017 +0300 +++ b/njs/test/njs_unit_test.c Thu Mar 30 22:01:17 2017 +0300 @@ -2499,6 +2499,18 @@ static njs_unit_test_t njs_test[] = { nxt_string("Array.isArray([])"), nxt_string("true") }, +{ nxt_string("Array.of()"), + nxt_string("") }, + +{ nxt_string("Array.of(1,2,3)"), + nxt_string("1,2,3") }, + +{ nxt_string("Array.of(undefined,1)"), + nxt_string(",1") }, + +{ nxt_string("Array.of(NaN,-1,{})"), + nxt_string("NaN,-1,[object Object]") }, + { nxt_string("var a = [1,2,3]; a.concat(4, [5, 6, 7], 8)"), nxt_string("1,2,3,4,5,6,7,8") }, ___ 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
On Wednesday 29 March 2017 20:01:55 Piotr Sikora via nginx-devel wrote: > Hey Valentin, > > > IMHO it's not a good idea to combine style fixes with behavior changes. > > Behavior changing commits are occasionally reverted. > > Fair enough, I'll update both patches shortly. > > > That's why it's still TODO (in other words intentionally skipped). > > We discussed it with QA and decided to be more tolerant here. > > I disagree. Forgiving implementations that allow broken clients to > seemingly "work", even when said clients are not obeying the > specification, are the reason why we have broken clients in the first > place. > One of the broken clients (not in this place particularly, but in a few others) is Google Chrome. Sometimes it takes year to convince devs to do something about that, even if the issue is obvious. Here is an example: https://bugs.chromium.org/p/chromium/issues/detail?id=546991 And if something isn't working in browser-webserver combination then this is usually us who will be blamed for. Because people need their services working in the first place. As a result, you can see such commits: http://hg.nginx.org/nginx/rev/8df664ebe037 I agree with your arguments about the positive side in enforcing strict validation. On the other hand, the main goal is to keep our users setups working with any clients. The world isn't perfect and neither us, nor our users can fix it. 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). wbr, Valentin V. Bartenev ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
Re: [PATCH] HTTP/2: style and typos
On Wednesday 29 March 2017 18:02:48 Piotr Sikora via nginx-devel wrote: > # HG changeset patch > # User Piotr Sikora> # Date 1490516701 25200 > # Sun Mar 26 01:25:01 2017 -0700 > # Node ID c76c2cedb2b2a1af16d77448e81801954713961f > # Parent 22be63bf21edaa1b8ea916c7d8cd4e5fe4892061 > HTTP/2: style and typos. > > Signed-off-by: Piotr Sikora > [..] Committed. Thanks. http://hg.nginx.org/nginx/rev/28dc369899ea wbr, Valentin V. Bartenev ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] HTTP/2: style and typos.
details: http://hg.nginx.org/nginx/rev/28dc369899ea branches: changeset: 6958:28dc369899ea user: Piotr Sikoradate: Sun Mar 26 01:25:01 2017 -0700 description: HTTP/2: style and typos. Signed-off-by: Piotr Sikora diffstat: src/http/v2/ngx_http_v2.c | 11 ++- src/http/v2/ngx_http_v2.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diffs (69 lines): diff -r 83bae3d354ab -r 28dc369899ea src/http/v2/ngx_http_v2.c --- a/src/http/v2/ngx_http_v2.c Wed Mar 29 20:21:01 2017 +0300 +++ b/src/http/v2/ngx_http_v2.c Sun Mar 26 01:25:01 2017 -0700 @@ -941,7 +941,7 @@ ngx_http_v2_state_read_data(ngx_http_v2_ if (size >= h2c->state.length) { size = h2c->state.length; -stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG; +stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG; } r = stream->request; @@ -1905,7 +1905,7 @@ ngx_http_v2_state_rst_stream(ngx_http_v2 if (node == NULL || node->stream == NULL) { ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, -"unknown http2 stream"); + "unknown http2 stream"); return ngx_http_v2_state_complete(h2c, pos, end); } @@ -2019,6 +2019,7 @@ ngx_http_v2_state_settings_params(ngx_ht break; case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING: + if (value > NGX_HTTP_V2_MAX_FRAME_SIZE || value < NGX_HTTP_V2_DEFAULT_FRAME_SIZE) { @@ -3076,7 +3077,7 @@ ngx_http_v2_pseudo_header(ngx_http_reque } ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, - "client sent unknown pseudo header \"%V\"", + "client sent unknown pseudo-header \":%V\"", >name); return NGX_DECLINED; @@ -3223,14 +3224,14 @@ ngx_http_v2_parse_scheme(ngx_http_reques { if (r->schema_start) { ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, - "client sent duplicate :schema header"); + "client sent duplicate :scheme header"); return NGX_DECLINED; } if (header->value.len == 0) { ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, - "client sent empty :schema header"); + "client sent empty :scheme header"); return NGX_DECLINED; } diff -r 83bae3d354ab -r 28dc369899ea src/http/v2/ngx_http_v2.h --- a/src/http/v2/ngx_http_v2.h Wed Mar 29 20:21:01 2017 +0300 +++ b/src/http/v2/ngx_http_v2.h Sun Mar 26 01:25:01 2017 -0700 @@ -249,8 +249,8 @@ ngx_http_v2_queue_blocked_frame(ngx_http { ngx_http_v2_out_frame_t **out; -for (out = >last_out; *out; out = &(*out)->next) -{ +for (out = >last_out; *out; out = &(*out)->next) { + if ((*out)->blocked || (*out)->stream == NULL) { break; } ___ 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
Hi Piotr, On 30/03/2017 04:01, Piotr Sikora via nginx-devel wrote: > Hey Valentin, > >> IMHO it's not a good idea to combine style fixes with behavior changes. >> Behavior changing commits are occasionally reverted. > > Fair enough, I'll update both patches shortly. > >> That's why it's still TODO (in other words intentionally skipped). >> We discussed it with QA and decided to be more tolerant here. > > I disagree. Forgiving implementations that allow broken clients to > seemingly "work", even when said clients are not obeying the > specification, are the reason why we have broken clients in the first > place. > How does google.com as a service behave with such clients? -- Maxim Konovalov ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel