From jan.prachar at gmail.com Wed Jan 2 19:17:46 2019 From: jan.prachar at gmail.com (Jan =?UTF-8?Q?Pracha=C5=99?=) Date: Wed, 02 Jan 2019 20:17:46 +0100 Subject: SSL_shutdown() return value <0 In-Reply-To: <20181211133348.GW99070@mdounin.ru> References: <7eb37d13ecfeeb33b090ee64152e2b04a2e8806c.camel@gmail.com> <20181211133348.GW99070@mdounin.ru> Message-ID: <31c9fd6621f695a7e27ef9daf9b03cff8a581010.camel@gmail.com> Hello! Thanks for the detailed explanation of ignoring SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE in ngx_ssl_shutdown. On Tue, 2018-12-11 at 16:33 +0300, Maxim Dounin wrote: > Hello! > > On Mon, Dec 10, 2018 at 09:46:28PM +0100, Jan Pracha? wrote: > > I have also tried to change the condition to just n < 0, and came > > to > > antoher issue. If client closes connection prematurely, there is > > usually SSL_write, that has failed with error WANT_WRITE. If then > > the > > SSL_shutdown is called repeatedly, it causes OpenSSL error (SSL: > > error:1409F07F:SSL routines:ssl3_write_pending:bad write retry), > > because pending SSL_write should have been called first. > > In many places we try to avoid doing actual SSL shutdown if we > know there was an error and/or we know the connection was already > closed, by using c->ssl->no_send_shutdown flag. Existing cases > might not be enough though. I have given some time to debug the issue and I have found that in this case nginx closes the connection inside read event handler ngx_http_test_reading(). As you adviced, I added + #if (NGX_HTTP_SSL) + if (c->ssl) { + c->ssl->no_send_shutdown = 1; + } + #endif + ngx_http_finalize_request(r, NGX_HTTP_CLIENT_CLOSED_REQUEST); } just before the last line in the function, and then all errors SSL: error:1409F07F:SSL routines:ssl3_write_pending:bad write retry dissapear. -- Jan Pracha? From fdintino at theatlantic.com Thu Jan 3 05:21:15 2019 From: fdintino at theatlantic.com (Frankie Dintino) Date: Thu, 3 Jan 2019 00:21:15 -0500 Subject: rate limit request body read from a body filter? (nginx-upload-module) Message-ID: <7C63024C-E4EE-419E-AFCC-0E29D839C9E7@theatlantic.com> Hi, I'm currently trying to rewrite https://github.com/fdintino/nginx-upload-module/ as a request body filter, in order to simplify the code and future-proof it (as it's currently written, there's a lot of copypasta from ngx_http_request_body.c that is very fragile and probably already incompatible with new features and third party modules). I'm nearly done this work, but I've hit a stumbling block trying to port the upload rate limiting feature. The current implementation completely overrides the request handler, so rate-limiting the request body is pretty trivial: if you need to delay the next buffer read, to stay within the rate limit, you can set c->read->delayed = 1, call ngx_add_timer(c->read, delay), and return NGX_AGAIN. When I try this from the request body filter, I'm able to delay the very next read event, but afterwards when control is returned to the outer request handler, the rate that read buffers get consumed is no longer within my control (also, returning NGX_AGAIN from the body handler to the http2 request handler doesn't work at all?it raises a 500?but that's another issue). So it seems to me that?if I want to keep the upload rate limiting feature?I'm going to have to do it somewhere else, maybe in a custom read event handler. Is there another option I'm not thinking of? And if I have to do it in a custom read_event_handler, does anyone have pointers for how I can do this in the least obtrusive way? Thanks! Frankie Dintino The Atlantic -------------- next part -------------- An HTML attachment was scrubbed... URL: From msellers at ranchmed.com Thu Jan 3 16:46:30 2019 From: msellers at ranchmed.com (Mark Sellers) Date: Thu, 3 Jan 2019 08:46:30 -0800 Subject: Module executed w/o directive in config Message-ID: <193650F6-8669-4393-9894-B64F71ECB8A8@ranchmed.com> I am building a simple module that does a uri rewrite (not using the rewrite module). The module directive is fastimg_rewrite with no parameters. I build the code, including the module. When attempt to access any url, I get an error in the log: *1 rewrite or internal redirection cycle while internally redirecting to "/images/bar/index.html? Funny thing is, I have not added the directive to my config file yet! Q1: Directive not in config - why is my module executing? Q2: What does this error message indicate? I do want to redirect to ?/images/bar/index.html?!! Here is the config file: server { listen 192.168.1.101:80; server_name dev.static.ranchmed.com ; root /var/www/html/static.ranchmed.com ; charset UTF-8; location / { } location /images/ { # fastimg_rewrite; # try_files $uri @fastimg_fcgi; } location @fastimg_fcgi { include fastcgi_params; fastcgi_pass 127.0.0.1:3000; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdounin at mdounin.ru Fri Jan 4 05:38:08 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 4 Jan 2019 08:38:08 +0300 Subject: Module executed w/o directive in config In-Reply-To: <193650F6-8669-4393-9894-B64F71ECB8A8@ranchmed.com> References: <193650F6-8669-4393-9894-B64F71ECB8A8@ranchmed.com> Message-ID: <20190104053808.GK99070@mdounin.ru> Hello! On Thu, Jan 03, 2019 at 08:46:30AM -0800, Mark Sellers wrote: > I am building a simple module that does a uri rewrite (not using > the rewrite module). The module directive is fastimg_rewrite > with no parameters. > > I build the code, including the module. > > When attempt to access any url, I get an error in the log: > > *1 rewrite or internal redirection cycle while internally > redirecting to "/images/bar/index.html? > > Funny thing is, I have not added the directive to my config file > yet! > > Q1: Directive not in config - why is my module executing? It is the module which decides what to do, and whether to do anything without any directives in the configuration, or not. That is, check your code. > Q2: What does this error message indicate? I do want to redirect to ?/images/bar/index.html?!! The message indicates that there were too many redirects, and nginx decided to stop it. Most likely, your code redirects all requests, including already redirected ones, and this is what causes the problem. -- Maxim Dounin http://mdounin.ru/ From vadimjunk at gmail.com Sun Jan 6 21:40:28 2019 From: vadimjunk at gmail.com (Vadim Fedorenko) Date: Mon, 7 Jan 2019 00:40:28 +0300 Subject: remove unneeded io_getevents syscall. Message-ID: # HG changeset patch # User Vadim Fedorenko # Date 1546810494 0 # Sun Jan 06 21:34:54 2019 +0000 # Node ID 3e538f6b8267d36f97b7dd67714c6ba0fba5e5bc # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 remove unneeded io_getevents syscall. This work is based on cloudflare's work on optimization Linux AIO. https://blog.cloudflare.com/io_submit-the-epoll-alternative-youve-never-heard-about/ The code is compilation of libaio library, it eliminates unnecessary context-switch on getting new AIO events, doing all possible work in userspace. diff -r 6d15e452fa2e -r 3e538f6b8267 src/event/modules/ngx_epoll_module.c --- a/src/event/modules/ngx_epoll_module.c Tue Dec 25 17:53:03 2018 +0300 +++ b/src/event/modules/ngx_epoll_module.c Sun Jan 06 21:34:54 2019 +0000 @@ -100,6 +100,35 @@ ngx_uint_t aio_requests; } ngx_epoll_conf_t; +#if (NGX_HAVE_FILE_AIO) + +/* Stolen from kernel arch/x86_64.h */ +#ifdef __x86_64__ +#define read_barrier() __asm__ __volatile__("lfence" ::: "memory") +#else +#ifdef __i386__ +#define read_barrier() __asm__ __volatile__("" : : : "memory") +#else +#define read_barrier() __sync_synchronize() +#endif +#endif + +/* Stolen from kernel fs/aio.c */ +#define AIO_RING_MAGIC 0xa10a10a1 +struct aio_ring { + unsigned id; /* kernel internal index number */ + unsigned nr; /* number of io_events */ + unsigned head; + unsigned tail; + unsigned magic; + unsigned compat_features; + unsigned incompat_features; + unsigned header_length; /* size of aio_ring */ + struct io_event events[0]; +}; + +#endif + static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer); #if (NGX_HAVE_EVENTFD) @@ -241,6 +270,39 @@ io_getevents(aio_context_t ctx, long min_nr, long nr, struct io_event *events, struct timespec *tmo) { + /* Code based on cloudflare-blog */ + ngx_int_t i = 0; + + struct aio_ring *ring = (struct aio_ring *)ctx; + if (ring == NULL || ring->magic != AIO_RING_MAGIC) { + goto do_syscall; + } + + while (i < nr) { + unsigned head = ring->head; + if (head == ring->tail) { + /* There are no more completions */ + break; + } else { + /* There is another completion to reap */ + events[i] = ring->events[head]; + read_barrier(); + ring->head = (head + 1) % ring->nr; + i++; + } + } + + if (i == 0 && tmo != NULL && tmo->tv_sec == 0 && + tmo->tv_nsec == 0) { + /* Requested non blocking operation. */ + return 0; + } + + if (i && i >= min_nr) { + return i; + } + +do_syscall: return syscall(SYS_io_getevents, ctx, min_nr, nr, events, tmo); } From mdounin at mdounin.ru Mon Jan 7 04:24:48 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 7 Jan 2019 07:24:48 +0300 Subject: remove unneeded io_getevents syscall. In-Reply-To: References: Message-ID: <20190107042448.GO99070@mdounin.ru> Hello! On Mon, Jan 07, 2019 at 12:40:28AM +0300, Vadim Fedorenko wrote: > # HG changeset patch > # User Vadim Fedorenko > # Date 1546810494 0 > # Sun Jan 06 21:34:54 2019 +0000 > # Node ID 3e538f6b8267d36f97b7dd67714c6ba0fba5e5bc > # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 > remove unneeded io_getevents syscall. > > This work is based on cloudflare's work on optimization Linux AIO. > https://blog.cloudflare.com/io_submit-the-epoll-alternative-youve-never-heard-about/ > The code is compilation of libaio library, it eliminates unnecessary > context-switch on getting new AIO events, doing all possible work in > userspace. > > diff -r 6d15e452fa2e -r 3e538f6b8267 src/event/modules/ngx_epoll_module.c > --- a/src/event/modules/ngx_epoll_module.c Tue Dec 25 17:53:03 2018 +0300 > +++ b/src/event/modules/ngx_epoll_module.c Sun Jan 06 21:34:54 2019 +0000 > @@ -100,6 +100,35 @@ > ngx_uint_t aio_requests; > } ngx_epoll_conf_t; > > +#if (NGX_HAVE_FILE_AIO) > + > +/* Stolen from kernel arch/x86_64.h */ > +#ifdef __x86_64__ > +#define read_barrier() __asm__ __volatile__("lfence" ::: "memory") > +#else > +#ifdef __i386__ > +#define read_barrier() __asm__ __volatile__("" : : : "memory") > +#else > +#define read_barrier() __sync_synchronize() > +#endif > +#endif > + > +/* Stolen from kernel fs/aio.c */ > +#define AIO_RING_MAGIC 0xa10a10a1 > +struct aio_ring { > + unsigned id; /* kernel internal index number */ > + unsigned nr; /* number of io_events */ > + unsigned head; > + unsigned tail; > + unsigned magic; > + unsigned compat_features; > + unsigned incompat_features; > + unsigned header_length; /* size of aio_ring */ > + struct io_event events[0]; > +}; > + > +#endif > + > > static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer); > #if (NGX_HAVE_EVENTFD) > @@ -241,6 +270,39 @@ > io_getevents(aio_context_t ctx, long min_nr, long nr, struct io_event *events, > struct timespec *tmo) > { > + /* Code based on cloudflare-blog */ > + ngx_int_t i = 0; > + > + struct aio_ring *ring = (struct aio_ring *)ctx; > + if (ring == NULL || ring->magic != AIO_RING_MAGIC) { > + goto do_syscall; > + } > + > + while (i < nr) { > + unsigned head = ring->head; > + if (head == ring->tail) { > + /* There are no more completions */ > + break; > + } else { > + /* There is another completion to reap */ > + events[i] = ring->events[head]; > + read_barrier(); > + ring->head = (head + 1) % ring->nr; > + i++; > + } > + } > + > + if (i == 0 && tmo != NULL && tmo->tv_sec == 0 && > + tmo->tv_nsec == 0) { > + /* Requested non blocking operation. */ > + return 0; > + } > + > + if (i && i >= min_nr) { > + return i; > + } > + > +do_syscall: > return syscall(SYS_io_getevents, ctx, min_nr, nr, events, tmo); > } Thank you for the patch. This looks like a hack which relies on implementation details of the kernel code. Even if the hack is indeed correct for the current kernel code (I actually doubt it is, since it uses unlocked accesses to the structure which seems to be locked in the kernel), I do not think we want such code in nginx. -- Maxim Dounin http://mdounin.ru/ From sepherosa at gmail.com Tue Jan 8 03:37:03 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Tue, 8 Jan 2019 11:37:03 +0800 Subject: aio/unix: Use signal.sival which is standard Message-ID: sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL for quite a while. Patch: https://leaf.dragonflybsd.org/~sephe/nginx_sival.diff Thanks, sephe -- Tomorrow Will Never Die From pluknet at nginx.com Wed Jan 9 11:52:30 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Wed, 9 Jan 2019 14:52:30 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: Message-ID: > On 8 Jan 2019, at 06:37, Sepherosa Ziehau wrote: > > sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL > for quite a while. > > Patch: > https://leaf.dragonflybsd.org/~sephe/nginx_sival.diff Citing here for archives: commit 14d1cab150226367c8a0f0ae219b0e0571587aea Author: Yanmin Qiao Date: Tue Jan 8 11:33:00 2019 +0800 unix/aio: Use sigval.sival which is standard. sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL for quite a while. diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c index aedc3c90..bb60ee82 100644 --- a/src/os/unix/ngx_file_aio_read.c +++ b/src/os/unix/ngx_file_aio_read.c @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset, #if (NGX_HAVE_KQUEUE) aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; #endif ev->handler = ngx_file_aio_event_handler; FreeBSD 4/5/6 lack sival_ptr (FreeBSD 3 has it, but not yet SIGEV_KEVENT), which seemingly was broken in svn r48621 and later restored in r152029. And that means that the following will no longer be true: : Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only While nginx still maintains compatibility down to FreeBSD 2.2. If applied, it'd need this part as well (used to build on old FreeBSD): diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c --- a/src/event/modules/ngx_eventport_module.c +++ b/src/event/modules/ngx_eventport_module.c @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n ngx_memzero(&sev, sizeof(struct sigevent)); sev.sigev_notify = SIGEV_PORT; -#if !(NGX_TEST_BUILD_EVENTPORT) sev.sigev_value.sival_ptr = &pn; -#endif if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, -- Sergey Kandaurov From xeioex at nginx.com Wed Jan 9 15:22:42 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 09 Jan 2019 15:22:42 +0000 Subject: [njs] 2019 year. Message-ID: details: https://hg.nginx.org/njs/rev/fd135f1b18bb branches: changeset: 713:fd135f1b18bb user: Dmitry Volyntsev date: Wed Jan 09 18:21:31 2019 +0300 description: 2019 year. diffstat: LICENSE | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (14 lines): diff -r 74776ba6a1a2 -r fd135f1b18bb LICENSE --- a/LICENSE Sat Dec 29 22:35:31 2018 +0800 +++ b/LICENSE Wed Jan 09 18:21:31 2019 +0300 @@ -1,7 +1,7 @@ /* - * Copyright (C) 2015-2018 Igor Sysoev - * Copyright (C) 2017-2018 Dmitry Volyntsev - * Copyright (C) 2015-2018 NGINX, Inc. + * Copyright (C) 2015-2019 NGINX, Inc. + * Copyright (C) 2015-2019 Igor Sysoev + * Copyright (C) 2017-2019 Dmitry Volyntsev * All rights reserved. * * Redistribution and use in source and binary forms, with or without From xeioex at nginx.com Wed Jan 9 15:22:43 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 09 Jan 2019 15:22:43 +0000 Subject: [njs] Fixed vmcode function call. Message-ID: details: https://hg.nginx.org/njs/rev/d0ba2a63eb5a branches: changeset: 714:d0ba2a63eb5a user: hongzhidao date: Mon Jan 07 17:40:48 2019 +0800 description: Fixed vmcode function call. This closes #82 issue on Github. diffstat: njs/njs_vm.c | 10 ++++++++-- njs/test/njs_unit_test.c | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diffs (33 lines): diff -r fd135f1b18bb -r d0ba2a63eb5a njs/njs_vm.c --- a/njs/njs_vm.c Wed Jan 09 18:21:31 2019 +0300 +++ b/njs/njs_vm.c Mon Jan 07 17:40:48 2019 +0800 @@ -2086,8 +2086,14 @@ njs_vmcode_function_call(njs_vm_t *vm, n * If a retval is in a callee arguments scope it * must be in the previous callee arguments scope. */ - vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = - vm->top_frame->arguments + function->args_offset; + args = vm->top_frame->arguments; + function = vm->top_frame->function; + + if (function != NULL) { + args += function->args_offset; + } + + vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args; retval = njs_vmcode_operand(vm, retval); /* diff -r fd135f1b18bb -r d0ba2a63eb5a njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Wed Jan 09 18:21:31 2019 +0300 +++ b/njs/test/njs_unit_test.c Mon Jan 07 17:40:48 2019 +0800 @@ -4017,6 +4017,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(5, 6, 7, 8, 9)"), nxt_string("0123456789") }, + { nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(Math.sqrt(25))"), + nxt_string("012345") }, + { nxt_string("var f = String.prototype.concat.bind(0, 1); f(2)"), nxt_string("012") }, From xeioex at nginx.com Wed Jan 9 15:25:12 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 09 Jan 2019 15:25:12 +0000 Subject: [njs] Refactored njs_function_frame_free. Message-ID: details: https://hg.nginx.org/njs/rev/0e7fc17f6071 branches: changeset: 715:0e7fc17f6071 user: hongzhidao date: Mon Jan 07 17:42:00 2019 +0800 description: Refactored njs_function_frame_free. diffstat: njs/njs_vm.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diffs (50 lines): diff -r d0ba2a63eb5a -r 0e7fc17f6071 njs/njs_vm.c --- a/njs/njs_vm.c Mon Jan 07 17:40:48 2019 +0800 +++ b/njs/njs_vm.c Mon Jan 07 17:42:00 2019 +0800 @@ -38,7 +38,7 @@ static njs_ret_t njs_vmcode_continuation njs_value_t *invld2); static njs_native_frame_t * njs_function_previous_frame(njs_native_frame_t *frame); -static njs_ret_t njs_function_frame_free(njs_vm_t *vm, +static void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame); static void njs_vm_trap(njs_vm_t *vm, njs_trap_t trap, njs_value_t *value1, @@ -2080,7 +2080,7 @@ njs_vmcode_function_call(njs_vm_t *vm, n frame = vm->top_frame; vm->top_frame = njs_function_previous_frame(frame); - (void) njs_function_frame_free(vm, frame); + njs_function_frame_free(vm, frame); /* * If a retval is in a callee arguments scope it @@ -2398,7 +2398,9 @@ njs_vmcode_return(njs_vm_t *vm, njs_valu vm->current = frame->return_address; - return njs_function_frame_free(vm, &frame->native); + njs_function_frame_free(vm, &frame->native); + + return 0; } @@ -2544,7 +2546,7 @@ njs_function_previous_frame(njs_native_f } -static njs_ret_t +static void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame) { njs_native_frame_t *previous; @@ -2562,8 +2564,6 @@ njs_function_frame_free(njs_vm_t *vm, nj frame = previous; } while (frame->skip); - - return 0; } From mdounin at mdounin.ru Wed Jan 9 19:02:11 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Wed, 9 Jan 2019 22:02:11 +0300 Subject: rate limit request body read from a body filter? (nginx-upload-module) In-Reply-To: <7C63024C-E4EE-419E-AFCC-0E29D839C9E7@theatlantic.com> References: <7C63024C-E4EE-419E-AFCC-0E29D839C9E7@theatlantic.com> Message-ID: <20190109190211.GV99070@mdounin.ru> Hello! On Thu, Jan 03, 2019 at 12:21:15AM -0500, Frankie Dintino wrote: > I'm currently trying to rewrite > https://github.com/fdintino/nginx-upload-module/ > as a request > body filter, in order to simplify the code and future-proof it > (as it's currently written, there's a lot of copypasta from > ngx_http_request_body.c that is very fragile and probably > already incompatible with new features and third party modules). > > I'm nearly done this work, but I've hit a stumbling block trying > to port the upload rate limiting feature. The current > implementation completely overrides the request handler, so > rate-limiting the request body is pretty trivial: if you need to > delay the next buffer read, to stay within the rate limit, you > can set c->read->delayed = 1, call ngx_add_timer(c->read, > delay), and return NGX_AGAIN. > > When I try this from the request body filter, I'm able to delay > the very next read event, but afterwards when control is > returned to the outer request handler, the rate that read > buffers get consumed is no longer within my control (also, > returning NGX_AGAIN from the body handler to the http2 request > handler doesn't work at all?it raises a 500?but that's another > issue). > > So it seems to me that?if I want to keep the upload rate > limiting feature?I'm going to have to do it somewhere else, > maybe in a custom read event handler. Is there another option > I'm not thinking of? And if I have to do it in a custom > read_event_handler, does anyone have pointers for how I can do > this in the least obtrusive way? With HTTP/1.x, I think it should be possible to implement rate limiting the way you are doing it as long as requests larger than client_body_buffer_size are concerned - that is, when writing requests to files. So nginx will read buffers up to client_body_buffer_size, and writing to a temporary file will be delayed by your code. With HTTP/2, I don't think there is a way to implement upload rate limiting without changes in the HTTP/2 code. -- Maxim Dounin http://mdounin.ru/ From msellers at ranchmed.com Wed Jan 9 23:05:22 2019 From: msellers at ranchmed.com (Mark Sellers) Date: Wed, 9 Jan 2019 15:05:22 -0800 Subject: Confusion about rewritten uri passed to a fastcgi program Message-ID: My module (ngx_http_fastimg_module) rewrites the uri of an image request. If the image is not yet in the filesystem, then it (using try_files) calls a fastcgi (fastimg_fcgi) that creates the image, serves it, and saves it in the file system. I have noticed something that I don?t understand. When the fastcgi program is executed, it receives the original uri in the REQUEST_URI fastcgi param, and not the rewritten uri. I also notice that the rewritten uri is available in the DOCUMENT_URI fastcgi param. Is this what you would expect? Thanks, Mark See partial debug log below. original uri: "/images/12/0/100/0.jpg? rewritten uri:"/images/21/12_0_100_0.jpg? ????? 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0 2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/" 2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/" 2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/" 2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2 2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler 2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri in: "/images/12/0/100/0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 ngx_http_fastimg_rewrite() uri out: "/images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 internal redirect: "/images/21/12_0_100_0.jpg?" 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 0 2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "/" 2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "images/" 2019/01/09 14:33:29 [debug] 19834#0: *1 using configuration "/images/" 2019/01/09 14:33:29 [debug] 19834#0: *1 http cl:-1 max:104857600 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2 2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3 2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6 2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7 2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8 2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10 2019/01/09 14:33:29 [debug] 19834#0: *1 try files handler 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "/images/21/12_0_100_0.jpg" "/var/www/html/static.ranchmed.com/images/21/12_0_100_0.jpg " 2019/01/09 14:33:29 [debug] 19834#0: *1 trying to use file: "@fastimg_fcgi" "/var/www/html/static.ranchmed.com @fastimg_fcgi" 2019/01/09 14:33:29 [debug] 19834#0: *1 test location: "@fastimg_fcgi" 2019/01/09 14:33:29 [debug] 19834#0: *1 using location: @fastimg_fcgi "/images/21/12_0_100_0.jpg?" 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 2 2019/01/09 14:33:29 [debug] 19834#0: *1 fastimg handler 2019/01/09 14:33:29 [debug] 19834#0: *1 rewrite phase: 3 2019/01/09 14:33:29 [debug] 19834#0: *1 post rewrite phase: 4 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 5 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 6 2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 7 2019/01/09 14:33:29 [debug] 19834#0: *1 access phase: 8 2019/01/09 14:33:29 [debug] 19834#0: *1 post access phase: 9 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 10 2019/01/09 14:33:29 [debug] 19834#0: *1 generic phase: 11 2019/01/09 14:33:29 [debug] 19834#0: *1 http init upstream, client timer: 0 2019/01/09 14:33:29 [debug] 19834#0: *1 epoll add event: fd:17 op:3 ev:80002005 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "QUERY_STRING" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "QUERY_STRING: " 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_METHOD" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "GET" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_METHOD: GET" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_TYPE" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_TYPE: " 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CONTENT_LENGTH" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "CONTENT_LENGTH: " 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SCRIPT_NAME" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SCRIPT_NAME: /images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_URI" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/12/0/100/0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_URI: /images/12/0/100/0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_URI" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_URI: /images/21/12_0_100_0.jpg" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "DOCUMENT_ROOT" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "/var/www/html/static.ranchmed.com " 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "DOCUMENT_ROOT: /var/www/html/static.ranchmed.com " 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PROTOCOL" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "HTTP/1.0" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PROTOCOL: HTTP/1.0" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REQUEST_SCHEME" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "http" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REQUEST_SCHEME: http" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "GATEWAY_INTERFACE" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "CGI/1.1" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_SOFTWARE" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "nginx/" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "1.15.7" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_SOFTWARE: nginx/1.15.7" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_ADDR" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.1" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_ADDR: 192.168.1.1" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REMOTE_PORT" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "42034" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REMOTE_PORT: 42034" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_ADDR" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "192.168.1.101" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_ADDR: 192.168.1.101" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_PORT" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "80" 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_PORT: 80" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "SERVER_NAME" 2019/01/09 14:33:29 [debug] 19834#0: *1 http script var: "dev.static.ranchmed.com " 2019/01/09 14:33:29 [debug] 19835#0: accept() not ready (11: Resource temporarily unavailable) 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "SERVER_NAME: dev.static.ranchmed.com " 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "REDIRECT_STATUS" 2019/01/09 14:33:29 [debug] 19835#0: timer delta: 22583 2019/01/09 14:33:29 [debug] 19834#0: *1 http script copy: "200" 2019/01/09 14:33:29 [debug] 19835#0: worker cycle 2019/01/09 14:33:29 [debug] 19834#0: *1 fastcgi param: "REDIRECT_STATUS: 200" -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxim at nginx.com Thu Jan 10 08:30:44 2019 From: maxim at nginx.com (Maxim Konovalov) Date: Thu, 10 Jan 2019 11:30:44 +0300 Subject: cache: move open to thread pool In-Reply-To: References: <20180808181653.GX56558@mdounin.ru> <20180810113946.GG56558@mdounin.ru> <20180903160903.GI56558@mdounin.ru> <4ba7414a-0eba-6bd3-5a50-2eca591ac25e@nginx.com> Message-ID: <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> So guys, are you really interested in this work beyond shiny marketing blog posts? On 05/12/2018 12:43, Maxim Konovalov wrote: > Hello, > > just a reminder that we are looking for a tester for these patches. > > Thanks, > > Maxim > > On 16/11/2018 12:10, Maxim Konovalov wrote: >> Thanks, Ka-Hing, we'll wait for your feedback. >> >> On 16/11/2018 01:53, Ka-Hing Cheung wrote: >>> Hi, >>> >>> I didn't forget about this. I am pretty swamped at the moment and >>> there's a holiday freeze coming up. Will get to his in December. >>> >>> - Ka-Hing >>> >>> On Thu, Nov 8, 2018 at 6:19 AM Maxim Konovalov wrote: >>>> >>>> Hi Ka-Hing, >>>> >>>> would you mind to test Roman's most recent patches that add >>>> "aio_open" directive? >>>> >>>> http://mailman.nginx.org/pipermail/nginx-devel/2018-November/011538.html >>>> >>>> We are looking for overall performance and stability metrics and >>>> feedback. >>>> >>>> Much appreciated, >>>> >>>> Maxim >>>> >>>> -- >>>> Maxim Konovalov >> >> > > -- Maxim Konovalov From xeioex at nginx.com Thu Jan 10 13:08:39 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 13:08:39 +0000 Subject: [njs] Introduced njs_function_native_call(). Message-ID: details: https://hg.nginx.org/njs/rev/045ba10db769 branches: changeset: 716:045ba10db769 user: hongzhidao date: Mon Jan 07 22:14:17 2019 +0800 description: Introduced njs_function_native_call(). diffstat: njs/njs_function.c | 92 ++++++++++++++++++++++++++++++++++ njs/njs_function.h | 4 + njs/njs_vm.c | 140 ++++++---------------------------------------------- 3 files changed, 113 insertions(+), 123 deletions(-) diffs (304 lines): diff -r 0e7fc17f6071 -r 045ba10db769 njs/njs_function.c --- a/njs/njs_function.c Mon Jan 07 17:42:00 2019 +0800 +++ b/njs/njs_function.c Mon Jan 07 22:14:17 2019 +0800 @@ -531,6 +531,98 @@ njs_function_call(njs_vm_t *vm, njs_inde } +njs_ret_t +njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, + njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) +{ + njs_ret_t ret; + njs_value_t *value; + njs_function_t *function; + njs_native_frame_t *frame; + + ret = native(vm, args, nargs, retval); + + /* + * A native method can return: + * NXT_OK on method success; + * NJS_APPLIED by Function.apply() and Function.call(); + * NXT_AGAIN to postpone nJSVM processing; + * NXT_ERROR. + * + * The callee arguments must be preserved + * for NJS_APPLIED and NXT_AGAIN cases. + */ + if (ret == NXT_OK) { + frame = vm->top_frame; + + vm->top_frame = njs_function_previous_frame(frame); + njs_function_frame_free(vm, frame); + + /* + * If a retval is in a callee arguments scope it + * must be in the previous callee arguments scope. + */ + args = vm->top_frame->arguments; + function = vm->top_frame->function; + + if (function != NULL) { + args += function->args_offset; + } + + vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args; + + if (!frame->skip) { + value = njs_vmcode_operand(vm, retval); + /* + * GC: value external/internal++ depending + * on vm->retval and retval type + */ + *value = vm->retval; + } + + return NXT_OK; + } + + return ret; +} + + +njs_native_frame_t * +njs_function_previous_frame(njs_native_frame_t *frame) +{ + njs_native_frame_t *previous; + + do { + previous = frame->previous; + frame = previous; + + } while (frame->skip); + + return frame; +} + + +void +njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame) +{ + njs_native_frame_t *previous; + + do { + previous = frame->previous; + + /* GC: free frame->local, etc. */ + + if (frame->size != 0) { + vm->stack_size -= frame->size; + nxt_mem_cache_free(vm->mem_cache_pool, frame); + } + + frame = previous; + + } while (frame->skip); +} + + /* * The "prototype" property of user defined functions is created on * demand in private hash of the functions by the "prototype" getter. diff -r 0e7fc17f6071 -r 045ba10db769 njs/njs_function.h --- a/njs/njs_function.h Mon Jan 07 17:42:00 2019 +0800 +++ b/njs/njs_function.h Mon Jan 07 22:14:17 2019 +0800 @@ -171,6 +171,10 @@ njs_ret_t njs_function_frame(njs_vm_t *v const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor); njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance); +njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, + njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); +njs_native_frame_t *njs_function_previous_frame(njs_native_frame_t *frame); +void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame); extern const njs_object_init_t njs_function_constructor_init; extern const njs_object_init_t njs_function_prototype_init; diff -r 0e7fc17f6071 -r 045ba10db769 njs/njs_vm.c --- a/njs/njs_vm.c Mon Jan 07 17:42:00 2019 +0800 +++ b/njs/njs_vm.c Mon Jan 07 22:14:17 2019 +0800 @@ -36,10 +36,6 @@ static void njs_vm_scopes_restore(njs_vm njs_native_frame_t *previous); static njs_ret_t njs_vmcode_continuation(njs_vm_t *vm, njs_value_t *invld1, njs_value_t *invld2); -static njs_native_frame_t * - njs_function_previous_frame(njs_native_frame_t *frame); -static void njs_function_frame_free(njs_vm_t *vm, - njs_native_frame_t *frame); static void njs_vm_trap(njs_vm_t *vm, njs_trap_t trap, njs_value_t *value1, njs_value_t *value2); @@ -2064,52 +2060,19 @@ njs_vmcode_function_call(njs_vm_t *vm, n return 0; } - ret = function->u.native(vm, args, nargs, (njs_index_t) retval); - - /* - * A native method can return: - * NXT_OK on method success; - * NJS_APPLIED by Function.apply() and Function.call(); - * NXT_AGAIN to postpone nJSVM processing; - * NXT_ERROR. - * - * The callee arguments must be preserved - * for NJS_APPLIED and NXT_AGAIN cases. - */ - if (ret == NXT_OK) { - frame = vm->top_frame; - - vm->top_frame = njs_function_previous_frame(frame); - njs_function_frame_free(vm, frame); - - /* - * If a retval is in a callee arguments scope it - * must be in the previous callee arguments scope. - */ - args = vm->top_frame->arguments; - function = vm->top_frame->function; - - if (function != NULL) { - args += function->args_offset; - } - - vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args; - - retval = njs_vmcode_operand(vm, retval); - /* - * GC: value external/internal++ depending - * on vm->retval and retval type - */ - *retval = vm->retval; - - ret = sizeof(njs_vmcode_function_call_t); - - } else if (ret == NJS_APPLIED) { - /* A user-defined method has been prepared to run. */ - ret = 0; + ret = njs_function_native_call(vm, function->u.native, args, nargs, + (njs_index_t) retval); + + switch (ret) { + case NXT_OK: + return sizeof(njs_vmcode_function_call_t); + + case NJS_APPLIED: + return 0; + + default: + return ret; } - - return ret; } @@ -2467,60 +2430,27 @@ static njs_ret_t njs_vmcode_continuation(njs_vm_t *vm, njs_value_t *invld1, njs_value_t *invld2) { njs_ret_t ret; - nxt_bool_t skip; - njs_value_t *args, *retval; - njs_function_t *function; njs_native_frame_t *frame; njs_continuation_t *cont; cont = njs_vm_continuation(vm); frame = vm->top_frame; - args = frame->arguments; if (cont->args_types != NULL) { - ret = njs_normalize_args(vm, args, cont->args_types, frame->nargs); + ret = njs_normalize_args(vm, frame->arguments, cont->args_types, + frame->nargs); if (ret != NJS_OK) { return ret; } } - ret = cont->function(vm, args, frame->nargs, cont->retval); + ret = njs_function_native_call(vm, cont->function, frame->arguments, + frame->nargs, cont->retval); switch (ret) { - case NXT_OK: - - frame = vm->top_frame; - skip = frame->skip; - - vm->top_frame = njs_function_previous_frame(frame); - - /* - * If a retval is in a callee arguments scope it - * must be in the previous callee arguments scope. - */ - args = vm->top_frame->arguments; - function = vm->top_frame->function; - - if (function != NULL) { - args += function->args_offset; - } - - vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args; - - if (!skip) { - retval = njs_vmcode_operand(vm, cont->retval); - /* - * GC: value external/internal++ depending - * on vm->retval and retval type - */ - *retval = vm->retval; - } - vm->current = cont->return_address; - (void) njs_function_frame_free(vm, frame); - - return 0; + /* Fall through. */ case NJS_APPLIED: return 0; @@ -2531,42 +2461,6 @@ njs_vmcode_continuation(njs_vm_t *vm, nj } -static njs_native_frame_t * -njs_function_previous_frame(njs_native_frame_t *frame) -{ - njs_native_frame_t *previous; - - do { - previous = frame->previous; - frame = previous; - - } while (frame->skip); - - return frame; -} - - -static void -njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame) -{ - njs_native_frame_t *previous; - - do { - previous = frame->previous; - - /* GC: free frame->local, etc. */ - - if (frame->size != 0) { - vm->stack_size -= frame->size; - nxt_mem_cache_free(vm->mem_cache_pool, frame); - } - - frame = previous; - - } while (frame->skip); -} - - njs_ret_t njs_vmcode_stop(njs_vm_t *vm, njs_value_t *invld, njs_value_t *retval) { From mdounin at mdounin.ru Thu Jan 10 13:19:13 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 10 Jan 2019 16:19:13 +0300 Subject: Confusion about rewritten uri passed to a fastcgi program In-Reply-To: References: Message-ID: <20190110131913.GX99070@mdounin.ru> Hello! On Wed, Jan 09, 2019 at 03:05:22PM -0800, Mark Sellers wrote: > > My module (ngx_http_fastimg_module) rewrites the uri of an image request. If the image is not yet in the filesystem, then it (using try_files) calls a fastcgi (fastimg_fcgi) that creates the image, serves it, and saves it in the file system. > > I have noticed something that I don?t understand. When the fastcgi program is executed, it receives the original uri in the REQUEST_URI fastcgi param, and not the rewritten uri. > > I also notice that the rewritten uri is available in the DOCUMENT_URI fastcgi param. > > Is this what you would expect? What is sent in FastCGI parameters is determined by the fastcgi_param directives used in your configuration, see http://nginx.org/r/fastcgi_param. The example/default fastcgi_params file as shipped with nginx contains fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; so the REQUEST_URI param will get the original URI as sent by the client, and the rewritten URI will be available in DOCUMENT_URI, exactly as your observe. -- Maxim Dounin http://mdounin.ru/ From xeioex at nginx.com Thu Jan 10 14:31:00 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 14:31:00 +0000 Subject: [njs] Moving njs_normalize_args() into njs_function_native_call(). Message-ID: details: https://hg.nginx.org/njs/rev/0da53bc8472b branches: changeset: 717:0da53bc8472b user: hongzhidao date: Tue Jan 08 04:04:02 2019 +0800 description: Moving njs_normalize_args() into njs_function_native_call(). diffstat: njs/njs_function.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++- njs/njs_function.h | 3 +- njs/njs_vm.c | 155 +--------------------------------------------------- njs/njs_vm.h | 2 - 4 files changed, 150 insertions(+), 154 deletions(-) diffs (388 lines): diff -r 045ba10db769 -r 0da53bc8472b njs/njs_function.c --- a/njs/njs_function.c Mon Jan 07 22:14:17 2019 +0800 +++ b/njs/njs_function.c Tue Jan 08 04:04:02 2019 +0800 @@ -8,6 +8,8 @@ #include +static njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args, + uint8_t *args_types, nxt_uint_t nargs); static njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, njs_value_t *this, njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); @@ -533,13 +535,19 @@ njs_function_call(njs_vm_t *vm, njs_inde njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, - njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) + njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, + njs_index_t retval) { njs_ret_t ret; njs_value_t *value; njs_function_t *function; njs_native_frame_t *frame; + ret = njs_normalize_args(vm, args, args_types, nargs); + if (ret != NJS_OK) { + return ret; + } + ret = native(vm, args, nargs, retval); /* @@ -587,6 +595,140 @@ njs_function_native_call(njs_vm_t *vm, n } +static njs_ret_t +njs_normalize_args(njs_vm_t *vm, njs_value_t *args, uint8_t *args_types, + nxt_uint_t nargs) +{ + nxt_uint_t n; + njs_trap_t trap; + + n = nxt_min(nargs, NJS_ARGS_TYPES_MAX); + + while (n != 0) { + + switch (*args_types) { + + case NJS_STRING_OBJECT_ARG: + + if (njs_is_null_or_void(args)) { + goto type_error; + } + + /* Fall through. */ + + case NJS_STRING_ARG: + + if (njs_is_string(args)) { + break; + } + + trap = NJS_TRAP_STRING_ARG; + goto trap; + + case NJS_NUMBER_ARG: + + if (njs_is_numeric(args)) { + break; + } + + trap = NJS_TRAP_NUMBER_ARG; + goto trap; + + case NJS_INTEGER_ARG: + + if (njs_is_numeric(args)) { + + /* Numbers are truncated to fit in 32-bit integers. */ + + if (isnan(args->data.u.number)) { + args->data.u.number = 0; + + } else if (args->data.u.number > 2147483647.0) { + args->data.u.number = 2147483647.0; + + } else if (args->data.u.number < -2147483648.0) { + args->data.u.number = -2147483648.0; + } + + break; + } + + trap = NJS_TRAP_NUMBER_ARG; + goto trap; + + case NJS_FUNCTION_ARG: + + switch (args->type) { + case NJS_STRING: + case NJS_FUNCTION: + break; + + default: + trap = NJS_TRAP_STRING_ARG; + goto trap; + } + + break; + + case NJS_REGEXP_ARG: + + switch (args->type) { + case NJS_VOID: + case NJS_STRING: + case NJS_REGEXP: + break; + + default: + trap = NJS_TRAP_STRING_ARG; + goto trap; + } + + break; + + case NJS_DATE_ARG: + if (!njs_is_date(args)) { + goto type_error; + } + + break; + + case NJS_OBJECT_ARG: + + if (njs_is_null_or_void(args)) { + goto type_error; + } + + break; + + case NJS_SKIP_ARG: + break; + + case 0: + return NJS_OK; + } + + args++; + args_types++; + n--; + } + + return NJS_OK; + +trap: + + njs_vm_trap_value(vm, args); + + return njs_trap(vm, trap); + +type_error: + + njs_type_error(vm, "cannot convert %s to %s", njs_type_string(args->type), + njs_arg_type_string(*args_types)); + + return NXT_ERROR; +} + + njs_native_frame_t * njs_function_previous_frame(njs_native_frame_t *frame) { diff -r 045ba10db769 -r 0da53bc8472b njs/njs_function.h --- a/njs/njs_function.h Mon Jan 07 22:14:17 2019 +0800 +++ b/njs/njs_function.h Tue Jan 08 04:04:02 2019 +0800 @@ -172,7 +172,8 @@ njs_ret_t njs_function_frame(njs_vm_t *v nxt_bool_t ctor); njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance); njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, - njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); + njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, + njs_index_t retval); njs_native_frame_t *njs_function_previous_frame(njs_native_frame_t *frame); void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame); diff -r 045ba10db769 -r 0da53bc8472b njs/njs_vm.c --- a/njs/njs_vm.c Mon Jan 07 22:14:17 2019 +0800 +++ b/njs/njs_vm.c Tue Jan 08 04:04:02 2019 +0800 @@ -2042,11 +2042,6 @@ njs_vmcode_function_call(njs_vm_t *vm, n args = frame->arguments; nargs = frame->nargs; - ret = njs_normalize_args(vm, args, function->args_types, nargs); - if (ret != NJS_OK) { - return ret; - } - if (function->continuation_size != 0) { cont = njs_vm_continuation(vm); @@ -2060,7 +2055,8 @@ njs_vmcode_function_call(njs_vm_t *vm, n return 0; } - ret = njs_function_native_call(vm, function->u.native, args, nargs, + ret = njs_function_native_call(vm, function->u.native, args, + function->args_types, nargs, (njs_index_t) retval); switch (ret) { @@ -2076,140 +2072,6 @@ njs_vmcode_function_call(njs_vm_t *vm, n } -njs_ret_t -njs_normalize_args(njs_vm_t *vm, njs_value_t *args, uint8_t *args_types, - nxt_uint_t nargs) -{ - nxt_uint_t n; - njs_trap_t trap; - - n = nxt_min(nargs, NJS_ARGS_TYPES_MAX); - - while (n != 0) { - - switch (*args_types) { - - case NJS_STRING_OBJECT_ARG: - - if (njs_is_null_or_void(args)) { - goto type_error; - } - - /* Fall through. */ - - case NJS_STRING_ARG: - - if (njs_is_string(args)) { - break; - } - - trap = NJS_TRAP_STRING_ARG; - goto trap; - - case NJS_NUMBER_ARG: - - if (njs_is_numeric(args)) { - break; - } - - trap = NJS_TRAP_NUMBER_ARG; - goto trap; - - case NJS_INTEGER_ARG: - - if (njs_is_numeric(args)) { - - /* Numbers are truncated to fit in 32-bit integers. */ - - if (isnan(args->data.u.number)) { - args->data.u.number = 0; - - } else if (args->data.u.number > 2147483647.0) { - args->data.u.number = 2147483647.0; - - } else if (args->data.u.number < -2147483648.0) { - args->data.u.number = -2147483648.0; - } - - break; - } - - trap = NJS_TRAP_NUMBER_ARG; - goto trap; - - case NJS_FUNCTION_ARG: - - switch (args->type) { - case NJS_STRING: - case NJS_FUNCTION: - break; - - default: - trap = NJS_TRAP_STRING_ARG; - goto trap; - } - - break; - - case NJS_REGEXP_ARG: - - switch (args->type) { - case NJS_VOID: - case NJS_STRING: - case NJS_REGEXP: - break; - - default: - trap = NJS_TRAP_STRING_ARG; - goto trap; - } - - break; - - case NJS_DATE_ARG: - if (!njs_is_date(args)) { - goto type_error; - } - - break; - - case NJS_OBJECT_ARG: - - if (njs_is_null_or_void(args)) { - goto type_error; - } - - break; - - case NJS_SKIP_ARG: - break; - - case 0: - return NJS_OK; - } - - args++; - args_types++; - n--; - } - - return NJS_OK; - -trap: - - njs_vm_trap_value(vm, args); - - return njs_trap(vm, trap); - -type_error: - - njs_type_error(vm, "cannot convert %s to %s", njs_type_string(args->type), - njs_arg_type_string(*args_types)); - - return NXT_ERROR; -} - - const char * njs_type_string(njs_value_type_t type) { @@ -2433,19 +2295,12 @@ njs_vmcode_continuation(njs_vm_t *vm, nj njs_native_frame_t *frame; njs_continuation_t *cont; + frame = vm->top_frame; cont = njs_vm_continuation(vm); - frame = vm->top_frame; - - if (cont->args_types != NULL) { - ret = njs_normalize_args(vm, frame->arguments, cont->args_types, - frame->nargs); - if (ret != NJS_OK) { - return ret; - } - } ret = njs_function_native_call(vm, cont->function, frame->arguments, - frame->nargs, cont->retval); + cont->args_types, frame->nargs, + cont->retval); switch (ret) { case NXT_OK: diff -r 045ba10db769 -r 0da53bc8472b njs/njs_vm.h --- a/njs/njs_vm.h Mon Jan 07 22:14:17 2019 +0800 +++ b/njs/njs_vm.h Tue Jan 08 04:04:02 2019 +0800 @@ -1262,8 +1262,6 @@ njs_ret_t njs_vmcode_finally(njs_vm_t *v nxt_bool_t njs_values_strict_equal(const njs_value_t *val1, const njs_value_t *val2); -njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args, - uint8_t *args_types, nxt_uint_t nargs); const char *njs_type_string(njs_value_type_t type); const char *njs_arg_type_string(uint8_t arg); From xeioex at nginx.com Thu Jan 10 14:31:01 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 14:31:01 +0000 Subject: [njs] Inlined njs_function_previous_frame(). Message-ID: details: https://hg.nginx.org/njs/rev/57b89039ff23 branches: changeset: 718:57b89039ff23 user: Dmitry Volyntsev date: Thu Jan 10 17:30:30 2019 +0300 description: Inlined njs_function_previous_frame(). diffstat: njs/njs_function.c | 15 --------------- njs/njs_function.h | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 16 deletions(-) diffs (54 lines): diff -r 0da53bc8472b -r 57b89039ff23 njs/njs_function.c --- a/njs/njs_function.c Tue Jan 08 04:04:02 2019 +0800 +++ b/njs/njs_function.c Thu Jan 10 17:30:30 2019 +0300 @@ -729,21 +729,6 @@ type_error: } -njs_native_frame_t * -njs_function_previous_frame(njs_native_frame_t *frame) -{ - njs_native_frame_t *previous; - - do { - previous = frame->previous; - frame = previous; - - } while (frame->skip); - - return frame; -} - - void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame) { diff -r 0da53bc8472b -r 57b89039ff23 njs/njs_function.h --- a/njs/njs_function.h Tue Jan 08 04:04:02 2019 +0800 +++ b/njs/njs_function.h Thu Jan 10 17:30:30 2019 +0300 @@ -174,9 +174,24 @@ njs_ret_t njs_function_call(njs_vm_t *vm njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, njs_index_t retval); -njs_native_frame_t *njs_function_previous_frame(njs_native_frame_t *frame); void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame); + +nxt_inline njs_native_frame_t * +njs_function_previous_frame(njs_native_frame_t *frame) +{ + njs_native_frame_t *previous; + + do { + previous = frame->previous; + frame = previous; + + } while (frame->skip); + + return frame; +} + + extern const njs_object_init_t njs_function_constructor_init; extern const njs_object_init_t njs_function_prototype_init; From xeioex at nginx.com Thu Jan 10 16:00:52 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 16:00:52 +0000 Subject: [njs] Simplified njs_vm_call(). Message-ID: details: https://hg.nginx.org/njs/rev/5da4da7386a8 branches: changeset: 720:5da4da7386a8 user: hongzhidao date: Tue Jan 08 05:02:20 2019 +0800 description: Simplified njs_vm_call(). diffstat: njs/njs.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diffs (19 lines): diff -r 6ee587abd958 -r 5da4da7386a8 njs/njs.c --- a/njs/njs.c Tue Jan 08 04:11:51 2019 +0800 +++ b/njs/njs.c Tue Jan 08 05:02:20 2019 +0800 @@ -479,14 +479,10 @@ njs_vm_call(njs_vm_t *vm, njs_function_t return ret; } - ret = njs_vmcode_interpreter(vm); + ret = njs_vm_start(vm); vm->current = current; - if (ret == NJS_STOP) { - ret = NXT_OK; - } - return ret; } From xeioex at nginx.com Thu Jan 10 16:00:51 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 16:00:51 +0000 Subject: [njs] Making njs_function_activate() more generic. Message-ID: details: https://hg.nginx.org/njs/rev/6ee587abd958 branches: changeset: 719:6ee587abd958 user: hongzhidao date: Tue Jan 08 04:11:51 2019 +0800 description: Making njs_function_activate() more generic. diffstat: njs/njs.c | 46 +++++++++------------------------------------- njs/njs_function.c | 43 ++++++++++++++++++++++++++++--------------- njs/njs_function.h | 3 +++ njs/njs_vm.c | 7 ++++++- njs/njs_vm.h | 2 +- 5 files changed, 47 insertions(+), 54 deletions(-) diffs (213 lines): diff -r 57b89039ff23 -r 6ee587abd958 njs/njs.c --- a/njs/njs.c Thu Jan 10 17:30:30 2019 +0300 +++ b/njs/njs.c Tue Jan 08 04:11:51 2019 +0800 @@ -461,50 +461,22 @@ nxt_int_t njs_vm_call(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, nxt_uint_t nargs) { - u_char *current; - njs_ret_t ret; - njs_value_t *this; - njs_continuation_t *cont; - - static const njs_vmcode_stop_t stop[] = { - { .code = { .operation = njs_vmcode_stop, - .operands = NJS_VMCODE_1OPERAND, - .retval = NJS_VMCODE_NO_RETVAL }, - .retval = NJS_INDEX_GLOBAL_RETVAL }, - }; + u_char *current; + njs_ret_t ret; + njs_value_t *this; this = (njs_value_t *) &njs_value_void; current = vm->current; - if (function->native) { - ret = njs_function_native_frame(vm, function, this, &args[0], - nargs, NJS_CONTINUATION_SIZE, 0); - if (ret != NJS_OK) { - return NJS_ERROR; - } - - cont = njs_vm_continuation(vm); - - cont->function = function->u.native; - cont->args_types = function->args_types; - cont->retval = NJS_INDEX_GLOBAL_RETVAL; + vm->current = (u_char *) njs_continuation_nexus; - cont->return_address = (u_char *) stop; - vm->current = (u_char *) njs_continuation_nexus; + ret = njs_function_activate(vm, function, this, args, nargs, + NJS_INDEX_GLOBAL_RETVAL, + sizeof(njs_vmcode_generic_t)); - } else { - ret = njs_function_frame(vm, function, this, args, nargs, 0); - if (nxt_slow_path(ret != NXT_OK)) { - return ret; - } - - vm->current = (u_char *) stop; - - ret = njs_function_call(vm, NJS_INDEX_GLOBAL_RETVAL, 0); - if (nxt_slow_path(ret == NXT_ERROR)) { - return ret; - } + if (nxt_slow_path(ret == NXT_ERROR)) { + return ret; } ret = njs_vmcode_interpreter(vm); diff -r 57b89039ff23 -r 6ee587abd958 njs/njs_function.c --- a/njs/njs_function.c Thu Jan 10 17:30:30 2019 +0300 +++ b/njs/njs_function.c Tue Jan 08 04:11:51 2019 +0800 @@ -10,8 +10,6 @@ static njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs); -static njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, - njs_value_t *this, njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); njs_function_t * @@ -897,6 +895,7 @@ static njs_ret_t njs_function_prototype_call(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) { + njs_ret_t ret; njs_value_t *this; njs_function_t *function; @@ -916,7 +915,16 @@ njs_function_prototype_call(njs_vm_t *vm function = args[0].data.u.function; - return njs_function_activate(vm, function, this, &args[2], nargs, retval); + ret = njs_function_activate(vm, function, this, &args[2], nargs, retval, + sizeof(njs_vmcode_function_call_t)); + if (nxt_slow_path(ret == NXT_ERROR)) { + return ret; + } + + /* Skip the "call" method frame. */ + vm->top_frame->previous->skip = 1; + + return NJS_APPLIED; } @@ -924,6 +932,7 @@ static njs_ret_t njs_function_prototype_apply(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) { + njs_ret_t ret; njs_array_t *array; njs_value_t *this; njs_function_t *function; @@ -954,13 +963,24 @@ njs_function_prototype_apply(njs_vm_t *v nargs = 0; } - return njs_function_activate(vm, function, this, args, nargs, retval); + ret = njs_function_activate(vm, function, this, args, nargs, retval, + sizeof(njs_vmcode_function_call_t)); + + if (nxt_slow_path(ret == NXT_ERROR)) { + return ret; + } + + /* Skip the "apply" method frame. */ + vm->top_frame->previous->skip = 1; + + return NJS_APPLIED; } -static njs_ret_t +njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, njs_value_t *this, - njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) + const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, + size_t advance) { njs_ret_t ret; njs_continuation_t *cont; @@ -972,17 +992,13 @@ njs_function_activate(njs_vm_t *vm, njs_ return ret; } - /* Skip the "call/apply" method frame. */ - vm->top_frame->previous->skip = 1; - cont = njs_vm_continuation(vm); cont->function = function->u.native; cont->args_types = function->args_types; cont->retval = retval; - cont->return_address = vm->current - + sizeof(njs_vmcode_function_call_t); + cont->return_address = vm->current + advance; vm->current = (u_char *) njs_continuation_nexus; return NJS_APPLIED; @@ -994,10 +1010,7 @@ njs_function_activate(njs_vm_t *vm, njs_ return ret; } - /* Skip the "call/apply" method frame. */ - vm->top_frame->previous->skip = 1; - - return njs_function_call(vm, retval, sizeof(njs_vmcode_function_call_t)); + return njs_function_call(vm, retval, advance); } diff -r 57b89039ff23 -r 6ee587abd958 njs/njs_function.h --- a/njs/njs_function.h Thu Jan 10 17:30:30 2019 +0300 +++ b/njs/njs_function.h Tue Jan 08 04:11:51 2019 +0800 @@ -170,6 +170,9 @@ njs_ret_t njs_function_native_frame(njs_ njs_ret_t njs_function_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor); +njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, + njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, + njs_index_t retval, size_t advance); njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance); njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, diff -r 57b89039ff23 -r 6ee587abd958 njs/njs_vm.c --- a/njs/njs_vm.c Thu Jan 10 17:30:30 2019 +0300 +++ b/njs/njs_vm.c Tue Jan 08 04:11:51 2019 +0800 @@ -2281,10 +2281,15 @@ njs_vm_scopes_restore(njs_vm_t *vm, njs_ } -const njs_vmcode_1addr_t njs_continuation_nexus[] = { +const njs_vmcode_generic_t njs_continuation_nexus[] = { { .code = { .operation = njs_vmcode_continuation, .operands = NJS_VMCODE_NO_OPERAND, .retval = NJS_VMCODE_NO_RETVAL } }, + + { .code = { .operation = njs_vmcode_stop, + .operands = NJS_VMCODE_1OPERAND, + .retval = NJS_VMCODE_NO_RETVAL }, + .operand1 = NJS_INDEX_GLOBAL_RETVAL }, }; diff -r 57b89039ff23 -r 6ee587abd958 njs/njs_vm.h --- a/njs/njs_vm.h Thu Jan 10 17:30:30 2019 +0300 +++ b/njs/njs_vm.h Tue Jan 08 04:11:51 2019 +0800 @@ -1304,7 +1304,7 @@ extern const njs_value_t njs_string_mem extern const nxt_mem_proto_t njs_array_mem_proto; extern const nxt_lvlhsh_proto_t njs_object_hash_proto; -extern const njs_vmcode_1addr_t njs_continuation_nexus[]; +extern const njs_vmcode_generic_t njs_continuation_nexus[]; #endif /* _NJS_VM_H_INCLUDED_ */ From xeioex at nginx.com Thu Jan 10 16:00:52 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 16:00:52 +0000 Subject: [njs] Fixed njs_vm_call(). Message-ID: details: https://hg.nginx.org/njs/rev/d357ff6b4fe3 branches: changeset: 721:d357ff6b4fe3 user: hongzhidao date: Tue Jan 08 06:14:36 2019 +0800 description: Fixed njs_vm_call(). diffstat: njs/njs.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diffs (18 lines): diff -r 5da4da7386a8 -r d357ff6b4fe3 njs/njs.c --- a/njs/njs.c Tue Jan 08 05:02:20 2019 +0800 +++ b/njs/njs.c Tue Jan 08 06:14:36 2019 +0800 @@ -475,12 +475,10 @@ njs_vm_call(njs_vm_t *vm, njs_function_t NJS_INDEX_GLOBAL_RETVAL, sizeof(njs_vmcode_generic_t)); - if (nxt_slow_path(ret == NXT_ERROR)) { - return ret; + if (nxt_fast_path(ret == NJS_APPLIED)) { + ret = njs_vm_start(vm); } - ret = njs_vm_start(vm); - vm->current = current; return ret; From xeioex at nginx.com Thu Jan 10 16:00:52 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 16:00:52 +0000 Subject: [njs] Refactored out njs_function_apply(). Message-ID: details: https://hg.nginx.org/njs/rev/7029ec713458 branches: changeset: 722:7029ec713458 user: hongzhidao date: Tue Jan 08 06:14:36 2019 +0800 description: Refactored out njs_function_apply(). As a variant of njs_function_activate(). diffstat: njs/njs_function.c | 42 +++--------------------------------------- njs/njs_function.h | 13 ++++++++++--- 2 files changed, 13 insertions(+), 42 deletions(-) diffs (96 lines): diff -r d357ff6b4fe3 -r 7029ec713458 njs/njs_function.c --- a/njs/njs_function.c Tue Jan 08 06:14:36 2019 +0800 +++ b/njs/njs_function.c Tue Jan 08 06:14:36 2019 +0800 @@ -393,42 +393,6 @@ njs_function_frame_alloc(njs_vm_t *vm, s nxt_noinline njs_ret_t -njs_function_apply(njs_vm_t *vm, njs_function_t *function, njs_value_t *args, - nxt_uint_t nargs, njs_index_t retval) -{ - njs_ret_t ret; - njs_continuation_t *cont; - - if (function->native) { - ret = njs_function_native_frame(vm, function, &args[0], &args[1], - nargs - 1, NJS_CONTINUATION_SIZE, 0); - if (ret != NJS_OK) { - return ret; - } - - cont = njs_vm_continuation(vm); - - cont->function = function->u.native; - cont->args_types = function->args_types; - cont->retval = retval; - - cont->return_address = vm->current; - vm->current = (u_char *) njs_continuation_nexus; - - return NJS_APPLIED; - } - - ret = njs_function_frame(vm, function, &args[0], &args[1], nargs - 1, 0); - - if (nxt_fast_path(ret == NXT_OK)) { - return njs_function_call(vm, retval, 0); - } - - return ret; -} - - -nxt_noinline njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance) { size_t size; @@ -978,9 +942,9 @@ njs_function_prototype_apply(njs_vm_t *v njs_ret_t -njs_function_activate(njs_vm_t *vm, njs_function_t *function, njs_value_t *this, - const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, - size_t advance) +njs_function_activate(njs_vm_t *vm, njs_function_t *function, + const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, + njs_index_t retval, size_t advance) { njs_ret_t ret; njs_continuation_t *cont; diff -r d357ff6b4fe3 -r 7029ec713458 njs/njs_function.h --- a/njs/njs_function.h Tue Jan 08 06:14:36 2019 +0800 +++ b/njs/njs_function.h Tue Jan 08 06:14:36 2019 +0800 @@ -162,8 +162,6 @@ njs_value_t *njs_function_property_proto njs_value_t *value); njs_ret_t njs_function_constructor(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused); -njs_ret_t njs_function_apply(njs_vm_t *vm, njs_function_t *function, - njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); njs_ret_t njs_function_native_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, size_t reserve, nxt_bool_t ctor); @@ -171,7 +169,7 @@ njs_ret_t njs_function_frame(njs_vm_t *v const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor); njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, - njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, + const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, size_t advance); njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance); njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, @@ -180,6 +178,15 @@ njs_ret_t njs_function_native_call(njs_v void njs_function_frame_free(njs_vm_t *vm, njs_native_frame_t *frame); +nxt_inline njs_ret_t +njs_function_apply(njs_vm_t *vm, njs_function_t *function, + const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) +{ + return njs_function_activate(vm, function, &args[0], &args[1], nargs - 1, + retval, 0); +} + + nxt_inline njs_native_frame_t * njs_function_previous_frame(njs_native_frame_t *frame) { From xeioex at nginx.com Thu Jan 10 17:25:02 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 17:25:02 +0000 Subject: [njs] Introduced njs_function_frame(). Message-ID: details: https://hg.nginx.org/njs/rev/f62736ecfa8f branches: changeset: 724:f62736ecfa8f user: hongzhidao date: Tue Jan 08 08:41:40 2019 +0800 description: Introduced njs_function_frame(). diffstat: njs/njs_function.h | 15 +++++++++++++++ njs/njs_vm.c | 25 ++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diffs (69 lines): diff -r ecf08b8a7dbe -r f62736ecfa8f njs/njs_function.h --- a/njs/njs_function.h Tue Jan 08 07:04:24 2019 +0800 +++ b/njs/njs_function.h Tue Jan 08 08:41:40 2019 +0800 @@ -180,6 +180,21 @@ void njs_function_frame_free(njs_vm_t *v nxt_inline njs_ret_t +njs_function_frame(njs_vm_t *vm, njs_function_t *function, + const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, + size_t reserve, nxt_bool_t ctor) +{ + if (function->native) { + return njs_function_native_frame(vm, function, this, args, nargs, + reserve, ctor); + + } else { + return njs_function_lambda_frame(vm, function, this, args, nargs, ctor); + } +} + + +nxt_inline njs_ret_t njs_function_apply(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval) { diff -r ecf08b8a7dbe -r f62736ecfa8f njs/njs_vm.c --- a/njs/njs_vm.c Tue Jan 08 07:04:24 2019 +0800 +++ b/njs/njs_vm.c Tue Jan 08 08:41:40 2019 +0800 @@ -1864,9 +1864,15 @@ njs_function_frame_create(njs_vm_t *vm, function = value->data.u.function; - if (!function->native) { - - if (ctor) { + if (ctor) { + if (function->native) { + if (!function->ctor) { + njs_type_error(vm, "%s is not a constructor", + njs_type_string(value->type)); + return NXT_ERROR; + } + + } else { object = njs_function_new_object(vm, value); if (nxt_slow_path(object == NULL)) { return NXT_ERROR; @@ -1877,20 +1883,9 @@ njs_function_frame_create(njs_vm_t *vm, val.data.truth = 1; this = &val; } - - return njs_function_lambda_frame(vm, function, this, NULL, - nargs, ctor); } - if (!ctor || function->ctor) { - return njs_function_native_frame(vm, function, this, NULL, - nargs, 0, ctor); - } - - njs_type_error(vm, "%s is not a constructor", - njs_type_string(value->type)); - - return NXT_ERROR; + return njs_function_frame(vm, function, this, NULL, nargs, 0, ctor); } njs_type_error(vm, "%s is not a function", njs_type_string(value->type)); From xeioex at nginx.com Thu Jan 10 17:25:02 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 17:25:02 +0000 Subject: [njs] Renamed functions related to lambda. Message-ID: details: https://hg.nginx.org/njs/rev/ecf08b8a7dbe branches: changeset: 723:ecf08b8a7dbe user: hongzhidao date: Tue Jan 08 07:04:24 2019 +0800 description: Renamed functions related to lambda. diffstat: njs/njs_function.c | 8 ++++---- njs/njs_function.h | 5 +++-- njs/njs_vm.c | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diffs (81 lines): diff -r 7029ec713458 -r ecf08b8a7dbe njs/njs_function.c --- a/njs/njs_function.c Tue Jan 08 06:14:36 2019 +0800 +++ b/njs/njs_function.c Tue Jan 08 07:04:24 2019 +0800 @@ -266,7 +266,7 @@ njs_function_native_frame(njs_vm_t *vm, nxt_noinline njs_ret_t -njs_function_frame(njs_vm_t *vm, njs_function_t *function, +njs_function_lambda_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor) { @@ -393,7 +393,7 @@ njs_function_frame_alloc(njs_vm_t *vm, s nxt_noinline njs_ret_t -njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance) +njs_function_lambda_call(njs_vm_t *vm, njs_index_t retval, size_t advance) { size_t size; njs_ret_t ret; @@ -968,13 +968,13 @@ njs_function_activate(njs_vm_t *vm, njs_ return NJS_APPLIED; } - ret = njs_function_frame(vm, function, this, args, nargs, 0); + ret = njs_function_lambda_frame(vm, function, this, args, nargs, 0); if (nxt_slow_path(ret != NXT_OK)) { return ret; } - return njs_function_call(vm, retval, advance); + return njs_function_lambda_call(vm, retval, advance); } diff -r 7029ec713458 -r ecf08b8a7dbe njs/njs_function.h --- a/njs/njs_function.h Tue Jan 08 06:14:36 2019 +0800 +++ b/njs/njs_function.h Tue Jan 08 07:04:24 2019 +0800 @@ -165,13 +165,14 @@ njs_ret_t njs_function_constructor(njs_v njs_ret_t njs_function_native_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, size_t reserve, nxt_bool_t ctor); -njs_ret_t njs_function_frame(njs_vm_t *vm, njs_function_t *function, +njs_ret_t njs_function_lambda_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor); njs_ret_t njs_function_activate(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, size_t advance); -njs_ret_t njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance); +njs_ret_t njs_function_lambda_call(njs_vm_t *vm, njs_index_t retval, + size_t advance); njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, njs_index_t retval); diff -r 7029ec713458 -r ecf08b8a7dbe njs/njs_vm.c --- a/njs/njs_vm.c Tue Jan 08 06:14:36 2019 +0800 +++ b/njs/njs_vm.c Tue Jan 08 07:04:24 2019 +0800 @@ -1878,7 +1878,8 @@ njs_function_frame_create(njs_vm_t *vm, this = &val; } - return njs_function_frame(vm, function, this, NULL, nargs, ctor); + return njs_function_lambda_frame(vm, function, this, NULL, + nargs, ctor); } if (!ctor || function->ctor) { @@ -2029,8 +2030,8 @@ njs_vmcode_function_call(njs_vm_t *vm, n function = frame->function; if (!function->native) { - ret = njs_function_call(vm, (njs_index_t) retval, - sizeof(njs_vmcode_function_call_t)); + ret = njs_function_lambda_call(vm, (njs_index_t) retval, + sizeof(njs_vmcode_function_call_t)); if (nxt_fast_path(ret != NJS_ERROR)) { return 0; From xeioex at nginx.com Thu Jan 10 17:25:02 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 10 Jan 2019 17:25:02 +0000 Subject: [njs] Making njs_function_frame_alloc() static. Message-ID: details: https://hg.nginx.org/njs/rev/112bd230858c branches: changeset: 725:112bd230858c user: Dmitry Volyntsev date: Thu Jan 10 20:18:27 2019 +0300 description: Making njs_function_frame_alloc() static. diffstat: njs/njs_function.c | 1 + njs/njs_function.h | 1 - 2 files changed, 1 insertions(+), 1 deletions(-) diffs (22 lines): diff -r f62736ecfa8f -r 112bd230858c njs/njs_function.c --- a/njs/njs_function.c Tue Jan 08 08:41:40 2019 +0800 +++ b/njs/njs_function.c Thu Jan 10 20:18:27 2019 +0300 @@ -8,6 +8,7 @@ #include +static njs_native_frame_t *njs_function_frame_alloc(njs_vm_t *vm, size_t size); static njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs); diff -r f62736ecfa8f -r 112bd230858c njs/njs_function.h --- a/njs/njs_function.h Tue Jan 08 08:41:40 2019 +0800 +++ b/njs/njs_function.h Thu Jan 10 20:18:27 2019 +0300 @@ -149,7 +149,6 @@ struct njs_frame_s { njs_function_t *njs_function_alloc(njs_vm_t *vm); njs_function_t *njs_function_value_copy(njs_vm_t *vm, njs_value_t *value); -njs_native_frame_t *njs_function_frame_alloc(njs_vm_t *vm, size_t size); njs_ret_t njs_function_arguments_object_init(njs_vm_t *vm, njs_native_frame_t *frame); njs_ret_t njs_function_rest_parameters_init(njs_vm_t *vm, From xeioex at nginx.com Fri Jan 11 16:20:29 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Fri, 11 Jan 2019 16:20:29 +0000 Subject: [njs] Improved an argument name of njs_function_frame(). Message-ID: details: https://hg.nginx.org/njs/rev/fb2c2bca61c2 branches: changeset: 727:fb2c2bca61c2 user: hongzhidao date: Fri Jan 11 19:20:38 2019 +0800 description: Improved an argument name of njs_function_frame(). diffstat: njs/njs_function.c | 8 ++++---- njs/njs_function.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diffs (58 lines): diff -r 8fb687d866de -r fb2c2bca61c2 njs/njs_function.c --- a/njs/njs_function.c Fri Jan 11 18:57:57 2019 +0800 +++ b/njs/njs_function.c Fri Jan 11 19:20:38 2019 +0800 @@ -216,16 +216,16 @@ njs_function_arguments_thrower(njs_vm_t njs_ret_t njs_function_native_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, - size_t reserve, nxt_bool_t ctor) + size_t continuation_size, nxt_bool_t ctor) { size_t size; nxt_uint_t n; njs_value_t *value, *bound; njs_native_frame_t *frame; - reserve = nxt_max(reserve, function->continuation_size); + continuation_size = nxt_max(continuation_size, function->continuation_size); - size = NJS_NATIVE_FRAME_SIZE + reserve + size = NJS_NATIVE_FRAME_SIZE + continuation_size + (function->args_offset + nargs) * sizeof(njs_value_t); frame = njs_function_frame_alloc(vm, size); @@ -237,7 +237,7 @@ njs_function_native_frame(njs_vm_t *vm, frame->nargs = function->args_offset + nargs; frame->ctor = ctor; - value = (njs_value_t *) (njs_continuation(frame) + reserve); + value = (njs_value_t *) (njs_continuation(frame) + continuation_size); frame->arguments = value; bound = function->bound; diff -r 8fb687d866de -r fb2c2bca61c2 njs/njs_function.h --- a/njs/njs_function.h Fri Jan 11 18:57:57 2019 +0800 +++ b/njs/njs_function.h Fri Jan 11 19:20:38 2019 +0800 @@ -163,7 +163,7 @@ njs_ret_t njs_function_constructor(njs_v nxt_uint_t nargs, njs_index_t unused); njs_ret_t njs_function_native_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, - size_t reserve, nxt_bool_t ctor); + size_t continuation_size, nxt_bool_t ctor); njs_ret_t njs_function_lambda_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, nxt_bool_t ctor); @@ -181,11 +181,11 @@ void njs_function_frame_free(njs_vm_t *v nxt_inline njs_ret_t njs_function_frame(njs_vm_t *vm, njs_function_t *function, const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, - size_t reserve, nxt_bool_t ctor) + size_t continuation_size, nxt_bool_t ctor) { if (function->native) { return njs_function_native_frame(vm, function, this, args, nargs, - reserve, ctor); + continuation_size, ctor); } else { return njs_function_lambda_frame(vm, function, this, args, nargs, ctor); From xeioex at nginx.com Fri Jan 11 16:20:28 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Fri, 11 Jan 2019 16:20:28 +0000 Subject: [njs] Refactored njs_function_lambda_call(). Message-ID: details: https://hg.nginx.org/njs/rev/8fb687d866de branches: changeset: 726:8fb687d866de user: hongzhidao date: Fri Jan 11 18:57:57 2019 +0800 description: Refactored njs_function_lambda_call(). diffstat: njs/njs_function.c | 35 +++++++++++++++++---------------- njs/njs_function.h | 2 +- njs/njs_vm.c | 55 ++++++++++++++++++++++++----------------------------- 3 files changed, 44 insertions(+), 48 deletions(-) diffs (163 lines): diff -r 112bd230858c -r 8fb687d866de njs/njs_function.c --- a/njs/njs_function.c Thu Jan 10 20:18:27 2019 +0300 +++ b/njs/njs_function.c Fri Jan 11 18:57:57 2019 +0800 @@ -394,7 +394,8 @@ njs_function_frame_alloc(njs_vm_t *vm, s nxt_noinline njs_ret_t -njs_function_lambda_call(njs_vm_t *vm, njs_index_t retval, size_t advance) +njs_function_lambda_call(njs_vm_t *vm, njs_index_t retval, + u_char *return_address) { size_t size; njs_ret_t ret; @@ -408,9 +409,9 @@ njs_function_lambda_call(njs_vm_t *vm, n frame = (njs_frame_t *) vm->top_frame; frame->retval = retval; + frame->return_address = return_address; function = frame->native.function; - frame->return_address = vm->current + advance; lambda = function->u.lambda; vm->current = lambda->start; @@ -947,35 +948,35 @@ njs_function_activate(njs_vm_t *vm, njs_ const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, size_t advance) { + u_char *return_address; njs_ret_t ret; njs_continuation_t *cont; + ret = njs_function_frame(vm, function, this, args, nargs, + NJS_CONTINUATION_SIZE, 0); + if (nxt_slow_path(ret != NXT_OK)) { + return ret; + } + + return_address = vm->current + advance; + if (function->native) { - ret = njs_function_native_frame(vm, function, this, args, nargs, - NJS_CONTINUATION_SIZE, 0); - if (nxt_slow_path(ret != NXT_OK)) { - return ret; - } - cont = njs_vm_continuation(vm); cont->function = function->u.native; cont->args_types = function->args_types; cont->retval = retval; + cont->return_address = return_address; - cont->return_address = vm->current + advance; vm->current = (u_char *) njs_continuation_nexus; - return NJS_APPLIED; + ret = NJS_APPLIED; + + } else { + ret = njs_function_lambda_call(vm, retval, return_address); } - ret = njs_function_lambda_frame(vm, function, this, args, nargs, 0); - - if (nxt_slow_path(ret != NXT_OK)) { - return ret; - } - - return njs_function_lambda_call(vm, retval, advance); + return ret; } diff -r 112bd230858c -r 8fb687d866de njs/njs_function.h --- a/njs/njs_function.h Thu Jan 10 20:18:27 2019 +0300 +++ b/njs/njs_function.h Fri Jan 11 18:57:57 2019 +0800 @@ -171,7 +171,7 @@ njs_ret_t njs_function_activate(njs_vm_t const njs_value_t *this, const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval, size_t advance); njs_ret_t njs_function_lambda_call(njs_vm_t *vm, njs_index_t retval, - size_t advance); + u_char *return_address); njs_ret_t njs_function_native_call(njs_vm_t *vm, njs_function_native_t native, njs_value_t *args, uint8_t *args_types, nxt_uint_t nargs, njs_index_t retval); diff -r 112bd230858c -r 8fb687d866de njs/njs_vm.c --- a/njs/njs_vm.c Thu Jan 10 20:18:27 2019 +0300 +++ b/njs/njs_vm.c Fri Jan 11 18:57:57 2019 +0800 @@ -2014,9 +2014,8 @@ njs_vmcode_method_frame(njs_vm_t *vm, nj njs_ret_t njs_vmcode_function_call(njs_vm_t *vm, njs_value_t *invld, njs_value_t *retval) { + u_char *return_address; njs_ret_t ret; - nxt_uint_t nargs; - njs_value_t *args; njs_function_t *function; njs_continuation_t *cont; njs_native_frame_t *frame; @@ -2024,37 +2023,33 @@ njs_vmcode_function_call(njs_vm_t *vm, n frame = vm->top_frame; function = frame->function; - if (!function->native) { + return_address = vm->current + sizeof(njs_vmcode_function_call_t); + + if (function->native) { + if (function->continuation_size != 0) { + cont = njs_vm_continuation(vm); + + cont->function = function->u.native; + cont->args_types = function->args_types; + cont->retval = (njs_index_t) retval; + cont->return_address = return_address; + + vm->current = (u_char *) njs_continuation_nexus; + + ret = NJS_APPLIED; + + } else { + ret = njs_function_native_call(vm, function->u.native, + frame->arguments, + function->args_types, frame->nargs, + (njs_index_t) retval); + } + + } else { ret = njs_function_lambda_call(vm, (njs_index_t) retval, - sizeof(njs_vmcode_function_call_t)); - - if (nxt_fast_path(ret != NJS_ERROR)) { - return 0; - } - - return ret; + return_address); } - args = frame->arguments; - nargs = frame->nargs; - - if (function->continuation_size != 0) { - cont = njs_vm_continuation(vm); - - cont->function = function->u.native; - cont->args_types = function->args_types; - cont->retval = (njs_index_t) retval; - - cont->return_address = vm->current + sizeof(njs_vmcode_function_call_t); - vm->current = (u_char *) njs_continuation_nexus; - - return 0; - } - - ret = njs_function_native_call(vm, function->u.native, args, - function->args_types, nargs, - (njs_index_t) retval); - switch (ret) { case NXT_OK: return sizeof(njs_vmcode_function_call_t); From msellers at ranchmed.com Mon Jan 14 16:33:23 2019 From: msellers at ranchmed.com (Mark Sellers) Date: Mon, 14 Jan 2019 08:33:23 -0800 Subject: Interaction between ngx module and fastcgi program Message-ID: <9484113F-2F71-49F6-BAA1-3F3A8E8F77AF@ranchmed.com> Thanks for your great feedback. It is truly appreciated. I am finalizing a simple nginx module, that does a uri rewrite. I have tested it, and the rewrite is working fine for files that exist on the server. A second component of my system is a fastcgi program (written in C) that, upon execution using the try_files named location. This fastcgi program has been tested, and works fine, by itself. My problem comes when both the module and fastcgi program are working together. Something in the combined environment is causing a malfunction. Could you please take a look at the annotated debug outputs, and suggest an approach to find the issue, and fix it? Please refer to below and see my notes offset to the left of the listing: Debug log with module and fastcgi both operating (I removed the first two columns of the debut output to provide a better fit on this page: [debug] 20594#0: *1 event timer del: 19: 556031347 [debug] 20594#0: *1 rewrite phase: 0 [debug] 20594#0: *1 test location: "/" [debug] 20594#0: *1 test location: "images/" [debug] 20594#0: *1 using configuration "/images/" [debug] 20594#0: *1 http cl:-1 max:104857600 [debug] 20594#0: *1 rewrite phase: 2 [debug] 20594#0: *1 fastimg handler <- My module [debug] 20594#0: *1 ngx_http_fastimg_rewrite() uri in: "/images/12/255/0/0.jpg? <- Input uri [debug] 20594#0: *1 ngx_http_fastimg_rewrite() uri out: "/images/21/12_255_0_0.jpg? <- Output uri (rewritten) [debug] 20594#0: *1 internal redirect: "/images/21/12_255_0_0.jpg?? <- Internal redirect using ngx_http_internal_redirect(r, &uri, NULL) [debug] 20594#0: *1 rewrite phase: 0 [debug] 20594#0: *1 test location: "/" [debug] 20594#0: *1 test location: "images/" [debug] 20594#0: *1 using configuration "/images/? <- Config location is ?/images/" [debug] 20594#0: *1 http cl:-1 max:104857600 [debug] 20594#0: *1 rewrite phase: 2 [debug] 20594#0: *1 fastimg handler [debug] 20594#0: *1 rewrite phase: 3 [debug] 20594#0: *1 post rewrite phase: 4 [debug] 20594#0: *1 generic phase: 5 [debug] 20594#0: *1 generic phase: 6 [debug] 20594#0: *1 access phase: 7 [debug] 20594#0: *1 access phase: 8 [debug] 20594#0: *1 post access phase: 9 [debug] 20594#0: *1 generic phase: 10 [debug] 20594#0: *1 try files handler <- Try files can?t find the image in the filesystem [debug] 20594#0: *1 http script var: "/images/21/12_255_0_0.jpg" [debug] 20594#0: *1 trying to use file: "/images/21/12_255_0_0.jpg" "/var/www/html/static.ranchmed.com/images/21/12_255_0_0.jpg" [debug] 20594#0: *1 trying to use file: "@fastimg_fcgi" "/var/www/html/static.ranchmed.com at fastimg_fcgi" [debug] 20594#0: *1 test location: "@fastimg_fcgi" [debug] 20594#0: *1 using location: @fastimg_fcgi "/images/21/12_255_0_0.jpg?? <- And executes my fastimg_fcgi program [debug] 20594#0: *1 rewrite phase: 2 [debug] 20594#0: *1 rewrite phase: 3 [debug] 20594#0: *1 post rewrite phase: 4 [debug] 20594#0: *1 generic phase: 5 [debug] 20594#0: *1 generic phase: 6 [debug] 20594#0: *1 access phase: 7 [debug] 20594#0: *1 access phase: 8 [debug] 20594#0: *1 post access phase: 9 [debug] 20594#0: *1 generic phase: 10 [debug] 20594#0: *1 generic phase: 11 [debug] 20594#0: *1 http init upstream, client timer: 0 [debug] 20594#0: *1 epoll add event: fd:19 op:3 ev:80002005 [debug] 20594#0: *1 http script copy: ?QUERY_STRING? <- Preparing environment variables for fcgi access [debug] 20594#0: *1 fastcgi param: "QUERY_STRING: " [debug] 20594#0: *1 http script copy: "REQUEST_METHOD" [debug] 20594#0: *1 http script var: "GET" [debug] 20594#0: *1 fastcgi param: "REQUEST_METHOD: GET" [debug] 20594#0: *1 http script copy: "CONTENT_TYPE" [debug] 20594#0: *1 fastcgi param: "CONTENT_TYPE: " [debug] 20594#0: *1 http script copy: "CONTENT_LENGTH" [debug] 20594#0: *1 fastcgi param: "CONTENT_LENGTH: " [debug] 20594#0: *1 http script copy: "SCRIPT_NAME" [debug] 20594#0: *1 http script var: "/images/21/12_255_0_0.jpg" [debug] 20594#0: *1 fastcgi param: "SCRIPT_NAME: /images/21/12_255_0_0.jpg? <- Is this a problem? This is a C fcgi program, and I didn?t set SCRIPT_NAME [debug] 20594#0: *1 http script copy: "REQUEST_URI" [debug] 20594#0: *1 http script var: "/images/12/255/0/0.jpg" [debug] 20594#0: *1 fastcgi param: "REQUEST_URI: /images/12/255/0/0.jpg? <- Request URI - I don?t use this, because it is the original [debug] 20594#0: *1 http script copy: "DOCUMENT_URI" [debug] 20594#0: *1 http script var: "/images/21/12_255_0_0.jpg" [debug] 20594#0: *1 fastcgi param: "DOCUMENT_URI: /images/21/12_255_0_0.jpg? <- fcgi program uses this URI [debug] 20594#0: *1 http script copy: "DOCUMENT_ROOT" [debug] 20594#0: *1 http script var: "/var/www/html/static.ranchmed.com" [debug] 20594#0: *1 fastcgi param: "DOCUMENT_ROOT: /var/www/html/static.ranchmed.com" [debug] 20594#0: *1 http script copy: "SERVER_PROTOCOL" [debug] 20594#0: *1 http script var: "HTTP/1.0" [debug] 20594#0: *1 fastcgi param: "SERVER_PROTOCOL: HTTP/1.0" [debug] 20594#0: *1 http script copy: "REQUEST_SCHEME" [debug] 20594#0: *1 http script var: "http" [debug] 20594#0: *1 fastcgi param: "REQUEST_SCHEME: http" [debug] 20594#0: *1 http script copy: "" [debug] 20594#0: *1 http script copy: "GATEWAY_INTERFACE" [debug] 20594#0: *1 http script copy: "CGI/1.1" [debug] 20594#0: *1 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1" [debug] 20594#0: *1 http script copy: "SERVER_SOFTWARE" [debug] 20594#0: *1 http script copy: "nginx/" [debug] 20594#0: *1 http script var: "1.15.7" [debug] 20594#0: *1 fastcgi param: "SERVER_SOFTWARE: nginx/1.15.7" [debug] 20594#0: *1 http script copy: "REMOTE_ADDR" [debug] 20594#0: *1 http script var: "96.236.66.50" [debug] 20594#0: *1 fastcgi param: "REMOTE_ADDR: 96.236.66.50" [debug] 20594#0: *1 http script copy: "REMOTE_PORT" [debug] 20594#0: *1 http script var: "50046" [debug] 20594#0: *1 fastcgi param: "REMOTE_PORT: 50046" [debug] 20594#0: *1 http script copy: "SERVER_ADDR" [debug] 20594#0: *1 http script var: "192.168.1.101" [debug] 20594#0: *1 fastcgi param: "SERVER_ADDR: 192.168.1.101" [debug] 20594#0: *1 http script copy: "SERVER_PORT" [debug] 20594#0: *1 http script var: "80" [debug] 20594#0: *1 fastcgi param: "SERVER_PORT: 80" [debug] 20594#0: *1 http script copy: "SERVER_NAME" [debug] 20594#0: *1 http script var: "static.ranchmed.com" [debug] 20594#0: *1 fastcgi param: "SERVER_NAME: static.ranchmed.com" [debug] 20594#0: *1 fastcgi param: "HTTP_HOST: static.ranchmed.com" [debug] 20594#0: *1 fastcgi param: "HTTP_X_REAL_IP: 96.236.66.50" [debug] 20594#0: *1 fastcgi param: "HTTP_X_FORWARDED_FOR: 96.236.66.50" [debug] 20594#0: *1 fastcgi param: "HTTP_CONNECTION: close" [debug] 20594#0: *1 fastcgi param: "HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" [debug] 20594#0: *1 fastcgi param: "HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" [debug] 20594#0: *1 fastcgi param: "HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5" [debug] 20594#0: *1 fastcgi param: "HTTP_ACCEPT_ENCODING: gzip, deflate, br" [debug] 20594#0: *1 fastcgi param: "HTTP_UPGRADE_INSECURE_REQUESTS: 1" [debug] 20594#0: *1 fastcgi param: "HTTP_CACHE_CONTROL: max-age=0" [debug] 20594#0: *1 http cleanup add: 0000000000D32CD8 [debug] 20594#0: *1 get rr peer, try: 1 [debug] 20594#0: *1 stream socket 20 [debug] 20594#0: *1 epoll add connection: fd:20 ev:80002005 [debug] 20594#0: *1 connect to 127.0.0.1:9000, fd:20 #2 [debug] 20594#0: *1 http upstream connect: -2 [debug] 20594#0: *1 posix_memalign: 0000000000D14A50:128 @16 [debug] 20594#0: *1 event timer add: 20: 60000:556031347 [debug] 20594#0: *1 http finalize request: -4, "/images/21/12_255_0_0.jpg?" a:1, c:4 [debug] 20594#0: *1 http request count:4 blk:0 [debug] 20594#0: *1 http finalize request: -4, "/images/21/12_255_0_0.jpg?" a:1, c:3 [debug] 20594#0: *1 http request count:3 blk:0 [debug] 20594#0: timer delta: 0 [debug] 20594#0: worker cycle [debug] 20594#0: epoll timer: 60000 [debug] 20594#0: epoll: fd:19 ev:0004 d:0000000000D4E4D0 [debug] 20594#0: *1 http run request: "/images/21/12_255_0_0.jpg?" [debug] 20594#0: *1 http upstream check client, write event:1, "/images/21/12_255_0_0.jpg" [debug] 20594#0: epoll: fd:20 ev:0004 d:0000000000D4E5B8 [debug] 20594#0: *1 http upstream request: "/images/21/12_255_0_0.jpg?" [debug] 20594#0: *1 http upstream send request handler [debug] 20594#0: *1 http upstream send request [debug] 20594#0: *1 http upstream send request body [debug] 20594#0: *1 chain writer buf fl:0 s:920 [debug] 20594#0: *1 chain writer in: 0000000000D32D18 [debug] 20594#0: *1 writev: 920 of 920 [debug] 20594#0: *1 chain writer out: 0000000000000000 [debug] 20594#0: *1 event timer del: 20: 556031347 [debug] 20594#0: *1 event timer add: 20: 60000:556031348 [debug] 20594#0: timer delta: 1 [debug] 20594#0: worker cycle [debug] 20594#0: epoll timer: 60000 [debug] 20594#0: epoll: fd:20 ev:0005 d:0000000000D4E5B8 [debug] 20594#0: *1 http upstream request: "0100101 Firefox/?D <- SOMETHING IS BROKE!! ?" [debug] 20594#0: *1 http upstream process header [debug] 20594#0: *1 malloc: 0000000000D24EB0:4096 [debug] 20594#0: *1 recv: eof:0, avail:1 [debug] 20594#0: *1 recv: fd:20 4096 of 4096 [debug] 20594#0: *1 http fastcgi record byte: 01 [debug] 20594#0: *1 http fastcgi record byte: 06 [debug] 20594#0: *1 http fastcgi record byte: 00 [debug] 20594#0: *1 http fastcgi record byte: 01 [debug] 20594#0: *1 http fastcgi record byte: 1F [debug] 20594#0: *1 http fastcgi record byte: F8 [debug] 20594#0: *1 http fastcgi record byte: 00 [debug] 20594#0: *1 http fastcgi record byte: 00 [debug] 20594#0: *1 http fastcgi record length: 8184 [debug] 20594#0: *1 http fastcgi parser: 0 [debug] 20594#0: *1 http fastcgi header: "Content-type: image/jpeg" [debug] 20594#0: *1 http fastcgi parser: 1 [debug] 20594#0: *1 http fastcgi header done [debug] 20594#0: *1 posix_memalign: 0000000000D18E70:4096 @16 [debug] 20594#0: *1 HTTP/1.1 200 OK Server: nginx/1.15.7 Date: Sun, 13 Jan 2019 15:37:24 GMT Content-Type: image/jpeg Connection: close You may suspect that the fcgi program is crashing. I tested this by turning off the module, and executing the fcgi program by manually specifying the ?rewritten? uri. Here is the output of a successful completion for the fcgi program: [debug] 20730#0: *1 event timer del: 12: 557645604 [debug] 20730#0: *1 rewrite phase: 0 [debug] 20730#0: *1 test location: "/" [debug] 20730#0: *1 test location: "images/" [debug] 20730#0: *1 using configuration "/images/" [debug] 20730#0: *1 http cl:-1 max:104857600 [debug] 20730#0: *1 rewrite phase: 2 [debug] 20730#0: *1 rewrite phase: 3 [debug] 20730#0: *1 post rewrite phase: 4 <- No rewrite - my module is disabled [debug] 20730#0: *1 generic phase: 5 [debug] 20730#0: *1 generic phase: 6 [debug] 20730#0: *1 access phase: 7 [debug] 20730#0: *1 access phase: 8 [debug] 20730#0: *1 post access phase: 9 [debug] 20730#0: *1 generic phase: 10 [debug] 20730#0: *1 try files handler <- Try files can?t find the image in the filesystem [debug] 20730#0: *1 http script var: "/images/21/12_260_0_0.jpg" [debug] 20730#0: *1 trying to use file: "/images/21/12_260_0_0.jpg" "/var/www/html/static.ranchmed.com/images/21/12_260_0_0.jpg" [debug] 20730#0: *1 trying to use file: "@fastimg_fcgi" "/var/www/html/static.ranchmed.com at fastimg_fcgi" [debug] 20730#0: *1 test location: "@fastimg_fcgi" [debug] 20730#0: *1 using location: @fastimg_fcgi "/images/21/12_260_0_0.jpg?? <- And executes my fastimg_fcgi program [debug] 20730#0: *1 rewrite phase: 2 [debug] 20730#0: *1 rewrite phase: 3 [debug] 20730#0: *1 post rewrite phase: 4 [debug] 20730#0: *1 generic phase: 5 [debug] 20730#0: *1 generic phase: 6 [debug] 20730#0: *1 access phase: 7 [debug] 20730#0: *1 access phase: 8 [debug] 20730#0: *1 post access phase: 9 [debug] 20730#0: *1 generic phase: 10 [debug] 20730#0: *1 generic phase: 11 [debug] 20730#0: *1 http init upstream, client timer: 0 [debug] 20730#0: *1 epoll add event: fd:12 op:3 ev:80002005 [debug] 20730#0: *1 http script copy: "QUERY_STRING" [debug] 20730#0: *1 fastcgi param: "QUERY_STRING: " [debug] 20730#0: *1 http script copy: "REQUEST_METHOD" [debug] 20730#0: *1 http script var: "GET" [debug] 20730#0: *1 fastcgi param: "REQUEST_METHOD: GET" [debug] 20730#0: *1 http script copy: "CONTENT_TYPE" [debug] 20730#0: *1 fastcgi param: "CONTENT_TYPE: " [debug] 20730#0: *1 http script copy: "CONTENT_LENGTH" [debug] 20730#0: *1 fastcgi param: "CONTENT_LENGTH: " [debug] 20730#0: *1 http script copy: "SCRIPT_NAME" [debug] 20730#0: *1 http script var: "/images/21/12_260_0_0.jpg" [debug] 20730#0: *1 fastcgi param: "SCRIPT_NAME: /images/21/12_260_0_0.jpg" [debug] 20730#0: *1 http script copy: "REQUEST_URI" [debug] 20730#0: *1 http script var: "/images/21/12_260_0_0.jpg" [debug] 20730#0: *1 fastcgi param: "REQUEST_URI: /images/21/12_260_0_0.jpg? <- Spoofed the URI (manually set the redirect uri) [debug] 20730#0: *1 http script copy: "DOCUMENT_URI" [debug] 20730#0: *1 http script var: "/images/21/12_260_0_0.jpg? <- This var is used in the fcgi [debug] 20730#0: *1 fastcgi param: "DOCUMENT_URI: /images/21/12_260_0_0.jpg" [debug] 20730#0: *1 http script copy: "DOCUMENT_ROOT" [debug] 20730#0: *1 http script var: "/var/www/html/static.ranchmed.com" [debug] 20730#0: *1 fastcgi param: "DOCUMENT_ROOT: /var/www/html/static.ranchmed.com" [debug] 20730#0: *1 http script copy: "SERVER_PROTOCOL" [debug] 20730#0: *1 http script var: "HTTP/1.0" [debug] 20730#0: *1 fastcgi param: "SERVER_PROTOCOL: HTTP/1.0" [debug] 20730#0: *1 http script copy: "REQUEST_SCHEME" [debug] 20730#0: *1 http script var: "http" [debug] 20730#0: *1 fastcgi param: "REQUEST_SCHEME: http" [debug] 20730#0: *1 http script copy: "" [debug] 20730#0: *1 http script copy: "GATEWAY_INTERFACE" [debug] 20730#0: *1 http script copy: "CGI/1.1" [debug] 20730#0: *1 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1" [debug] 20730#0: *1 http script copy: "SERVER_SOFTWARE" [debug] 20730#0: *1 http script copy: "nginx/" [debug] 20730#0: *1 http script var: "1.15.7" [debug] 20730#0: *1 fastcgi param: "SERVER_SOFTWARE: nginx/1.15.7" [debug] 20730#0: *1 http script copy: "REMOTE_ADDR" [debug] 20730#0: *1 http script var: "96.236.66.50" [debug] 20730#0: *1 fastcgi param: "REMOTE_ADDR: 96.236.66.50" [debug] 20730#0: *1 http script copy: "REMOTE_PORT" [debug] 20730#0: *1 http script var: "50108" [debug] 20730#0: *1 fastcgi param: "REMOTE_PORT: 50108" [debug] 20730#0: *1 http script copy: "SERVER_ADDR" [debug] 20730#0: *1 http script var: "192.168.1.101" [debug] 20730#0: *1 fastcgi param: "SERVER_ADDR: 192.168.1.101" [debug] 20730#0: *1 http script copy: "SERVER_PORT" [debug] 20730#0: *1 http script var: "80" [debug] 20730#0: *1 fastcgi param: "SERVER_PORT: 80" [debug] 20730#0: *1 http script copy: "SERVER_NAME" [debug] 20730#0: *1 http script var: "static.ranchmed.com" [debug] 20730#0: *1 fastcgi param: "SERVER_NAME: static.ranchmed.com" [debug] 20730#0: *1 fastcgi param: "HTTP_HOST: static.ranchmed.com" [debug] 20730#0: *1 fastcgi param: "HTTP_X_REAL_IP: 96.236.66.50" [debug] 20730#0: *1 fastcgi param: "HTTP_X_FORWARDED_FOR: 96.236.66.50" [debug] 20730#0: *1 fastcgi param: "HTTP_CONNECTION: close" [debug] 20730#0: *1 fastcgi param: "HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" [debug] 20730#0: *1 fastcgi param: "HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" [debug] 20730#0: *1 fastcgi param: "HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5" [debug] 20730#0: *1 fastcgi param: "HTTP_ACCEPT_ENCODING: gzip, deflate, br" [debug] 20730#0: *1 fastcgi param: "HTTP_UPGRADE_INSECURE_REQUESTS: 1" [debug] 20730#0: *1 http cleanup add: 0000000000C0ECC0 [debug] 20730#0: *1 get rr peer, try: 1 [debug] 20730#0: *1 stream socket 14 [debug] 20730#0: *1 epoll add connection: fd:14 ev:80002005 [debug] 20730#0: *1 connect to 127.0.0.1:9000, fd:14 #2 [debug] 20730#0: *1 http upstream connect: -2 [debug] 20730#0: *1 posix_memalign: 0000000000BF0A50:128 @16 [debug] 20730#0: *1 event timer add: 14: 60000:557645604 [debug] 20730#0: *1 http finalize request: -4, "/images/21/12_260_0_0.jpg?" a:1, c:3 [debug] 20730#0: *1 http request count:3 blk:0 [debug] 20730#0: *1 http finalize request: -4, "/images/21/12_260_0_0.jpg?" a:1, c:2 [debug] 20730#0: *1 http request count:2 blk:0 [debug] 20730#0: timer delta: 0 [debug] 20730#0: worker cycle [debug] 20730#0: epoll timer: 60000 [debug] 20730#0: epoll: fd:12 ev:0004 d:0000000000C2A4D0 [debug] 20730#0: *1 http run request: "/images/21/12_260_0_0.jpg?" [debug] 20730#0: *1 http upstream check client, write event:1, "/images/21/12_260_0_0.jpg" [debug] 20730#0: epoll: fd:14 ev:0004 d:0000000000C2A5B8 [debug] 20730#0: *1 http upstream request: "/images/21/12_260_0_0.jpg?" [debug] 20730#0: *1 http upstream send request handler [debug] 20730#0: *1 http upstream send request [debug] 20730#0: *1 http upstream send request body [debug] 20730#0: *1 chain writer buf fl:0 s:896 [debug] 20730#0: *1 chain writer in: 0000000000C0BB30 [debug] 20730#0: *1 writev: 896 of 896 [debug] 20730#0: *1 chain writer out: 0000000000000000 [debug] 20730#0: *1 event timer del: 14: 557645604 [debug] 20730#0: *1 event timer add: 14: 60000:557645604 [debug] 20730#0: timer delta: 0 [debug] 20730#0: worker cycle [debug] 20730#0: epoll timer: 60000 [debug] 20730#0: epoll: fd:14 ev:0005 d:0000000000C2A5B8 [debug] 20730#0: *1 http upstream request: "/images/21/12_260_0_0.jpg?" [debug] 20730#0: *1 http upstream process header [debug] 20730#0: *1 malloc: 0000000000C00EB0:4096 [debug] 20730#0: *1 recv: eof:0, avail:1 [debug] 20730#0: *1 recv: fd:14 4096 of 4096 [debug] 20730#0: *1 http fastcgi record byte: 01 [debug] 20730#0: *1 http fastcgi record byte: 06 [debug] 20730#0: *1 http fastcgi record byte: 00 [debug] 20730#0: *1 http fastcgi record byte: 01 [debug] 20730#0: *1 http fastcgi record byte: 1F [debug] 20730#0: *1 http fastcgi record byte: F8 [debug] 20730#0: *1 http fastcgi record byte: 00 [debug] 20730#0: *1 http fastcgi record byte: 00 [debug] 20730#0: *1 http fastcgi record length: 8184 [debug] 20730#0: *1 http fastcgi parser: 0 [debug] 20730#0: *1 http fastcgi header: "Content-type: image/jpeg" [debug] 20730#0: *1 http fastcgi parser: 1 [debug] 20730#0: *1 http fastcgi header done [debug] 20730#0: *1 posix_memalign: 0000000000BF4E70:4096 @16 [debug] 20730#0: *1 HTTP/1.1 200 OK <- SUCCESS!! Server: nginx/1.15.7 Date: Sun, 13 Jan 2019 16:04:18 GMT Content-Type: image/jpeg Connection: close I hope you are able to take a little time to review these two debug listings, and to provide some guidance to understand an approach that I can take to fix the problems! Many Thanks, Mark From mdounin at mdounin.ru Mon Jan 14 16:47:55 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 14 Jan 2019 19:47:55 +0300 Subject: Interaction between ngx module and fastcgi program In-Reply-To: <9484113F-2F71-49F6-BAA1-3F3A8E8F77AF@ranchmed.com> References: <9484113F-2F71-49F6-BAA1-3F3A8E8F77AF@ranchmed.com> Message-ID: <20190114164755.GE99070@mdounin.ru> Hello! On Mon, Jan 14, 2019 at 08:33:23AM -0800, Mark Sellers wrote: > Thanks for your great feedback. It is truly appreciated. > > I am finalizing a simple nginx module, that does a uri rewrite. I have tested it, and the rewrite is working fine for files that exist on the server. > > A second component of my system is a fastcgi program (written in C) that, upon execution using the try_files named location. This fastcgi program has been tested, and works fine, by itself. > > My problem comes when both the module and fastcgi program are working together. Something in the combined environment is causing a malfunction. > > Could you please take a look at the annotated debug outputs, and suggest an approach to find the issue, and fix it? Please refer to below and see my notes offset to the left of the listing: > > Debug log with module and fastcgi both operating (I removed the first two columns of the debut output to provide a better fit on this page: > > > > [debug] 20594#0: *1 event timer del: 19: 556031347 > [debug] 20594#0: *1 rewrite phase: 0 > [debug] 20594#0: *1 test location: "/" > [debug] 20594#0: *1 test location: "images/" > [debug] 20594#0: *1 using configuration "/images/" > [debug] 20594#0: *1 http cl:-1 max:104857600 > [debug] 20594#0: *1 rewrite phase: 2 > [debug] 20594#0: *1 fastimg handler <- My module > [debug] 20594#0: *1 ngx_http_fastimg_rewrite() uri in: "/images/12/255/0/0.jpg? <- Input uri > [debug] 20594#0: *1 ngx_http_fastimg_rewrite() uri out: "/images/21/12_255_0_0.jpg? <- Output uri (rewritten) > [debug] 20594#0: *1 internal redirect: "/images/21/12_255_0_0.jpg?? <- Internal redirect using ngx_http_internal_redirect(r, &uri, NULL) [...] > [debug] 20594#0: timer delta: 1 > [debug] 20594#0: worker cycle > [debug] 20594#0: epoll timer: 60000 > [debug] 20594#0: epoll: fd:20 ev:0005 d:0000000000D4E5B8 > [debug] 20594#0: *1 http upstream request: "0100101 Firefox/?D <- SOMETHING IS BROKE!! > ?" > [debug] 20594#0: *1 http upstream process header Check how do you allocate URI as passed to the ngx_http_internal_redirect() function. I suspect you are using stack or other temporary allocated buffer there, and this is what causes the problem: as long as the buffer is overwritten, everything is broken. Instead, you should allocate the URI string as passed to ngx_http_internal_redirect() from the request memory pool, so it will not be rewritten till the request is freed. -- Maxim Dounin http://mdounin.ru/ From kahing at cloudflare.com Tue Jan 15 01:53:42 2019 From: kahing at cloudflare.com (Ka-Hing Cheung) Date: Mon, 14 Jan 2019 17:53:42 -0800 Subject: cache: move open to thread pool In-Reply-To: <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> References: <20180808181653.GX56558@mdounin.ru> <20180810113946.GG56558@mdounin.ru> <20180903160903.GI56558@mdounin.ru> <4ba7414a-0eba-6bd3-5a50-2eca591ac25e@nginx.com> <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> Message-ID: We didn't get to it last year because of other priorities but this is being worked on. We don't use a vanilla nginx so it takes effort to integrate your patches. Having a version of this in upstream nginx is important to us and to me personally. On Thu, Jan 10, 2019 at 12:30 AM Maxim Konovalov wrote: > > So guys, are you really interested in this work beyond shiny > marketing blog posts? > > On 05/12/2018 12:43, Maxim Konovalov wrote: > > Hello, > > > > just a reminder that we are looking for a tester for these patches. > > > > Thanks, > > > > Maxim > > > > On 16/11/2018 12:10, Maxim Konovalov wrote: > >> Thanks, Ka-Hing, we'll wait for your feedback. > >> > >> On 16/11/2018 01:53, Ka-Hing Cheung wrote: > >>> Hi, > >>> > >>> I didn't forget about this. I am pretty swamped at the moment and > >>> there's a holiday freeze coming up. Will get to his in December. > >>> > >>> - Ka-Hing > >>> > >>> On Thu, Nov 8, 2018 at 6:19 AM Maxim Konovalov wrote: > >>>> > >>>> Hi Ka-Hing, > >>>> > >>>> would you mind to test Roman's most recent patches that add > >>>> "aio_open" directive? > >>>> > >>>> http://mailman.nginx.org/pipermail/nginx-devel/2018-November/011538.html > >>>> > >>>> We are looking for overall performance and stability metrics and > >>>> feedback. > >>>> > >>>> Much appreciated, > >>>> > >>>> Maxim > >>>> > >>>> -- > >>>> Maxim Konovalov > >> > >> > > > > > > > -- > Maxim Konovalov > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From Elliot.Thomas at bbc.co.uk Wed Jan 16 10:20:59 2019 From: Elliot.Thomas at bbc.co.uk (Elliot Thomas) Date: Wed, 16 Jan 2019 10:20:59 +0000 Subject: [PATCH] Apply cache locking behaviour to stale cache entries. In-Reply-To: References: <20181210190717.GV99070@mdounin.ru> Message-ID: Hello! With regards to the cache locking on stale patch, are there any further improvements I should make? Regards, Elliot --- Please ignore the following disclaimer, it?s a bit silly. I have read the contribution guide, and am fine with it. ----------------------------- http://www.bbc.co.uk This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. ----------------------------- From xeioex at nginx.com Wed Jan 16 15:55:34 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 16 Jan 2019 15:55:34 +0000 Subject: [njs] Fixed heap-use-after-free introduced in 045ba10db769. Message-ID: details: https://hg.nginx.org/njs/rev/4c0de77ef946 branches: changeset: 728:4c0de77ef946 user: Dmitry Volyntsev date: Wed Jan 16 18:55:16 2019 +0300 description: Fixed heap-use-after-free introduced in 045ba10db769. diffstat: njs/njs_function.c | 3 ++- njs/njs_vm.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diffs (48 lines): diff -r fb2c2bca61c2 -r 4c0de77ef946 njs/njs_function.c --- a/njs/njs_function.c Fri Jan 11 19:20:38 2019 +0800 +++ b/njs/njs_function.c Wed Jan 16 18:55:16 2019 +0300 @@ -528,7 +528,6 @@ njs_function_native_call(njs_vm_t *vm, n frame = vm->top_frame; vm->top_frame = njs_function_previous_frame(frame); - njs_function_frame_free(vm, frame); /* * If a retval is in a callee arguments scope it @@ -552,6 +551,8 @@ njs_function_native_call(njs_vm_t *vm, n *value = vm->retval; } + njs_function_frame_free(vm, frame); + return NXT_OK; } diff -r fb2c2bca61c2 -r 4c0de77ef946 njs/njs_vm.c --- a/njs/njs_vm.c Fri Jan 11 19:20:38 2019 +0800 +++ b/njs/njs_vm.c Wed Jan 16 18:55:16 2019 +0300 @@ -2287,12 +2287,15 @@ const njs_vmcode_generic_t njs_continua static njs_ret_t njs_vmcode_continuation(njs_vm_t *vm, njs_value_t *invld1, njs_value_t *invld2) { + u_char *return_address; njs_ret_t ret; njs_native_frame_t *frame; njs_continuation_t *cont; frame = vm->top_frame; + cont = njs_vm_continuation(vm); + return_address = cont->return_address; ret = njs_function_native_call(vm, cont->function, frame->arguments, cont->args_types, frame->nargs, @@ -2300,7 +2303,7 @@ njs_vmcode_continuation(njs_vm_t *vm, nj switch (ret) { case NXT_OK: - vm->current = cont->return_address; + vm->current = return_address; /* Fall through. */ case NJS_APPLIED: From sepherosa at gmail.com Thu Jan 17 05:43:57 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Thu, 17 Jan 2019 13:43:57 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: Message-ID: What's the preferred way to handle this? I am not sure whether you guys allow __FreeBSD_version testing etc. On Wed, Jan 9, 2019 at 7:52 PM Sergey Kandaurov wrote: > > > > > On 8 Jan 2019, at 06:37, Sepherosa Ziehau wrote: > > > > sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL > > for quite a while. > > > > Patch: > > https://leaf.dragonflybsd.org/~sephe/nginx_sival.diff > > Citing here for archives: > > commit 14d1cab150226367c8a0f0ae219b0e0571587aea > Author: Yanmin Qiao > Date: Tue Jan 8 11:33:00 2019 +0800 > > unix/aio: Use sigval.sival which is standard. > > sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL for quite a while. > > diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c > index aedc3c90..bb60ee82 100644 > --- a/src/os/unix/ngx_file_aio_read.c > +++ b/src/os/unix/ngx_file_aio_read.c > @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset, > #if (NGX_HAVE_KQUEUE) > aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; > aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; > + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; > #endif > ev->handler = ngx_file_aio_event_handler; > > > FreeBSD 4/5/6 lack sival_ptr (FreeBSD 3 has it, but not yet SIGEV_KEVENT), > which seemingly was broken in svn r48621 and later restored in r152029. > > And that means that the following will no longer be true: > > : Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only > > While nginx still maintains compatibility down to FreeBSD 2.2. > > If applied, it'd need this part as well (used to build on old FreeBSD): > > diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c > --- a/src/event/modules/ngx_eventport_module.c > +++ b/src/event/modules/ngx_eventport_module.c > @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n > > ngx_memzero(&sev, sizeof(struct sigevent)); > sev.sigev_notify = SIGEV_PORT; > -#if !(NGX_TEST_BUILD_EVENTPORT) > sev.sigev_value.sival_ptr = &pn; > -#endif > > if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, > > -- > Sergey Kandaurov > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel -- Tomorrow Will Never Die From pluknet at nginx.com Thu Jan 17 10:29:56 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Thu, 17 Jan 2019 13:29:56 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: Message-ID: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> > On 17 Jan 2019, at 08:43, Sepherosa Ziehau wrote: > > What's the preferred way to handle this? I am not sure whether you > guys allow __FreeBSD_version testing etc. > This could be solved with autotests. # HG changeset patch # User Sergey Kandaurov # Date 1547720890 0 # Thu Jan 17 10:28:10 2019 +0000 # Node ID d28513cd71bce227b4e159b7a3f518aa504232f0 # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 Fixed portability issues with union sigval. The sival_ptr field is now preferably used. diff --git a/auto/unix b/auto/unix --- a/auto/unix +++ b/auto/unix @@ -523,6 +523,7 @@ if [ $NGX_FILE_AIO = YES ]; then ngx_feature_libs= ngx_feature_test="struct aiocb iocb; iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; + iocb.aio_sigevent.sigev_value.sival_ptr = NULL; (void) aio_read(&iocb)" . auto/feature @@ -532,6 +533,22 @@ if [ $NGX_FILE_AIO = YES ]; then if [ $ngx_found = no ]; then + ngx_feature="kqueue AIO support (legacy)" + ngx_feature_name="NGX_HAVE_FILE_AIO_LEGACY" + ngx_feature_test="struct aiocb iocb; + iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; + iocb.aio_sigevent.sigev_value.sigval_ptr = NULL; + (void) aio_read(&iocb)" + . auto/feature + + if [ $ngx_found = yes ]; then + CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS" + have=NGX_HAVE_FILE_AIO . auto/have + fi + fi + + if [ $ngx_found = no ]; then + ngx_feature="Linux AIO support" ngx_feature_name="NGX_HAVE_FILE_AIO" ngx_feature_run=no diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c --- a/src/os/unix/ngx_file_aio_read.c +++ b/src/os/unix/ngx_file_aio_read.c @@ -110,8 +110,12 @@ ngx_file_aio_read(ngx_file_t *file, u_ch #if (NGX_HAVE_KQUEUE) aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; +#if !(NGX_HAVE_FILE_AIO_LEGACY) + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; +#else aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; #endif +#endif ev->handler = ngx_file_aio_event_handler; n = aio_read(&aio->aiocb); -- Sergey Kandaurov From vl at nginx.com Thu Jan 17 11:36:27 2019 From: vl at nginx.com (Vladimir Homutov) Date: Thu, 17 Jan 2019 11:36:27 +0000 Subject: [nginx] Version bump. Message-ID: details: https://hg.nginx.org/nginx/rev/134343f2a877 branches: changeset: 7438:134343f2a877 user: Vladimir Homutov date: Thu Jan 17 14:31:01 2019 +0300 description: Version bump. diffstat: src/core/nginx.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (14 lines): diff -r 6d15e452fa2e -r 134343f2a877 src/core/nginx.h --- a/src/core/nginx.h Tue Dec 25 17:53:03 2018 +0300 +++ b/src/core/nginx.h Thu Jan 17 14:31:01 2019 +0300 @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1015008 -#define NGINX_VERSION "1.15.8" +#define nginx_version 1015009 +#define NGINX_VERSION "1.15.9" #define NGINX_VER "nginx/" NGINX_VERSION #ifdef NGX_BUILD From vl at nginx.com Thu Jan 17 11:36:29 2019 From: vl at nginx.com (Vladimir Homutov) Date: Thu, 17 Jan 2019 11:36:29 +0000 Subject: [nginx] Added the ngx_http_test_required_predicates() function. Message-ID: details: https://hg.nginx.org/nginx/rev/5efc23d83bc2 branches: changeset: 7439:5efc23d83bc2 user: Vladimir Homutov date: Thu Jan 17 14:31:04 2019 +0300 description: Added the ngx_http_test_required_predicates() function. In contrast to ngx_http_test_predicates(), it requires all values to be non-empty and not equal to "0". diffstat: src/http/ngx_http_script.c | 28 ++++++++++++++++++++++++++++ src/http/ngx_http_script.h | 2 ++ 2 files changed, 30 insertions(+), 0 deletions(-) diffs (50 lines): diff -r 134343f2a877 -r 5efc23d83bc2 src/http/ngx_http_script.c --- a/src/http/ngx_http_script.c Thu Jan 17 14:31:01 2019 +0300 +++ b/src/http/ngx_http_script.c Thu Jan 17 14:31:04 2019 +0300 @@ -271,6 +271,34 @@ ngx_http_test_predicates(ngx_http_reques } +ngx_int_t +ngx_http_test_required_predicates(ngx_http_request_t *r, + ngx_array_t *predicates) +{ + ngx_str_t val; + ngx_uint_t i; + ngx_http_complex_value_t *cv; + + if (predicates == NULL) { + return NGX_OK; + } + + cv = predicates->elts; + + for (i = 0; i < predicates->nelts; i++) { + if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { + return NGX_ERROR; + } + + if (val.len == 0 || (val.len == 1 && val.data[0] == '0')) { + return NGX_DECLINED; + } + } + + return NGX_OK; +} + + char * ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { diff -r 134343f2a877 -r 5efc23d83bc2 src/http/ngx_http_script.h --- a/src/http/ngx_http_script.h Thu Jan 17 14:31:01 2019 +0300 +++ b/src/http/ngx_http_script.h Thu Jan 17 14:31:04 2019 +0300 @@ -214,6 +214,8 @@ char *ngx_http_set_complex_value_slot(ng ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates); +ngx_int_t ngx_http_test_required_predicates(ngx_http_request_t *r, + ngx_array_t *predicates); char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); From arut at nginx.com Thu Jan 17 12:12:10 2019 From: arut at nginx.com (Roman Arutyunyan) Date: Thu, 17 Jan 2019 12:12:10 +0000 Subject: [nginx] Prevented scheduling events on a shared connection. Message-ID: details: https://hg.nginx.org/nginx/rev/6d4bc025c5a7 branches: changeset: 7440:6d4bc025c5a7 user: Roman Arutyunyan date: Mon Jan 14 20:36:23 2019 +0300 description: Prevented scheduling events on a shared connection. A shared connection does not own its file descriptor, which means that ngx_handle_read_event/ngx_handle_write_event calls should do nothing for it. Currently the c->shared flag is checked in several places in the stream proxy module prior to calling these functions. However it was not done everywhere. Missing checks could lead to calling ngx_handle_read_event/ngx_handle_write_event on shared connections. The problem manifested itself when using proxy_upload_rate and resulted in either duplicate file descriptor error (e.g. with epoll) or incorrect further udp packet processing (e.g. with kqueue). The fix is to set and reset the event active flag in a way that prevents ngx_handle_read_event/ngx_handle_write_event from scheduling socket events. diffstat: src/event/ngx_event_udp.c | 6 ++++++ src/stream/ngx_stream_proxy_module.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diffs (58 lines): diff -r 5efc23d83bc2 -r 6d4bc025c5a7 src/event/ngx_event_udp.c --- a/src/event/ngx_event_udp.c Thu Jan 17 14:31:04 2019 +0300 +++ b/src/event/ngx_event_udp.c Mon Jan 14 20:36:23 2019 +0300 @@ -256,7 +256,9 @@ ngx_event_recvmsg(ngx_event_t *ev) rev = c->read; c->udp->buffer = &buf; + rev->ready = 1; + rev->active = 0; rev->handler(rev); @@ -265,6 +267,7 @@ ngx_event_recvmsg(ngx_event_t *ev) } rev->ready = 0; + rev->active = 1; goto next; } @@ -343,6 +346,7 @@ ngx_event_recvmsg(ngx_event_t *ev) rev = c->read; wev = c->write; + rev->active = 1; wev->ready = 1; rev->log = log; @@ -453,7 +457,9 @@ ngx_udp_shared_recv(ngx_connection_t *c, ngx_memcpy(buf, b->pos, n); c->udp->buffer = NULL; + c->read->ready = 0; + c->read->active = 1; return n; } diff -r 5efc23d83bc2 -r 6d4bc025c5a7 src/stream/ngx_stream_proxy_module.c --- a/src/stream/ngx_stream_proxy_module.c Thu Jan 17 14:31:04 2019 +0300 +++ b/src/stream/ngx_stream_proxy_module.c Mon Jan 14 20:36:23 2019 +0300 @@ -1667,13 +1667,13 @@ ngx_stream_proxy_process(ngx_stream_sess flags = src->read->eof ? NGX_CLOSE_EVENT : 0; - if (!src->shared && ngx_handle_read_event(src->read, flags) != NGX_OK) { + if (ngx_handle_read_event(src->read, flags) != NGX_OK) { ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); return; } if (dst) { - if (!dst->shared && ngx_handle_write_event(dst->write, 0) != NGX_OK) { + if (ngx_handle_write_event(dst->write, 0) != NGX_OK) { ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); return; } From arut at nginx.com Thu Jan 17 12:12:12 2019 From: arut at nginx.com (Roman Arutyunyan) Date: Thu, 17 Jan 2019 12:12:12 +0000 Subject: [nginx] Stream: do not split datagrams when limiting proxy rate. Message-ID: details: https://hg.nginx.org/nginx/rev/8acaa1161783 branches: changeset: 7441:8acaa1161783 user: Roman Arutyunyan date: Thu Dec 27 19:37:34 2018 +0300 description: Stream: do not split datagrams when limiting proxy rate. Previously, when using proxy_upload_rate and proxy_download_rate, the buffer size for reading from a socket could be reduced as a result of rate limiting. For connection-oriented protocols this behavior is normal since unread data will normally be read at the next iteration. But for datagram-oriented protocols this is not the case, and unread part of the datagram is lost. Now buffer size is not limited for datagrams. Rate limiting still works in this case by delaying the next reading event. diffstat: src/stream/ngx_stream_proxy_module.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 6d4bc025c5a7 -r 8acaa1161783 src/stream/ngx_stream_proxy_module.c --- a/src/stream/ngx_stream_proxy_module.c Mon Jan 14 20:36:23 2019 +0300 +++ b/src/stream/ngx_stream_proxy_module.c Thu Dec 27 19:37:34 2018 +0300 @@ -1593,7 +1593,7 @@ ngx_stream_proxy_process(ngx_stream_sess break; } - if ((off_t) size > limit) { + if (c->type == SOCK_STREAM && (off_t) size > limit) { size = (size_t) limit; } } From mdounin at mdounin.ru Thu Jan 17 13:22:51 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 17 Jan 2019 16:22:51 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> Message-ID: <20190117132251.GI99070@mdounin.ru> Hello! On Thu, Jan 17, 2019 at 01:29:56PM +0300, Sergey Kandaurov wrote: > > > > On 17 Jan 2019, at 08:43, Sepherosa Ziehau wrote: > > > > What's the preferred way to handle this? I am not sure whether you > > guys allow __FreeBSD_version testing etc. > > > > This could be solved with autotests. As long as we only care about different FreeBSD versions, this might as well be an auto/os/freebsd test based on $version, or just a define based on __FreeBSD_version in src/os/unix/ngx_freebsd_config.h. > # HG changeset patch > # User Sergey Kandaurov > # Date 1547720890 0 > # Thu Jan 17 10:28:10 2019 +0000 > # Node ID d28513cd71bce227b4e159b7a3f518aa504232f0 > # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 > Fixed portability issues with union sigval. > > The sival_ptr field is now preferably used. > > diff --git a/auto/unix b/auto/unix > --- a/auto/unix > +++ b/auto/unix > @@ -523,6 +523,7 @@ if [ $NGX_FILE_AIO = YES ]; then > ngx_feature_libs= > ngx_feature_test="struct aiocb iocb; > iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > + iocb.aio_sigevent.sigev_value.sival_ptr = NULL; > (void) aio_read(&iocb)" > . auto/feature > > @@ -532,6 +533,22 @@ if [ $NGX_FILE_AIO = YES ]; then > > if [ $ngx_found = no ]; then > > + ngx_feature="kqueue AIO support (legacy)" > + ngx_feature_name="NGX_HAVE_FILE_AIO_LEGACY" > + ngx_feature_test="struct aiocb iocb; > + iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > + iocb.aio_sigevent.sigev_value.sigval_ptr = NULL; > + (void) aio_read(&iocb)" > + . auto/feature Note that this will test for "kqueue AIO support (legacy)" on each Linux build with aio. > + > + if [ $ngx_found = yes ]; then > + CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS" > + have=NGX_HAVE_FILE_AIO . auto/have > + fi > + fi > + > + if [ $ngx_found = no ]; then > + > ngx_feature="Linux AIO support" > ngx_feature_name="NGX_HAVE_FILE_AIO" > ngx_feature_run=no > diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c > --- a/src/os/unix/ngx_file_aio_read.c > +++ b/src/os/unix/ngx_file_aio_read.c > @@ -110,8 +110,12 @@ ngx_file_aio_read(ngx_file_t *file, u_ch > #if (NGX_HAVE_KQUEUE) > aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; > aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > +#if !(NGX_HAVE_FILE_AIO_LEGACY) > + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; > +#else > aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; > #endif > +#endif > ev->handler = ngx_file_aio_event_handler; > > n = aio_read(&aio->aiocb); A simplier solution might be to always use sival_ptr, and define it to sigval_ptr on old FreeBSDs. Alternatively, we can consider dropping file AIO support for these old FreeBSD versions. This shouldn't be a big deal as this is an optional feature which is not enabled by default. -- Maxim Dounin http://mdounin.ru/ From mdounin at mdounin.ru Thu Jan 17 13:24:02 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 17 Jan 2019 16:24:02 +0300 Subject: [PATCH] Apply cache locking behaviour to stale cache entries. In-Reply-To: References: <20181210190717.GV99070@mdounin.ru> Message-ID: <20190117132401.GJ99070@mdounin.ru> Hello! On Wed, Jan 16, 2019 at 10:20:59AM +0000, Elliot Thomas wrote: > With regards to the cache locking on stale patch, are there any further > improvements I should make? Sorry, I'm a bit busy with other tasks now. Hopefully I'll be able to look again at the patch later this month. -- Maxim Dounin http://mdounin.ru/ From manickam.subbiah at gmail.com Thu Jan 17 13:57:52 2019 From: manickam.subbiah at gmail.com (Manickam) Date: Thu, 17 Jan 2019 19:27:52 +0530 Subject: post handler json data Message-ID: Hi, I am new to Nginx development and looking for simple module which just dumps the input (json format) as is. Looked at different examples available on net and none of them deals with handling post data. May be i am missing something and any help is appreciated. Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From xeioex at nginx.com Thu Jan 17 14:03:22 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 17 Jan 2019 14:03:22 +0000 Subject: [njs] Fixed try_break instruction. Message-ID: details: https://hg.nginx.org/njs/rev/9973704e2e36 branches: changeset: 730:9973704e2e36 user: Dmitry Volyntsev date: Thu Jan 17 16:11:52 2019 +0300 description: Fixed try_break instruction. diffstat: njs/njs_vm.c | 5 ++++- njs/test/njs_unit_test.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletions(-) diffs (28 lines): diff -r 0f919fb820e8 -r 9973704e2e36 njs/njs_vm.c --- a/njs/njs_vm.c Wed Jan 16 18:58:23 2019 +0300 +++ b/njs/njs_vm.c Thu Jan 17 16:11:52 2019 +0300 @@ -2376,7 +2376,10 @@ nxt_noinline njs_ret_t njs_vmcode_try_break(njs_vm_t *vm, njs_value_t *exit_value, njs_value_t *offset) { - exit_value->data.u.number = 1; + /* exit_value can contain valid value set by vmcode_try_return. */ + if (!njs_is_valid(exit_value)) { + exit_value->data.u.number = 1; + } return (njs_ret_t) offset; } diff -r 0f919fb820e8 -r 9973704e2e36 njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Wed Jan 16 18:58:23 2019 +0300 +++ b/njs/test/njs_unit_test.c Thu Jan 17 16:11:52 2019 +0300 @@ -6902,6 +6902,9 @@ static njs_unit_test_t njs_test[] = "})(function () {throw 'a'}, 'v')"), nxt_string("v") }, + { nxt_string("(function() { try { return ['a'];} finally {} } )()"), + nxt_string("a") }, + { nxt_string("var o = { valueOf: function() { return '3' } }; --o"), nxt_string("2") }, From xeioex at nginx.com Thu Jan 17 14:03:22 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 17 Jan 2019 14:03:22 +0000 Subject: [njs] Making generator block for block statements. Message-ID: details: https://hg.nginx.org/njs/rev/0f919fb820e8 branches: changeset: 729:0f919fb820e8 user: Dmitry Volyntsev date: Wed Jan 16 18:58:23 2019 +0300 description: Making generator block for block statements. diffstat: njs/njs_generator.c | 28 +++++++++++++++++++ njs/njs_parser.c | 75 +++++++++++++++++++++++++++++++++++++++++++++------- njs/njs_parser.h | 1 + 3 files changed, 93 insertions(+), 11 deletions(-) diffs (230 lines): diff -r 4c0de77ef946 -r 0f919fb820e8 njs/njs_generator.c --- a/njs/njs_generator.c Wed Jan 16 18:55:16 2019 +0300 +++ b/njs/njs_generator.c Wed Jan 16 18:58:23 2019 +0300 @@ -99,6 +99,8 @@ static nxt_int_t njs_generate_break_stat njs_generator_t *generator, njs_parser_node_t *node); static nxt_int_t njs_generate_statement(njs_vm_t *vm, njs_generator_t *generator, njs_parser_node_t *node); +static nxt_int_t njs_generate_block_statement(njs_vm_t *vm, + njs_generator_t *generator, njs_parser_node_t *node); static nxt_int_t njs_generate_children(njs_vm_t *vm, njs_generator_t *generator, njs_parser_node_t *node); static nxt_int_t njs_generate_stop_statement(njs_vm_t *vm, @@ -257,6 +259,9 @@ njs_generator(njs_vm_t *vm, njs_generato case NJS_TOKEN_STATEMENT: return njs_generate_statement(vm, generator, node); + case NJS_TOKEN_BLOCK: + return njs_generate_block_statement(vm, generator, node); + case NJS_TOKEN_END: return njs_generate_stop_statement(vm, generator, node); @@ -1507,6 +1512,29 @@ njs_generate_statement(njs_vm_t *vm, njs static nxt_int_t +njs_generate_block_statement(njs_vm_t *vm, njs_generator_t *generator, + njs_parser_node_t *node) +{ + nxt_int_t ret; + + ret = njs_generate_start_block(vm, generator, NJS_GENERATOR_BLOCK, + &no_label); + if (nxt_slow_path(ret != NXT_OK)) { + return ret; + } + + ret = njs_generate_statement(vm, generator, node->left); + if (nxt_slow_path(ret != NXT_OK)) { + return ret; + } + + njs_generate_patch_block_exit(vm, generator); + + return ret; +} + + +static nxt_int_t njs_generate_children(njs_vm_t *vm, njs_generator_t *generator, njs_parser_node_t *node) { diff -r 4c0de77ef946 -r 0f919fb820e8 njs/njs_parser.c --- a/njs/njs_parser.c Wed Jan 16 18:55:16 2019 +0300 +++ b/njs/njs_parser.c Wed Jan 16 18:58:23 2019 +0300 @@ -19,6 +19,8 @@ static njs_token_t njs_parser_statement( njs_token_t token); static njs_token_t njs_parser_block_statement(njs_vm_t *vm, njs_parser_t *parser); +static njs_token_t njs_parser_block(njs_vm_t *vm, + njs_parser_t *parser, njs_token_t token); static njs_token_t njs_parser_function_declaration(njs_vm_t *vm, njs_parser_t *parser); static njs_parser_t *njs_parser_function_create(njs_vm_t *vm, @@ -390,8 +392,9 @@ njs_parser_statement(njs_vm_t *vm, njs_p static njs_token_t njs_parser_block_statement(njs_vm_t *vm, njs_parser_t *parser) { - njs_ret_t ret; - njs_token_t token; + njs_ret_t ret; + njs_token_t token; + njs_parser_node_t *node; token = njs_parser_token(parser); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { @@ -412,12 +415,48 @@ njs_parser_block_statement(njs_vm_t *vm, } } + if (parser->node != NULL) { + /* The statement is not empty block or just semicolon. */ + + node = njs_parser_node_alloc(vm); + if (nxt_slow_path(node == NULL)) { + return NJS_TOKEN_ERROR; + } + + node->token = NJS_TOKEN_BLOCK; + node->left = parser->node; + node->right = NULL; + parser->node = node; + } + njs_parser_scope_end(vm, parser); return njs_parser_token(parser); } +static njs_token_t +njs_parser_block(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token) +{ + njs_parser_node_t *node; + + token = njs_parser_statement(vm, parser, token); + if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { + return token; + } + + node = parser->node; + + if (node != NULL && node->token == NJS_TOKEN_BLOCK) { + parser->node = node->left; + + nxt_mem_cache_free(vm->mem_cache_pool, node); + } + + return token; +} + + nxt_inline njs_token_t njs_parser_match(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token, njs_token_t match) @@ -933,7 +972,7 @@ njs_parser_if_statement(njs_vm_t *vm, nj cond = parser->node; - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -947,7 +986,7 @@ njs_parser_if_statement(njs_vm_t *vm, nj return token; } - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1104,7 +1143,7 @@ njs_parser_while_statement(njs_vm_t *vm, cond = parser->node; - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1134,7 +1173,7 @@ njs_parser_do_while_statement(njs_vm_t * return token; } - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1252,7 +1291,7 @@ njs_parser_for_statement(njs_vm_t *vm, n return token; } - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1418,7 +1457,7 @@ njs_parser_for_var_in_statement(njs_vm_t return token; } - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1467,7 +1506,7 @@ njs_parser_for_in_statement(njs_vm_t *vm return token; } - token = njs_parser_statement(vm, parser, token); + token = njs_parser_block(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } @@ -1677,14 +1716,28 @@ njs_parser_try_statement(njs_vm_t *vm, n static njs_token_t njs_parser_try_block(njs_vm_t *vm, njs_parser_t *parser) { - njs_token_t token; + njs_token_t token; + njs_parser_node_t *node; token = njs_parser_token(parser); if (nxt_slow_path(token != NJS_TOKEN_OPEN_BRACE)) { return NJS_TOKEN_ILLEGAL; } - return njs_parser_block_statement(vm, parser); + token = njs_parser_block_statement(vm, parser); + if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { + return token; + } + + node = parser->node; + + if (node != NULL && node->token == NJS_TOKEN_BLOCK) { + parser->node = node->left; + + nxt_mem_cache_free(vm->mem_cache_pool, node); + } + + return token; } diff -r 4c0de77ef946 -r 0f919fb820e8 njs/njs_parser.h --- a/njs/njs_parser.h Wed Jan 16 18:55:16 2019 +0300 +++ b/njs/njs_parser.h Wed Jan 16 18:58:23 2019 +0300 @@ -138,6 +138,7 @@ typedef enum { NJS_TOKEN_EXTERNAL, NJS_TOKEN_STATEMENT, + NJS_TOKEN_BLOCK, NJS_TOKEN_VAR, NJS_TOKEN_IF, NJS_TOKEN_ELSE, From xeioex at nginx.com Thu Jan 17 14:03:23 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 17 Jan 2019 14:03:23 +0000 Subject: [njs] Fixed comments "try" instructions. Message-ID: details: https://hg.nginx.org/njs/rev/2e9bdb42b3e6 branches: changeset: 731:2e9bdb42b3e6 user: Dmitry Volyntsev date: Thu Jan 17 16:12:46 2019 +0300 description: Fixed comments "try" instructions. diffstat: njs/njs_vm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diffs (21 lines): diff -r 9973704e2e36 -r 2e9bdb42b3e6 njs/njs_vm.c --- a/njs/njs_vm.c Thu Jan 17 16:11:52 2019 +0300 +++ b/njs/njs_vm.c Thu Jan 17 16:12:46 2019 +0300 @@ -2386,7 +2386,7 @@ njs_vmcode_try_break(njs_vm_t *vm, njs_v /* - * njs_vmcode_try_break() sets exit_value to INVALID -1, and jumps to + * njs_vmcode_try_continue() sets exit_value to INVALID -1, and jumps to * the nearest try_end block. The exit_value is checked by njs_vmcode_finally(). */ @@ -2401,7 +2401,7 @@ njs_vmcode_try_continue(njs_vm_t *vm, nj /* * njs_vmcode_try_return() saves a return value to use it later by - * njs_vmcode_finally(), and jumps to the nearest try_end block. + * njs_vmcode_finally(), and jumps to the nearest try_break block. */ nxt_noinline njs_ret_t From xeioex at nginx.com Thu Jan 17 14:03:23 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 17 Jan 2019 14:03:23 +0000 Subject: [njs] Setting exit index for try_return instruction is simplified. Message-ID: details: https://hg.nginx.org/njs/rev/3b1239c2ee12 branches: changeset: 732:3b1239c2ee12 user: Dmitry Volyntsev date: Thu Jan 17 17:01:22 2019 +0300 description: Setting exit index for try_return instruction is simplified. diffstat: njs/njs_generator.c | 57 ++++++++++++---------------------------------------- 1 files changed, 13 insertions(+), 44 deletions(-) diffs (175 lines): diff -r 2e9bdb42b3e6 -r 3b1239c2ee12 njs/njs_generator.c --- a/njs/njs_generator.c Thu Jan 17 16:12:46 2019 +0300 +++ b/njs/njs_generator.c Thu Jan 17 17:01:22 2019 +0300 @@ -20,11 +20,6 @@ struct njs_generator_patch_s { */ njs_ret_t jump_offset; njs_generator_patch_t *next; - /* - * index_offset is used for patching vmcode_try_return instruction - * inside try blocks. - */ - njs_index_t index_offset; }; @@ -47,6 +42,8 @@ struct njs_generator_block_s { njs_generator_patch_t *continuation; njs_generator_patch_t *exit; njs_generator_block_t *next; + + njs_index_t index; }; @@ -87,8 +84,6 @@ static nxt_int_t njs_generate_make_conti njs_generator_t *generator, njs_generator_block_t *block, njs_ret_t offset); static nxt_noinline void njs_generate_patch_block(njs_vm_t *vm, njs_generator_t *generator, njs_generator_patch_t *list); -static nxt_noinline void njs_generate_patch_try_exit_block(njs_vm_t *vm, - njs_generator_t *generator, njs_generator_patch_t *list, njs_index_t dest); static nxt_int_t njs_generate_make_exit_patch(njs_vm_t *vm, njs_generator_t *generator, njs_generator_block_t *block, njs_ret_t offset); static nxt_noinline void njs_generate_patch_block_exit(njs_vm_t *vm, @@ -891,7 +886,6 @@ njs_generate_switch_statement(njs_vm_t * return NXT_ERROR; } - patch->index_offset = 0; patch->jump_offset = njs_code_offset(generator, equal) + offsetof(njs_vmcode_equal_jump_t, offset); @@ -1277,6 +1271,8 @@ njs_generate_start_block(njs_vm_t *vm, n block->continuation = NULL; block->exit = NULL; + block->index = 0; + return NXT_OK; } @@ -1315,7 +1311,6 @@ njs_generate_make_continuation_patch(njs patch->next = block->continuation; block->continuation = patch; - patch->index_offset = 0; patch->jump_offset = offset; return NXT_OK; @@ -1337,25 +1332,6 @@ njs_generate_patch_block(njs_vm_t *vm, n } -static nxt_noinline void -njs_generate_patch_try_exit_block(njs_vm_t *vm, njs_generator_t *generator, - njs_generator_patch_t *list, njs_index_t dest) -{ - njs_generator_patch_t *patch, *next; - - for (patch = list; patch != NULL; patch = next) { - njs_code_update_offset(generator, patch); - next = patch->next; - - if (patch->index_offset != 0) { - *(njs_code_ptr(generator, njs_index_t, patch->index_offset)) = dest; - } - - nxt_mem_cache_free(vm->mem_cache_pool, patch); - } -} - - static nxt_int_t njs_generate_make_exit_patch(njs_vm_t *vm, njs_generator_t *generator, njs_generator_block_t *block, njs_ret_t offset) @@ -1372,7 +1348,6 @@ njs_generate_make_exit_patch(njs_vm_t *v patch->next = block->exit; block->exit = patch; - patch->index_offset = 0; patch->jump_offset = offset; return NXT_OK; @@ -1429,7 +1404,6 @@ njs_generate_continue_statement(njs_vm_t jump->code.retval = NJS_VMCODE_NO_RETVAL; jump->offset = offsetof(njs_vmcode_jump_t, offset); - patch->index_offset = 0; patch->jump_offset = njs_code_offset(generator, jump) + offsetof(njs_vmcode_jump_t, offset); } @@ -1480,7 +1454,6 @@ njs_generate_break_statement(njs_vm_t *v jump->code.retval = NJS_VMCODE_NO_RETVAL; jump->offset = offsetof(njs_vmcode_jump_t, offset); - patch->index_offset = 0; patch->jump_offset = njs_code_offset(generator, jump) + offsetof(njs_vmcode_jump_t, offset); } @@ -2533,10 +2506,7 @@ njs_generate_return_statement(njs_vm_t * try_return->code.operands = NJS_VMCODE_2OPERANDS; try_return->code.retval = NJS_VMCODE_RETVAL; try_return->retval = index; - - try_return->save = index; - patch->index_offset = njs_code_offset(generator, try_return) - + offsetof(njs_vmcode_try_return_t, save); + try_return->save = block->index; try_return->offset = offsetof(njs_vmcode_try_return_t, offset); patch->jump_offset = njs_code_offset(generator, try_return) @@ -2739,13 +2709,14 @@ njs_generate_try_statement(njs_vm_t *vm, return ret; } + try_block = generator->block; + try_block->index = exit_index; + ret = njs_generator(vm, generator, node->left); if (nxt_slow_path(ret != NXT_OK)) { return ret; } - try_block = generator->block; - njs_generate_code(generator, njs_vmcode_try_end_t, try_end); try_end_offset = njs_code_offset(generator, try_end); try_end->code.operation = njs_vmcode_try_end; @@ -2753,8 +2724,7 @@ njs_generate_try_statement(njs_vm_t *vm, try_end->code.retval = NJS_VMCODE_NO_RETVAL; if (try_block->exit != NULL) { - njs_generate_patch_try_exit_block(vm, generator, try_block->exit, - exit_index); + njs_generate_patch_block(vm, generator, try_block->exit); njs_generate_code(generator, njs_vmcode_try_trampoline_t, try_break); try_break->code.operation = njs_vmcode_try_break; @@ -2876,13 +2846,14 @@ njs_generate_try_statement(njs_vm_t *vm, return ret; } + catch_block = generator->block; + catch_block->index = exit_index; + ret = njs_generator(vm, generator, node->left->right); if (nxt_slow_path(ret != NXT_OK)) { return ret; } - catch_block = generator->block; - njs_generate_code(generator, njs_vmcode_try_end_t, catch_end); catch_end_offset = njs_code_offset(generator, catch_end); catch_end->code.operation = njs_vmcode_try_end; @@ -2890,9 +2861,7 @@ njs_generate_try_statement(njs_vm_t *vm, catch_end->code.retval = NJS_VMCODE_NO_RETVAL; if (catch_block->exit != NULL) { - njs_generate_patch_try_exit_block(vm, generator, - catch_block->exit, - exit_index); + njs_generate_patch_block(vm, generator, catch_block->exit); njs_generate_code(generator, njs_vmcode_try_trampoline_t, try_break); From pluknet at nginx.com Thu Jan 17 15:18:29 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Thu, 17 Jan 2019 18:18:29 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <20190117132251.GI99070@mdounin.ru> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> Message-ID: <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> > On 17 Jan 2019, at 16:22, Maxim Dounin wrote: > > Hello! > > On Thu, Jan 17, 2019 at 01:29:56PM +0300, Sergey Kandaurov wrote: > >> >> >>> On 17 Jan 2019, at 08:43, Sepherosa Ziehau wrote: >>> >>> What's the preferred way to handle this? I am not sure whether you >>> guys allow __FreeBSD_version testing etc. >>> >> >> This could be solved with autotests. > > As long as we only care about different FreeBSD versions, this > might as well be an auto/os/freebsd test based on $version, or > just a define based on __FreeBSD_version in > src/os/unix/ngx_freebsd_config.h. > >> # HG changeset patch >> # User Sergey Kandaurov >> # Date 1547720890 0 >> # Thu Jan 17 10:28:10 2019 +0000 >> # Node ID d28513cd71bce227b4e159b7a3f518aa504232f0 >> # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 >> Fixed portability issues with union sigval. >> >> The sival_ptr field is now preferably used. >> >> diff --git a/auto/unix b/auto/unix >> --- a/auto/unix >> +++ b/auto/unix >> @@ -523,6 +523,7 @@ if [ $NGX_FILE_AIO = YES ]; then >> ngx_feature_libs= >> ngx_feature_test="struct aiocb iocb; >> iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; >> + iocb.aio_sigevent.sigev_value.sival_ptr = NULL; >> (void) aio_read(&iocb)" >> . auto/feature >> >> @@ -532,6 +533,22 @@ if [ $NGX_FILE_AIO = YES ]; then >> >> if [ $ngx_found = no ]; then >> >> + ngx_feature="kqueue AIO support (legacy)" >> + ngx_feature_name="NGX_HAVE_FILE_AIO_LEGACY" >> + ngx_feature_test="struct aiocb iocb; >> + iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; >> + iocb.aio_sigevent.sigev_value.sigval_ptr = NULL; >> + (void) aio_read(&iocb)" >> + . auto/feature > > Note that this will test for "kqueue AIO support (legacy)" on each > Linux build with aio. That is unfortunate. >> + >> + if [ $ngx_found = yes ]; then >> + CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS" >> + have=NGX_HAVE_FILE_AIO . auto/have >> + fi >> + fi >> + >> + if [ $ngx_found = no ]; then >> + >> ngx_feature="Linux AIO support" >> ngx_feature_name="NGX_HAVE_FILE_AIO" >> ngx_feature_run=no >> diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c >> --- a/src/os/unix/ngx_file_aio_read.c >> +++ b/src/os/unix/ngx_file_aio_read.c >> @@ -110,8 +110,12 @@ ngx_file_aio_read(ngx_file_t *file, u_ch >> #if (NGX_HAVE_KQUEUE) >> aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; >> aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; >> +#if !(NGX_HAVE_FILE_AIO_LEGACY) >> + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; >> +#else >> aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; >> #endif >> +#endif >> ev->handler = ngx_file_aio_event_handler; >> >> n = aio_read(&aio->aiocb); > > A simplier solution might be to always use sival_ptr, and define > it to sigval_ptr on old FreeBSDs. This looks simpler indeed. > Alternatively, we can consider dropping file AIO support for these > old FreeBSD versions. This shouldn't be a big deal as this is an > optional feature which is not enabled by default. And that's what I'd prefer for --test-build-eventport workaround. What about these patches? For DragonFly this should effectively match initial submission. # HG changeset patch # User Sergey Kandaurov # Date 1547734251 0 # Thu Jan 17 14:10:51 2019 +0000 # Node ID baab2b35e8cc79cfdf9924d1752348e97c1da13e # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 Fixed portability issues with union sigval. diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c --- a/src/os/unix/ngx_file_aio_read.c +++ b/src/os/unix/ngx_file_aio_read.c @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch #if (NGX_HAVE_KQUEUE) aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; #endif ev->handler = ngx_file_aio_event_handler; diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -91,6 +91,10 @@ #if (NGX_HAVE_FILE_AIO) #include typedef struct aiocb ngx_aiocb_t; + +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) +#define sival_ptr sigval_ptr +#endif #endif # HG changeset patch # User Sergey Kandaurov # Date 1547736673 0 # Thu Jan 17 14:51:13 2019 +0000 # Node ID c66911fc9924a60bb5d691ca00bc2fb1c3032866 # Parent baab2b35e8cc79cfdf9924d1752348e97c1da13e Removed --test-build-eventport workaround for old FreeBSD versions. diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c --- a/src/event/modules/ngx_eventport_module.c +++ b/src/event/modules/ngx_eventport_module.c @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n ngx_memzero(&sev, sizeof(struct sigevent)); sev.sigev_notify = SIGEV_PORT; -#if !(NGX_TEST_BUILD_EVENTPORT) sev.sigev_value.sival_ptr = &pn; -#endif if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, -- Sergey Kandaurov From yuchen at cloudflare.com Thu Jan 17 19:28:54 2019 From: yuchen at cloudflare.com (Yuchen Wu) Date: Thu, 17 Jan 2019 11:28:54 -0800 Subject: [PATCH] Be consistent with keepalive during graceful shutdown Message-ID: <8a6290c41b33c664d52d.1547753334@YuchenDev> # HG changeset patch # User Yuchen Wu # Date 1547749157 28800 # Thu Jan 17 10:19:17 2019 -0800 # Node ID 8a6290c41b33c664d52d7a472400381e71ecf171 # Parent 8acaa1161783347106dcaea574837e441e13b540 Be consistent with keepalive during graceful shutdown Before, when nginx sends the Connection: Keep-Alive header and then nginx decides to shutdown, it will close the connection. Downstream may already reuse the connection for another request in the meanwhile. This change allows one extra use of such a connection to make sure it is closed cleanly. diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_header_filter_module.c --- a/src/http/ngx_http_header_filter_module.c Thu Dec 27 19:37:34 2018 +0300 +++ b/src/http/ngx_http_header_filter_module.c Thu Jan 17 10:19:17 2019 -0800 @@ -187,6 +187,10 @@ r->header_only = 1; } + if (ngx_terminate || ngx_exiting) { + r->keepalive = 0; + } + if (r->headers_out.last_modified_time != -1) { if (r->headers_out.status != NGX_HTTP_OK && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c Thu Dec 27 19:37:34 2018 +0300 +++ b/src/http/ngx_http_request.c Thu Jan 17 10:19:17 2019 -0800 @@ -2611,9 +2611,7 @@ r->lingering_close = 1; } - if (!ngx_terminate - && !ngx_exiting - && r->keepalive + if (r->keepalive && clcf->keepalive_timeout > 0) { ngx_http_set_keepalive(r); From hungnv at opensource.com.vn Fri Jan 18 02:28:00 2019 From: hungnv at opensource.com.vn (Hung Nguyen) Date: Fri, 18 Jan 2019 09:28:00 +0700 Subject: post handler json data In-Reply-To: References: Message-ID: <654CEB36-9C6F-410F-B514-B056B437F9CA@opensource.com.vn> Hello, With this type of purpose I personally think you should take a look at njs instead of writing nginx module. Json can be done easier with JS -- H?ng > On Jan 17, 2019, at 20:57, Manickam wrote: > > Hi, > > I am new to Nginx development and looking for simple module which just dumps the input (json format) as is. Looked at different examples available on net and none of them deals with handling post data. May be i am missing something and any help is appreciated. > > Thanks in advance > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel From sepherosa at gmail.com Fri Jan 18 07:39:50 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Fri, 18 Jan 2019 15:39:50 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> Message-ID: Hi, > diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h > --- a/src/os/unix/ngx_freebsd_config.h > +++ b/src/os/unix/ngx_freebsd_config.h > @@ -91,6 +91,10 @@ > #if (NGX_HAVE_FILE_AIO) > #include > typedef struct aiocb ngx_aiocb_t; > + > +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) > +#define sival_ptr sigval_ptr > +#endif > #endif Will the following code be more straightforward? #if defined(__FreeBSD__) && (__FreeBSD_version < 700005) #define sival_ptr sigval_ptr #endif Thanks, sephe -- Tomorrow Will Never Die From pluknet at nginx.com Fri Jan 18 10:22:39 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Fri, 18 Jan 2019 13:22:39 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> Message-ID: <80C7E6D7-4FBE-471B-A53D-D0FB777EA88E@nginx.com> > On 18 Jan 2019, at 10:39, Sepherosa Ziehau wrote: > > Hi, > >> diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h >> --- a/src/os/unix/ngx_freebsd_config.h >> +++ b/src/os/unix/ngx_freebsd_config.h >> @@ -91,6 +91,10 @@ >> #if (NGX_HAVE_FILE_AIO) >> #include >> typedef struct aiocb ngx_aiocb_t; >> + >> +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) >> +#define sival_ptr sigval_ptr >> +#endif >> #endif > > Will the following code be more straightforward? > #if defined(__FreeBSD__) && (__FreeBSD_version < 700005) > #define sival_ptr sigval_ptr > #endif This won't work. __FreeBSD__ and__FreeBSD_version are defined for DragonFly in src/core/ngx_config.h. -- Sergey Kandaurov From xeioex at nginx.com Fri Jan 18 11:51:13 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Fri, 18 Jan 2019 11:51:13 +0000 Subject: [njs] Style. Message-ID: details: https://hg.nginx.org/njs/rev/1ebf0773c44f branches: changeset: 733:1ebf0773c44f user: Dmitry Volyntsev date: Fri Jan 18 14:50:50 2019 +0300 description: Style. diffstat: njs/njs_extern.c | 2 +- njs/njs_generator.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diffs (24 lines): diff -r 3b1239c2ee12 -r 1ebf0773c44f njs/njs_extern.c --- a/njs/njs_extern.c Thu Jan 17 17:01:22 2019 +0300 +++ b/njs/njs_extern.c Fri Jan 18 14:50:50 2019 +0300 @@ -173,7 +173,7 @@ njs_vm_external_prototype(njs_vm_t *vm, nxt_int_t njs_vm_external_create(njs_vm_t *vm, njs_value_t *ext_val, - const njs_extern_t *proto, njs_external_ptr_t object) + const njs_extern_t *proto, njs_external_ptr_t object) { void *obj; diff -r 3b1239c2ee12 -r 1ebf0773c44f njs/njs_generator.c --- a/njs/njs_generator.c Thu Jan 17 17:01:22 2019 +0300 +++ b/njs/njs_generator.c Fri Jan 18 14:50:50 2019 +0300 @@ -817,7 +817,7 @@ njs_generate_switch_statement(njs_vm_t * njs_parser_node_t *node, *expr, *branch; njs_vmcode_move_t *move; njs_vmcode_jump_t *jump; - njs_generator_patch_t *patch, *next, *patches, **last; + njs_generator_patch_t *patch, *next, *patches, **last; njs_vmcode_equal_jump_t *equal; /* The "switch" expression. */ From xeioex at nginx.com Fri Jan 18 12:28:32 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Fri, 18 Jan 2019 12:28:32 +0000 Subject: [njs] Removed unused vm->scratch field. Message-ID: details: https://hg.nginx.org/njs/rev/0813395557b6 branches: changeset: 734:0813395557b6 user: Dmitry Volyntsev date: Fri Jan 18 15:28:17 2019 +0300 description: Removed unused vm->scratch field. diffstat: njs/njs_vm.h | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diffs (16 lines): diff -r 1ebf0773c44f -r 0813395557b6 njs/njs_vm.h --- a/njs/njs_vm.h Fri Jan 18 14:50:50 2019 +0300 +++ b/njs/njs_vm.h Fri Jan 18 15:28:17 2019 +0300 @@ -1021,12 +1021,6 @@ struct njs_vm_s { /* njs_vm_t must be aligned to njs_value_t due to scratch value. */ njs_value_t retval; - /* - * The scratch value is used for lvalue operations on nonexistent - * properties of non-object values: "a = 1; a.b++". - */ - njs_value_t scratch; - u_char *current; njs_value_t *scopes[NJS_SCOPES]; From mdounin at mdounin.ru Mon Jan 21 15:17:16 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Mon, 21 Jan 2019 18:17:16 +0300 Subject: [PATCH] Be consistent with keepalive during graceful shutdown In-Reply-To: <8a6290c41b33c664d52d.1547753334@YuchenDev> References: <8a6290c41b33c664d52d.1547753334@YuchenDev> Message-ID: <20190121151716.GB1877@mdounin.ru> Hello! On Thu, Jan 17, 2019 at 11:28:54AM -0800, Yuchen Wu via nginx-devel wrote: > # HG changeset patch > # User Yuchen Wu > # Date 1547749157 28800 > # Thu Jan 17 10:19:17 2019 -0800 > # Node ID 8a6290c41b33c664d52d7a472400381e71ecf171 > # Parent 8acaa1161783347106dcaea574837e441e13b540 > Be consistent with keepalive during graceful shutdown > > Before, when nginx sends the Connection: Keep-Alive header and then > nginx decides to shutdown, it will close the connection. Downstream > may already reuse the connection for another request in the meanwhile. > > This change allows one extra use of such a connection to make sure it > is closed cleanly. > > diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_header_filter_module.c > --- a/src/http/ngx_http_header_filter_module.c Thu Dec 27 19:37:34 2018 +0300 > +++ b/src/http/ngx_http_header_filter_module.c Thu Jan 17 10:19:17 2019 -0800 > @@ -187,6 +187,10 @@ > r->header_only = 1; > } > > + if (ngx_terminate || ngx_exiting) { > + r->keepalive = 0; > + } > + > if (r->headers_out.last_modified_time != -1) { > if (r->headers_out.status != NGX_HTTP_OK > && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT > diff -r 8acaa1161783 -r 8a6290c41b33 src/http/ngx_http_request.c > --- a/src/http/ngx_http_request.c Thu Dec 27 19:37:34 2018 +0300 > +++ b/src/http/ngx_http_request.c Thu Jan 17 10:19:17 2019 -0800 > @@ -2611,9 +2611,7 @@ > r->lingering_close = 1; > } > > - if (!ngx_terminate > - && !ngx_exiting > - && r->keepalive > + if (r->keepalive > && clcf->keepalive_timeout > 0) > { > ngx_http_set_keepalive(r); Thank you for the patch. Some notes, in no particular order: - As per HTTP RFC, clients are expected to be prepared to connection close even if there is no "Connection: close" header, https://tools.ietf.org/html/rfc2616#section-8.1.4: A client, server, or proxy MAY close the transport connection at any time. For example, a client might have started to send a new request at the same time that the server has decided to close the "idle" connection. From the server's point of view, the connection is being closed while it was idle, but from the client's point of view, a request is in progress. This means that clients, servers, and proxies MUST be able to recover from asynchronous close events. Client software SHOULD reopen the transport connection and retransmit the aborted sequence of requests without user interaction so long as the request sequence is idempotent (see section 9.1.2). Given this, nginx more or less doesn't care when it closes idle (keepalive) connections. In particular, it does so when keepalive_timeout expires (which can be quite low), on graceful shutdown of worker process, and also when there isn't enough worker_connections. - Waiting for another request on graceful shutdown means that old worker processes will be running for keepalive_timeout time even if there are no requests in progress. While this might not be important for configurations where are requests in progress for significantly longer time, this is an important change for configurations where normally no in-progress requests and so configuration reloads are more or less immediate now. This should be carefully considered before changing the behaviour (if at all). - The patch suggested introduces inconsistency between handling of connections which were moved to keepalive before shutdown was requested, and connections which are moving to keepalive after this point. - The patch suggested introduces connections which are in idle state, yet not closed after a shutdown request. There should be no such connections, and the fact that such connections are not closed immediately is a result of an optimization, see http://hg.nginx.org/nginx/rev/5e6142609e48. If you want to improve keepalive connection handling on shutdown / configuration reload, you may want to focus on less intrusive changes, in particular: - Reset r->keepalive on shutdown if it is still possible (as ngx_http_header_filter_module.c part of your patch does). - Try to process pipelined requests if there are any if nginx worker is shutting down but wasn't yet able to announce "Connection: close" to the client. -- Maxim Dounin http://mdounin.ru/ From mdounin at mdounin.ru Tue Jan 22 14:54:29 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Tue, 22 Jan 2019 17:54:29 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> Message-ID: <20190122145429.GE1877@mdounin.ru> Hello! On Thu, Jan 17, 2019 at 06:18:29PM +0300, Sergey Kandaurov wrote: > > > On 17 Jan 2019, at 16:22, Maxim Dounin wrote: > > > > Hello! > > > > On Thu, Jan 17, 2019 at 01:29:56PM +0300, Sergey Kandaurov wrote: > > > >> > >> > >>> On 17 Jan 2019, at 08:43, Sepherosa Ziehau wrote: > >>> > >>> What's the preferred way to handle this? I am not sure whether you > >>> guys allow __FreeBSD_version testing etc. > >>> > >> > >> This could be solved with autotests. > > > > As long as we only care about different FreeBSD versions, this > > might as well be an auto/os/freebsd test based on $version, or > > just a define based on __FreeBSD_version in > > src/os/unix/ngx_freebsd_config.h. > > > >> # HG changeset patch > >> # User Sergey Kandaurov > >> # Date 1547720890 0 > >> # Thu Jan 17 10:28:10 2019 +0000 > >> # Node ID d28513cd71bce227b4e159b7a3f518aa504232f0 > >> # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 > >> Fixed portability issues with union sigval. > >> > >> The sival_ptr field is now preferably used. > >> > >> diff --git a/auto/unix b/auto/unix > >> --- a/auto/unix > >> +++ b/auto/unix > >> @@ -523,6 +523,7 @@ if [ $NGX_FILE_AIO = YES ]; then > >> ngx_feature_libs= > >> ngx_feature_test="struct aiocb iocb; > >> iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > >> + iocb.aio_sigevent.sigev_value.sival_ptr = NULL; > >> (void) aio_read(&iocb)" > >> . auto/feature > >> > >> @@ -532,6 +533,22 @@ if [ $NGX_FILE_AIO = YES ]; then > >> > >> if [ $ngx_found = no ]; then > >> > >> + ngx_feature="kqueue AIO support (legacy)" > >> + ngx_feature_name="NGX_HAVE_FILE_AIO_LEGACY" > >> + ngx_feature_test="struct aiocb iocb; > >> + iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > >> + iocb.aio_sigevent.sigev_value.sigval_ptr = NULL; > >> + (void) aio_read(&iocb)" > >> + . auto/feature > > > > Note that this will test for "kqueue AIO support (legacy)" on each > > Linux build with aio. > > That is unfortunate. > > >> + > >> + if [ $ngx_found = yes ]; then > >> + CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS" > >> + have=NGX_HAVE_FILE_AIO . auto/have > >> + fi > >> + fi > >> + > >> + if [ $ngx_found = no ]; then > >> + > >> ngx_feature="Linux AIO support" > >> ngx_feature_name="NGX_HAVE_FILE_AIO" > >> ngx_feature_run=no > >> diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c > >> --- a/src/os/unix/ngx_file_aio_read.c > >> +++ b/src/os/unix/ngx_file_aio_read.c > >> @@ -110,8 +110,12 @@ ngx_file_aio_read(ngx_file_t *file, u_ch > >> #if (NGX_HAVE_KQUEUE) > >> aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; > >> aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > >> +#if !(NGX_HAVE_FILE_AIO_LEGACY) > >> + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; > >> +#else > >> aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; > >> #endif > >> +#endif > >> ev->handler = ngx_file_aio_event_handler; > >> > >> n = aio_read(&aio->aiocb); > > > > A simplier solution might be to always use sival_ptr, and define > > it to sigval_ptr on old FreeBSDs. > > This looks simpler indeed. > > > Alternatively, we can consider dropping file AIO support for these > > old FreeBSD versions. This shouldn't be a big deal as this is an > > optional feature which is not enabled by default. > > And that's what I'd prefer for --test-build-eventport workaround. > > What about these patches? > For DragonFly this should effectively match initial submission. > > # HG changeset patch > # User Sergey Kandaurov > # Date 1547734251 0 > # Thu Jan 17 14:10:51 2019 +0000 > # Node ID baab2b35e8cc79cfdf9924d1752348e97c1da13e > # Parent 6d15e452fa2eaf19408e24a0d0fcc3a31344a289 > Fixed portability issues with union sigval. This needs to be extended with some background information - notably why it used to be sigval_ptr, and why to switch to sival_ptr. > > diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c > --- a/src/os/unix/ngx_file_aio_read.c > +++ b/src/os/unix/ngx_file_aio_read.c > @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch > #if (NGX_HAVE_KQUEUE) > aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; > aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; > + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; > #endif > ev->handler = ngx_file_aio_event_handler; > > diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h > --- a/src/os/unix/ngx_freebsd_config.h > +++ b/src/os/unix/ngx_freebsd_config.h > @@ -91,6 +91,10 @@ > #if (NGX_HAVE_FILE_AIO) > #include > typedef struct aiocb ngx_aiocb_t; > + > +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) > +#define sival_ptr sigval_ptr > +#endif > #endif > > Minor style nits: diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -89,12 +89,14 @@ #if (NGX_HAVE_FILE_AIO) + #include typedef struct aiocb ngx_aiocb_t; #if (__FreeBSD_version < 700005 && !defined __DragonFly__) -#define sival_ptr sigval_ptr +#define sival_ptr sigval_ptr #endif + #endif > # HG changeset patch > # User Sergey Kandaurov > # Date 1547736673 0 > # Thu Jan 17 14:51:13 2019 +0000 > # Node ID c66911fc9924a60bb5d691ca00bc2fb1c3032866 > # Parent baab2b35e8cc79cfdf9924d1752348e97c1da13e > Removed --test-build-eventport workaround for old FreeBSD versions. > > diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c > --- a/src/event/modules/ngx_eventport_module.c > +++ b/src/event/modules/ngx_eventport_module.c > @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n > > ngx_memzero(&sev, sizeof(struct sigevent)); > sev.sigev_notify = SIGEV_PORT; > -#if !(NGX_TEST_BUILD_EVENTPORT) > sev.sigev_value.sival_ptr = &pn; > -#endif > > if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, Looks fine. -- Maxim Dounin http://mdounin.ru/ From xeioex at nginx.com Tue Jan 22 15:09:08 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Tue, 22 Jan 2019 15:09:08 +0000 Subject: [njs] Improved setting vm->trace. Message-ID: details: https://hg.nginx.org/njs/rev/11cfd1d486f7 branches: changeset: 735:11cfd1d486f7 user: Dmitry Volyntsev date: Tue Jan 22 18:08:47 2019 +0300 description: Improved setting vm->trace. diffstat: njs/njs.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diffs (23 lines): diff -r 0813395557b6 -r 11cfd1d486f7 njs/njs.c --- a/njs/njs.c Fri Jan 18 15:28:17 2019 +0300 +++ b/njs/njs.c Tue Jan 22 18:08:47 2019 +0300 @@ -335,6 +335,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ nvm->mem_cache_pool = nmcp; nvm->shared = vm->shared; + nvm->trace = vm->trace; nvm->variables_hash = vm->variables_hash; nvm->values_hash = vm->values_hash; @@ -444,11 +445,6 @@ njs_vm_init(njs_vm_t *vm) vm->backtrace = backtrace; } - vm->trace.level = NXT_LEVEL_TRACE; - vm->trace.size = 2048; - vm->trace.handler = njs_parser_trace_handler; - vm->trace.data = vm; - if (njs_is_null(&vm->retval)) { vm->retval = njs_value_void; } From kahing at cloudflare.com Tue Jan 22 18:20:56 2019 From: kahing at cloudflare.com (Ka-Hing Cheung) Date: Tue, 22 Jan 2019 10:20:56 -0800 Subject: cache: move open to thread pool In-Reply-To: References: <20180808181653.GX56558@mdounin.ru> <20180810113946.GG56558@mdounin.ru> <20180903160903.GI56558@mdounin.ru> <4ba7414a-0eba-6bd3-5a50-2eca591ac25e@nginx.com> <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> Message-ID: Hi Maxim and Roman, We've been running a version of your patches in our test colo for the past week with no ill effects, with the caveat that it's difficult to measure performance impacts in our test colo because of varying traffic. We had to massage the patches a bit because we don't run vanilla nginx. Also we've only tried with open file cache disabled. Let me know if you are looking for other feedback. - Ka-Hing On Mon, Jan 14, 2019 at 5:53 PM Ka-Hing Cheung wrote: > > We didn't get to it last year because of other priorities but this is > being worked on. We don't use a vanilla nginx so it takes effort to > integrate your patches. Having a version of this in upstream nginx is > important to us and to me personally. > > On Thu, Jan 10, 2019 at 12:30 AM Maxim Konovalov wrote: > > > > So guys, are you really interested in this work beyond shiny > > marketing blog posts? > > > > On 05/12/2018 12:43, Maxim Konovalov wrote: > > > Hello, > > > > > > just a reminder that we are looking for a tester for these patches. > > > > > > Thanks, > > > > > > Maxim > > > > > > On 16/11/2018 12:10, Maxim Konovalov wrote: > > >> Thanks, Ka-Hing, we'll wait for your feedback. > > >> > > >> On 16/11/2018 01:53, Ka-Hing Cheung wrote: > > >>> Hi, > > >>> > > >>> I didn't forget about this. I am pretty swamped at the moment and > > >>> there's a holiday freeze coming up. Will get to his in December. > > >>> > > >>> - Ka-Hing > > >>> > > >>> On Thu, Nov 8, 2018 at 6:19 AM Maxim Konovalov wrote: > > >>>> > > >>>> Hi Ka-Hing, > > >>>> > > >>>> would you mind to test Roman's most recent patches that add > > >>>> "aio_open" directive? > > >>>> > > >>>> http://mailman.nginx.org/pipermail/nginx-devel/2018-November/011538.html > > >>>> > > >>>> We are looking for overall performance and stability metrics and > > >>>> feedback. > > >>>> > > >>>> Much appreciated, > > >>>> > > >>>> Maxim > > >>>> > > >>>> -- > > >>>> Maxim Konovalov > > >> > > >> > > > > > > > > > > > > -- > > Maxim Konovalov > > _______________________________________________ > > nginx-devel mailing list > > nginx-devel at nginx.org > > http://mailman.nginx.org/mailman/listinfo/nginx-devel From kahing at cloudflare.com Tue Jan 22 19:34:03 2019 From: kahing at cloudflare.com (Ka-Hing Cheung) Date: Tue, 22 Jan 2019 11:34:03 -0800 Subject: cache: move open to thread pool In-Reply-To: References: <20180808181653.GX56558@mdounin.ru> <20180810113946.GG56558@mdounin.ru> <20180903160903.GI56558@mdounin.ru> <4ba7414a-0eba-6bd3-5a50-2eca591ac25e@nginx.com> <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> Message-ID: I spoke too soon, just realized our test colo is running the patches without aio_open on. Flipping that switch now. Also, including the patch that we applied on top in addition to the massaging we did to resolve conflicts. I haven't dug too deep to see if stock nginx also requires similar changes or they are only necessary because of our other nginx changes: --- src/http/ngx_http_file_cache.c +++ src/http/ngx_http_file_cache.c @@ -611,6 +611,12 @@ ngx_http_do_file_cache_open(ngx_http_request_t *r, unsigned ignore_vary) return NGX_ERROR; } + c->buf = ngx_create_temp_buf(r->pool, c->body_start); + if (c->buf == NULL) { + return NGX_ERROR; + } + c->file.fd = NGX_INVALID_FILE; + if (!test) { /* * Either the request is cacheable but the file doesn't @@ -1148,6 +1154,7 @@ ngx_http_file_cache_aio_open(ngx_http_request_t *r, ngx_http_cache_t *c) ngx_memzero(&r->open_file_info, sizeof(ngx_open_file_info_t)); r->open_file_info.uniq = c->uniq; + r->open_file_info.fd = NGX_INVALID_FILE; r->open_file_info.valid = clcf->open_file_cache_valid; r->open_file_info.min_uses = clcf->open_file_cache_min_uses; r->open_file_info.events = clcf->open_file_cache_events; @@ -1205,11 +1212,6 @@ ngx_http_file_cache_aio_open(ngx_http_request_t *r, ngx_http_cache_t *c) c->length = r->open_file_info.size; c->fs_size = (r->open_file_info.fs_size + cache->bsize - 1) / cache->bsize; - c->buf = ngx_create_temp_buf(r->pool, c->body_start); - if (c->buf == NULL) { - return NGX_ERROR; - } - return NGX_OK; } On Tue, Jan 22, 2019 at 10:20 AM Ka-Hing Cheung wrote: > > Hi Maxim and Roman, > > We've been running a version of your patches in our test colo for the > past week with no ill effects, with the caveat that it's difficult to > measure performance impacts in our test colo because of varying > traffic. We had to massage the patches a bit because we don't run > vanilla nginx. Also we've only tried with open file cache disabled. > > Let me know if you are looking for other feedback. > > - Ka-Hing > > On Mon, Jan 14, 2019 at 5:53 PM Ka-Hing Cheung wrote: > > > > We didn't get to it last year because of other priorities but this is > > being worked on. We don't use a vanilla nginx so it takes effort to > > integrate your patches. Having a version of this in upstream nginx is > > important to us and to me personally. > > > > On Thu, Jan 10, 2019 at 12:30 AM Maxim Konovalov wrote: > > > > > > So guys, are you really interested in this work beyond shiny > > > marketing blog posts? > > > > > > On 05/12/2018 12:43, Maxim Konovalov wrote: > > > > Hello, > > > > > > > > just a reminder that we are looking for a tester for these patches. > > > > > > > > Thanks, > > > > > > > > Maxim > > > > > > > > On 16/11/2018 12:10, Maxim Konovalov wrote: > > > >> Thanks, Ka-Hing, we'll wait for your feedback. > > > >> > > > >> On 16/11/2018 01:53, Ka-Hing Cheung wrote: > > > >>> Hi, > > > >>> > > > >>> I didn't forget about this. I am pretty swamped at the moment and > > > >>> there's a holiday freeze coming up. Will get to his in December. > > > >>> > > > >>> - Ka-Hing > > > >>> > > > >>> On Thu, Nov 8, 2018 at 6:19 AM Maxim Konovalov wrote: > > > >>>> > > > >>>> Hi Ka-Hing, > > > >>>> > > > >>>> would you mind to test Roman's most recent patches that add > > > >>>> "aio_open" directive? > > > >>>> > > > >>>> http://mailman.nginx.org/pipermail/nginx-devel/2018-November/011538.html > > > >>>> > > > >>>> We are looking for overall performance and stability metrics and > > > >>>> feedback. > > > >>>> > > > >>>> Much appreciated, > > > >>>> > > > >>>> Maxim > > > >>>> > > > >>>> -- > > > >>>> Maxim Konovalov > > > >> > > > >> > > > > > > > > > > > > > > > > > -- > > > Maxim Konovalov > > > _______________________________________________ > > > nginx-devel mailing list > > > nginx-devel at nginx.org > > > http://mailman.nginx.org/mailman/listinfo/nginx-devel From maxim at nginx.com Wed Jan 23 12:39:02 2019 From: maxim at nginx.com (Maxim Konovalov) Date: Wed, 23 Jan 2019 15:39:02 +0300 Subject: cache: move open to thread pool In-Reply-To: References: <20180808181653.GX56558@mdounin.ru> <20180810113946.GG56558@mdounin.ru> <20180903160903.GI56558@mdounin.ru> <4ba7414a-0eba-6bd3-5a50-2eca591ac25e@nginx.com> <2a3577f6-4ad4-aa2d-80a2-7e9b715c070d@nginx.com> Message-ID: Hi Ka-Hing, Roman told me that the delta is because of your changes. Thanks for your time on that. Waiting for your testing results. Maxim On 22/01/2019 22:34, Ka-Hing Cheung via nginx-devel wrote: > I spoke too soon, just realized our test colo is running the patches > without aio_open on. Flipping that switch now. > > Also, including the patch that we applied on top in addition to the > massaging we did to resolve conflicts. I haven't dug too deep to see > if stock nginx also requires similar changes or they are only > necessary because of our other nginx changes: > [...] -- Maxim Konovalov From xeioex at nginx.com Wed Jan 23 17:39:30 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 23 Jan 2019 17:39:30 +0000 Subject: [njs] Simplified function parsing. Message-ID: details: https://hg.nginx.org/njs/rev/72fce46a7669 branches: changeset: 736:72fce46a7669 user: hongzhidao date: Wed Jan 23 19:48:19 2019 +0300 description: Simplified function parsing. Avoid creating phony parser structures while parsing function bodies. diffstat: njs/njs.c | 15 ++++++------- njs/njs_generator.c | 25 ++++++++++------------ njs/njs_generator.h | 2 +- njs/njs_parser.c | 58 +++++++++++++--------------------------------------- njs/njs_parser.h | 5 ++- 5 files changed, 37 insertions(+), 68 deletions(-) diffs (292 lines): diff -r 11cfd1d486f7 -r 72fce46a7669 njs/njs.c --- a/njs/njs.c Tue Jan 22 18:08:47 2019 +0300 +++ b/njs/njs.c Wed Jan 23 19:48:19 2019 +0300 @@ -217,11 +217,10 @@ njs_vm_destroy(njs_vm_t *vm) nxt_int_t njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end) { - nxt_int_t ret; - njs_lexer_t *lexer; - njs_parser_t *parser, *prev; - njs_generator_t *generator; - njs_parser_node_t *node; + nxt_int_t ret; + njs_lexer_t *lexer; + njs_parser_t *parser, *prev; + njs_generator_t *generator; parser = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_parser_t)); if (nxt_slow_path(parser == NULL)) { @@ -252,8 +251,8 @@ njs_vm_compile(njs_vm_t *vm, u_char **st vm->retval = njs_value_void; - node = njs_parser(vm, parser, prev); - if (nxt_slow_path(node == NULL)) { + ret = njs_parser(vm, parser, prev); + if (nxt_slow_path(ret != NXT_OK)) { goto fail; } @@ -279,7 +278,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st nxt_memzero(generator, sizeof(njs_generator_t)); - ret = njs_generate_scope(vm, generator, node); + ret = njs_generate_scope(vm, generator, parser->scope); if (nxt_slow_path(ret != NXT_OK)) { goto fail; } diff -r 11cfd1d486f7 -r 72fce46a7669 njs/njs_generator.c --- a/njs/njs_generator.c Tue Jan 22 18:08:47 2019 +0300 +++ b/njs/njs_generator.c Wed Jan 23 19:48:19 2019 +0300 @@ -2303,7 +2303,7 @@ njs_generate_function_scope(njs_vm_t *vm node = node->right; - ret = njs_generate_scope(vm, generator, node); + ret = njs_generate_scope(vm, generator, node->scope); if (nxt_fast_path(ret == NXT_OK)) { size = 0; @@ -2334,18 +2334,15 @@ njs_generate_function_scope(njs_vm_t *vm nxt_int_t njs_generate_scope(njs_vm_t *vm, njs_generator_t *generator, - njs_parser_node_t *node) + njs_parser_scope_t *scope) { - u_char *p; - size_t size; - uintptr_t scope_size; - nxt_int_t ret; - nxt_uint_t n; - njs_value_t *value; - njs_vm_code_t *code; - njs_parser_scope_t *scope; - - scope = node->scope; + u_char *p; + size_t size; + uintptr_t scope_size; + nxt_int_t ret; + nxt_uint_t n; + njs_value_t *value; + njs_vm_code_t *code; generator->code_size = 128; @@ -2357,12 +2354,12 @@ njs_generate_scope(njs_vm_t *vm, njs_gen generator->code_start = p; generator->code_end = p; - ret = njs_generate_argument_closures(vm, generator, node); + ret = njs_generate_argument_closures(vm, generator, scope->node); if (nxt_slow_path(ret != NXT_OK)) { return NXT_ERROR; } - if (nxt_slow_path(njs_generator(vm, generator, node) != NXT_OK)) { + if (nxt_slow_path(njs_generator(vm, generator, scope->node) != NXT_OK)) { return NXT_ERROR; } diff -r 11cfd1d486f7 -r 72fce46a7669 njs/njs_generator.h --- a/njs/njs_generator.h Tue Jan 22 18:08:47 2019 +0300 +++ b/njs/njs_generator.h Wed Jan 23 19:48:19 2019 +0300 @@ -29,7 +29,7 @@ struct njs_generator_s { nxt_int_t njs_generate_scope(njs_vm_t *vm, njs_generator_t *generator, - njs_parser_node_t *node); + njs_parser_scope_t *scope); #endif /* _NJS_GENERATOR_H_INCLUDED_ */ diff -r 11cfd1d486f7 -r 72fce46a7669 njs/njs_parser.c --- a/njs/njs_parser.c Tue Jan 22 18:08:47 2019 +0300 +++ b/njs/njs_parser.c Wed Jan 23 19:48:19 2019 +0300 @@ -23,8 +23,6 @@ static njs_token_t njs_parser_block(njs_ njs_parser_t *parser, njs_token_t token); static njs_token_t njs_parser_function_declaration(njs_vm_t *vm, njs_parser_t *parser); -static njs_parser_t *njs_parser_function_create(njs_vm_t *vm, - njs_parser_t *parent); static njs_token_t njs_parser_function_lambda(njs_vm_t *vm, njs_parser_t *parser, njs_function_lambda_t *lambda, njs_token_t token); static njs_token_t njs_parser_return_statement(njs_vm_t *vm, @@ -68,7 +66,7 @@ static njs_token_t njs_parser_unexpected njs_parser_t *parser, njs_token_t token); -njs_parser_node_t * +nxt_int_t njs_parser(njs_vm_t *vm, njs_parser_t *parser, njs_parser_t *prev) { njs_ret_t ret; @@ -81,7 +79,7 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p ret = njs_parser_scope_begin(vm, parser, NJS_SCOPE_GLOBAL); if (nxt_slow_path(ret != NXT_OK)) { - return NULL; + return NXT_ERROR; } if (prev != NULL) { @@ -111,7 +109,7 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p ret = nxt_lvlhsh_insert(variables, &lhq); if (nxt_slow_path(ret != NXT_OK)) { - return NULL; + return NXT_ERROR; } } } @@ -122,7 +120,7 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p token = njs_parser_statement_chain(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { - return NULL; + return NXT_ERROR; } if (token == NJS_TOKEN_CLOSE_BRACE && vm->options.trailer) { @@ -138,14 +136,16 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p node = njs_parser_node_alloc(vm); if (nxt_slow_path(node == NULL)) { - return NULL; + return NXT_ERROR; } } node->token = NJS_TOKEN_END; node->scope = parser->scope; - return node; + parser->scope->node = node; + + return NXT_OK; } @@ -545,15 +545,8 @@ njs_parser_function_declaration(njs_vm_t var->value.type = NJS_FUNCTION; var->value.data.truth = 1; - parser = njs_parser_function_create(vm, parser); - if (nxt_slow_path(parser == NULL)) { - return NJS_TOKEN_ERROR; - } - token = njs_parser_function_lambda(vm, parser, function->u.lambda, token); - vm->parser = parser->parent; - return token; } @@ -578,11 +571,6 @@ njs_parser_function_expression(njs_vm_t node->scope = parser->scope; parser->node = node; - parser = njs_parser_function_create(vm, parser); - if (nxt_slow_path(parser == NULL)) { - return NJS_TOKEN_ERROR; - } - token = njs_parser_token(parser); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; @@ -634,31 +622,10 @@ njs_parser_function_expression(njs_vm_t njs_parser_scope_end(vm, parser); - vm->parser = parser->parent; - return token; } -static njs_parser_t * -njs_parser_function_create(njs_vm_t *vm, njs_parser_t *parent) -{ - njs_parser_t *parser; - - parser = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_parser_t)); - if (nxt_slow_path(parser == NULL)) { - return NULL; - } - - parser->parent = parent; - parser->scope = parent->scope; - parser->lexer = parent->lexer; - vm->parser = parser; - - return parser; -} - - static njs_token_t njs_parser_function_lambda(njs_vm_t *vm, njs_parser_t *parser, njs_function_lambda_t *lambda, njs_token_t token) @@ -666,7 +633,7 @@ njs_parser_function_lambda(njs_vm_t *vm, njs_ret_t ret; njs_index_t index; njs_variable_t *arg; - njs_parser_node_t *node, *body, *last; + njs_parser_node_t *node, *body, *last, *parent; ret = njs_parser_scope_begin(vm, parser, NJS_SCOPE_FUNCTION); if (nxt_slow_path(ret != NXT_OK)) { @@ -744,6 +711,7 @@ njs_parser_function_lambda(njs_vm_t *vm, return token; } + parent = parser->node; parser->node = NULL; while (token != NJS_TOKEN_CLOSE_BRACE) { @@ -796,8 +764,12 @@ njs_parser_function_lambda(njs_vm_t *vm, node->right->token = NJS_TOKEN_RETURN; } - parser->parent->node->right = parser->node; + parent->right = parser->node; + parser->node->scope = parser->scope; + parser->scope->node = parser->node; + + parser->node = parent; njs_parser_scope_end(vm, parser); diff -r 11cfd1d486f7 -r 72fce46a7669 njs/njs_parser.h --- a/njs/njs_parser.h Tue Jan 22 18:08:47 2019 +0300 +++ b/njs/njs_parser.h Wed Jan 23 19:48:19 2019 +0300 @@ -232,6 +232,8 @@ typedef struct { struct njs_parser_scope_s { + njs_parser_node_t *node; + nxt_queue_link_t link; nxt_queue_t nested; @@ -289,7 +291,6 @@ struct njs_parser_s { njs_lexer_t *lexer; njs_parser_node_t *node; njs_parser_scope_t *scope; - njs_parser_t *parent; }; @@ -308,7 +309,7 @@ njs_token_t njs_lexer_keyword(njs_lexer_ njs_value_t *njs_parser_external(njs_vm_t *vm, njs_parser_t *parser); -njs_parser_node_t *njs_parser(njs_vm_t *vm, njs_parser_t *parser, +nxt_int_t njs_parser(njs_vm_t *vm, njs_parser_t *parser, njs_parser_t *prev); njs_token_t njs_parser_arguments(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *parent); From sepherosa at gmail.com Thu Jan 24 02:04:09 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Thu, 24 Jan 2019 10:04:09 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <80C7E6D7-4FBE-471B-A53D-D0FB777EA88E@nginx.com> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> <80C7E6D7-4FBE-471B-A53D-D0FB777EA88E@nginx.com> Message-ID: On Fri, Jan 18, 2019 at 6:22 PM Sergey Kandaurov wrote: > > > > > On 18 Jan 2019, at 10:39, Sepherosa Ziehau wrote: > > > > Hi, > > > >> diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h > >> --- a/src/os/unix/ngx_freebsd_config.h > >> +++ b/src/os/unix/ngx_freebsd_config.h > >> @@ -91,6 +91,10 @@ > >> #if (NGX_HAVE_FILE_AIO) > >> #include > >> typedef struct aiocb ngx_aiocb_t; > >> + > >> +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) > >> +#define sival_ptr sigval_ptr > >> +#endif > >> #endif > > > > Will the following code be more straightforward? > > #if defined(__FreeBSD__) && (__FreeBSD_version < 700005) > > #define sival_ptr sigval_ptr > > #endif > > This won't work. __FreeBSD__ and__FreeBSD_version > are defined for DragonFly in src/core/ngx_config.h. Aha, I see. Thank you. -- Tomorrow Will Never Die From sepherosa at gmail.com Thu Jan 24 02:07:57 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Thu, 24 Jan 2019 10:07:57 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <20190122145429.GE1877@mdounin.ru> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> <20190122145429.GE1877@mdounin.ru> Message-ID: On Tue, Jan 22, 2019 at 10:54 PM Maxim Dounin wrote: > This needs to be extended with some background information - > notably why it used to be sigval_ptr, and why to switch to > sival_ptr. I am not sure why it used to be sigval_ptr; seems to be a miss name in FreeBSD. And the code seems to assume having KQUEUE == having sigval_ptr. As about why the switching: - It's POSIX standard. - It was noticed recently in DragonFly, since we removed this compat field (sigval_ptr), since after scanning the source code in ports system, nginx seems to be the only one using sigval_ptr. Thanks, sephe > > > > > diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c > > --- a/src/os/unix/ngx_file_aio_read.c > > +++ b/src/os/unix/ngx_file_aio_read.c > > @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch > > #if (NGX_HAVE_KQUEUE) > > aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; > > aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; > > - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; > > + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; > > #endif > > ev->handler = ngx_file_aio_event_handler; > > > > diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h > > --- a/src/os/unix/ngx_freebsd_config.h > > +++ b/src/os/unix/ngx_freebsd_config.h > > @@ -91,6 +91,10 @@ > > #if (NGX_HAVE_FILE_AIO) > > #include > > typedef struct aiocb ngx_aiocb_t; > > + > > +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) > > +#define sival_ptr sigval_ptr > > +#endif > > #endif > > > > > > Minor style nits: > > diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h > --- a/src/os/unix/ngx_freebsd_config.h > +++ b/src/os/unix/ngx_freebsd_config.h > @@ -89,12 +89,14 @@ > > > #if (NGX_HAVE_FILE_AIO) > + > #include > typedef struct aiocb ngx_aiocb_t; > > #if (__FreeBSD_version < 700005 && !defined __DragonFly__) > -#define sival_ptr sigval_ptr > +#define sival_ptr sigval_ptr > #endif > + > #endif > > > > # HG changeset patch > > # User Sergey Kandaurov > > # Date 1547736673 0 > > # Thu Jan 17 14:51:13 2019 +0000 > > # Node ID c66911fc9924a60bb5d691ca00bc2fb1c3032866 > > # Parent baab2b35e8cc79cfdf9924d1752348e97c1da13e > > Removed --test-build-eventport workaround for old FreeBSD versions. > > > > diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c > > --- a/src/event/modules/ngx_eventport_module.c > > +++ b/src/event/modules/ngx_eventport_module.c > > @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n > > > > ngx_memzero(&sev, sizeof(struct sigevent)); > > sev.sigev_notify = SIGEV_PORT; > > -#if !(NGX_TEST_BUILD_EVENTPORT) > > sev.sigev_value.sival_ptr = &pn; > > -#endif > > > > if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { > > ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, > > Looks fine. > > -- > Maxim Dounin > http://mdounin.ru/ > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel -- Tomorrow Will Never Die From mdounin at mdounin.ru Thu Jan 24 14:59:14 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 17:59:14 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> <20190122145429.GE1877@mdounin.ru> Message-ID: <20190124145914.GN1877@mdounin.ru> Hello! On Thu, Jan 24, 2019 at 10:07:57AM +0800, Sepherosa Ziehau wrote: > On Tue, Jan 22, 2019 at 10:54 PM Maxim Dounin wrote: > > This needs to be extended with some background information - > > notably why it used to be sigval_ptr, and why to switch to > > sival_ptr. > > I am not sure why it used to be sigval_ptr; seems to be a miss name in > FreeBSD. And the code seems to assume having KQUEUE == having sigval_ptr. > > As about why the switching: > - It's POSIX standard. > - It was noticed recently in DragonFly, since we removed this compat > field (sigval_ptr), since after scanning the source code in ports > system, nginx seems to be the only one using sigval_ptr. Yes, Sergey have details on hand. It was renamed (likely by accident) in 1999 (FreeBSD 4.0) when introducing SA_SIGINFO support[1]. Standard-complaint name was restored in 2005 (first released in FreeBSD 7.0 in 2008), retaining compatibility with previous versions[2][3]. Similar changes were committed in DragonFly in 2009[4]. Since initial AIO support in nginx was introduced in 2003[5], it used the only name available at the moment. Switching to a standard name now is fine, especially giving that we can easily retain compatibility with previous versions. But at least some of these details need to be preserved in the commit log, and that's what I was asking Sergey about. [1] https://github.com/freebsd/freebsd/commit/53573bf465904188986e8c982e8019835628d6b2 [2] https://github.com/freebsd/freebsd/commit/ae161ac2394e00bb3afca0667a13243d7963dfe2 [3] https://github.com/freebsd/freebsd/commit/54f35995c2ce65f23beb667de4ccf3d68139a81a [4] https://gitweb.dragonflybsd.org/dragonfly.git/commit/36934016eeaca3abd418acb1c68bd391d3b54aa7 [5] http://hg.nginx.org/nginx/rev/738fe44c70d5 -- Maxim Dounin http://mdounin.ru/ From teward at thomas-ward.net Thu Jan 24 15:23:01 2019 From: teward at thomas-ward.net (Thomas Ward) Date: Thu, 24 Jan 2019 10:23:01 -0500 Subject: PCRE2 support? In-Reply-To: References: <20180918121231.843FC2C50D50@mail.nginx.com> <20180918155518.GQ56558@mdounin.ru> Message-ID: <0522327a-8b2c-f066-ddd6-392207ec6c1d@thomas-ward.net> It's been several more months, but now I need to ask what distributions you are 'supporting' here, Maxim and nginx team. PCRE2 is in Debian, Ubuntu, CentOS, Fedora, and others.? That covers a large portion of the major distributions at play. This has once again popped on my radar in Ubuntu as we are trying to move pcre3 out of Main, and rely on pcre2.? NGINX is one of the few packages that hasn't had any changes to it to make it PCRE2-supportable. I also agree that Exim should not be the basis of support. Is it possible to revisit this decision, and determine whether it is possible to support PCRE2 as it is now 2019 and many things seem to be switching to pcre2?? Otherwise, we have to either (1) Strip out PCRE support entirely in NGINX in Ubuntu, which would break most if not all regex functionality. (2) No longer consider nginx supported officially and drop it to community-only support (which means I will be once again doing all the work in Ubuntu to patch it, though this isn't new for me). I would like to ask that this be re-discussed and revisited since PCRE2 is far from 'new' and many things're switching to it, as well as it being present in multiple major distributions now. Thomas On 9/19/18 3:19 AM, Mark Mielke wrote: > On Tue, Sep 18, 2018 at 11:55 AM Maxim Dounin > wrote: > > On Tue, Sep 18, 2018 at 08:12:20AM -0400, Thomas Ward wrote: > > Downstream in Ubuntu, it has been proposed to demote pcre3 and > > use pcre2 instead as it is newer. > > https://trac.nginx.org/nginx/ticket/720 shows it was marked 4 > > years ago that NGINX does not support pcre2.? Are there any > > plans to use pcre2 instead of pcre3? > There are no immediate plans. > When we last checked, there were no problems with PCRE, but PCRE2 > wasn't available in most distributions we support, making the > switch mostly meaningless. > > > I think there have been changes since then. PCRE2 was new in 2015, but > isn't new in 2018. > > RHEL 7 (and clones) include libpcre2. I think this is a pretty wide > set of machines right here. I believe Ubuntu 16.04 LTS has libpcre2 > which is another wide set. Fedora has had it for a while now. I think > that unless you go to older releases, all major distributions should > have PCRE2 by now. > > I build haproxy with PCRE2 support. > > One that was interesting to me, is that Git recently (April, 2018?) > switched to building with PCRE2 by default when "USE_LIBPCRE=Yes" was > specified: > > https://github.com/git/git/commit/cac5351363c5713248b8494e1e58e282c0a5bde7 > > I'm not sure about meaningless from a functionality perspective. All > new features are going into PCRE2. PCRE is a stable branched with only > bug fixes and security problems fixed. The newest features, including > performance improvements, are all in PCRE2. I believe the reason it is > "PCRE2-10" instead of "PCRE-10", is because of API changes, and the > opportunity to improve or fix previous API decisions. This then > becomes the basis for all future development free of the PCRE API > shackles. > > ? > > > Also, it looks like PCRE2 is still not supported even by Exim, > which is the parent project of PCRE and PCRE2: > > https://bugs.exim.org/show_bug.cgi?id=1878 > > > I don't think Exim should be the measure: > > "PCRE was originally written for the?Exim MTA , > but is now used by many high-profile open source projects, > including?Apache ,?PHP > ,?KDE ,?Postfix > , and?Nmap . PCRE has also > found its way into some well known commercial products, like?Apple > Safari . Some other interesting > projects using PCRE include?Chicken > ,?Ferite > ,?Onyx > ,?Hypermail > ,?Leafnode > ,?Askemos > ,?Wenlin , and?8th > ." > > This list is also far from complete. PCRE and PCRE2 are widely used, > and PCRE2 is where all current improvement is occurring. Anybody > waiting for Exim, will probably be among the very last to switch. > > > As such, adding PCRE2 support to nginx looks premature. > > > > Before writing the above, I was debating with myself about when the > right time to add support for a new component release is. For some > projects and some components, it will be more important than others. > For example, OpenSSL 1.1.1 with TLSv1.3 support might be considered > premature for some projects to support, and yet Nginx supports this > newly released version long before OpenSSL 1.1.1 is readily available > in a majority of distributions that you support. I think in this case, > OpenSSL 1.1.1 is of strategic importance to Nginx, and this ensured it > was on the roadmap. (However, it still seems to be missing an ability > to configure the cipher suite... :-) ) > > I don't know if PCRE2 belongs on this roadmap. I think there have been > significant improvements with the JIT compilation that could prove > useful for higher performance evaluation of regular expressions with > Nginx, but I personally don't have this requirement, so if after > considering all of the above - you still felt it was premature, I > wouldn't raise any concern personally. I just want to make sure this > is an informed position. :-) > > -- > Mark Mielke > > > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdounin at mdounin.ru Thu Jan 24 18:21:22 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 21:21:22 +0300 Subject: PCRE2 support? In-Reply-To: <0522327a-8b2c-f066-ddd6-392207ec6c1d@thomas-ward.net> References: <20180918121231.843FC2C50D50@mail.nginx.com> <20180918155518.GQ56558@mdounin.ru> <0522327a-8b2c-f066-ddd6-392207ec6c1d@thomas-ward.net> Message-ID: <20190124182121.GP1877@mdounin.ru> Hello! On Thu, Jan 24, 2019 at 10:23:01AM -0500, Thomas Ward wrote: > It's been several more months, but now I need to ask what distributions > you are 'supporting' here, Maxim and nginx team. > > PCRE2 is in Debian, Ubuntu, CentOS, Fedora, and others.? That covers a > large portion of the major distributions at play. List of the Linux distributions most interesting for us can be found here: http://nginx.org/en/linux_packages.html It looks like most have PCRE2 now. Though obviously enough, there are at least some where there are no PCRE2, including Ubuntu 14.04 which is expected to be supported till April 2019, Debian 8, which is to be supported till 2020, and CentOS 6, which is to be supported till 2020 as well. > This has once again popped on my radar in Ubuntu as we are trying to > move pcre3 out of Main, and rely on pcre2.? NGINX is one of the few > packages that hasn't had any changes to it to make it PCRE2-supportable. So this is going to be the first real reason to actually support PCRE2. Patches are welcome. > I also agree that Exim should not be the basis of support. Well, this depends on your point of view. If a project which actually developed the library fails to introduce support to the new version of the library - for an external observer this suggests that there is something wrong with the new version. [...] -- Maxim Dounin http://mdounin.ru/ From pgnet.dev at gmail.com Thu Jan 24 18:47:48 2019 From: pgnet.dev at gmail.com (PGNet Dev) Date: Thu, 24 Jan 2019 10:47:48 -0800 Subject: PCRE2 support? In-Reply-To: <20190124182121.GP1877@mdounin.ru> References: <20180918121231.843FC2C50D50@mail.nginx.com> <20180918155518.GQ56558@mdounin.ru> <0522327a-8b2c-f066-ddd6-392207ec6c1d@thomas-ward.net> <20190124182121.GP1877@mdounin.ru> Message-ID: <5f5a8d73-77b5-bf62-d963-5e2927aa72e1@gmail.com> > Well, this depends on your point of view. If a project which > actually developed the library fails to introduce support to the > new version of the library - for an external observer this > suggests that there is something wrong with the new version. FUD 'suggestions' simply aren't needed. The Exim project didn't develop the pcre2 library ... Philip Hazel did (https://www.pcre.org/current/doc/html/pcre2.html#SEC4), as a separate project. Exim's last (? something newer out there?) rationale for not adopting it was simply, https://bugs.exim.org/show_bug.cgi?id=1878 "The original PCRE support is not broken. If it is going to go away, then adding PCRE2 support becomes much more important, but I've seen nobody saying that yet." Also of note, https://pcre.org/pcre.txt "The old libraries (now called PCRE1) are still being maintained for bug fixes, but there will be no new development. New projects are advised to use the new PCRE2 libraries." From mdounin at mdounin.ru Thu Jan 24 20:16:17 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 20:16:17 +0000 Subject: [nginx] Events: fixed copying of old events in poll init. Message-ID: details: https://hg.nginx.org/nginx/rev/e0e636ab10be branches: changeset: 7442:e0e636ab10be user: Maxim Dounin date: Thu Jan 24 21:50:37 2019 +0300 description: Events: fixed copying of old events in poll init. Previously, the code incorrectly assumed "ngx_event_t *" elements instead of "struct pollfd". This is mostly cosmetic change, as this code is never called now. diffstat: src/event/modules/ngx_poll_module.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c --- a/src/event/modules/ngx_poll_module.c +++ b/src/event/modules/ngx_poll_module.c @@ -84,7 +84,7 @@ ngx_poll_init(ngx_cycle_t *cycle, ngx_ms } if (event_list) { - ngx_memcpy(list, event_list, sizeof(ngx_event_t *) * nevents); + ngx_memcpy(list, event_list, sizeof(struct pollfd) * nevents); ngx_free(event_list); } From mdounin at mdounin.ru Thu Jan 24 20:16:18 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 20:16:18 +0000 Subject: [nginx] Win32: properly enabled select on Windows. Message-ID: details: https://hg.nginx.org/nginx/rev/f3ff79ae31d9 branches: changeset: 7443:f3ff79ae31d9 user: Maxim Dounin date: Thu Jan 24 21:51:00 2019 +0300 description: Win32: properly enabled select on Windows. Previously, select was compiled in by default, but the NGX_HAVE_SELECT macro was not set, resulting in iocp being used by default unless the "--with-select_module" configure option was explicitly specified. Since the iocp module is not finished and does not work properly, this effectively meant that the "--with-select_module" option was mandatory. With the change NGX_HAVE_SELECT is properly set, making "--with-select_module" optional. Accordingly, it is removed from misc/GNUmakefile win32 target. diffstat: auto/os/win32 | 1 + misc/GNUmakefile | 1 - 2 files changed, 1 insertions(+), 1 deletions(-) diffs (22 lines): diff --git a/auto/os/win32 b/auto/os/win32 --- a/auto/os/win32 +++ b/auto/os/win32 @@ -34,6 +34,7 @@ EVENT_MODULES="$EVENT_MODULES $IOCP_MODU EVENT_FOUND=YES if [ $EVENT_SELECT = NO ]; then + have=NGX_HAVE_SELECT . auto/have CORE_SRCS="$CORE_SRCS $SELECT_SRCS" EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE" fi diff --git a/misc/GNUmakefile b/misc/GNUmakefile --- a/misc/GNUmakefile +++ b/misc/GNUmakefile @@ -65,7 +65,6 @@ win32: --with-cc-opt=-DFD_SETSIZE=1024 \ --with-pcre=$(OBJS)/lib/$(PCRE) \ --with-zlib=$(OBJS)/lib/$(ZLIB) \ - --with-select_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ From mdounin at mdounin.ru Thu Jan 24 20:16:20 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 20:16:20 +0000 Subject: [nginx] Win32: added WSAPoll() support. Message-ID: details: https://hg.nginx.org/nginx/rev/4089b3d2cb59 branches: changeset: 7444:4089b3d2cb59 user: Maxim Dounin date: Thu Jan 24 21:51:21 2019 +0300 description: Win32: added WSAPoll() support. WSAPoll() is only available with Windows Vista and newer (and only available during compilation if _WIN32_WINNT >= 0x0600). To make sure the code works with Windows XP, we do not redefine _WIN32_WINNT, but instead load WSAPoll() dynamically if it is not available during compilation. Also, sockets are not guaranteed to be small integers on Windows. So an index array is used instead of NGX_USE_FD_EVENT to map events to connections. diffstat: auto/os/win32 | 1 + auto/sources | 1 + src/event/modules/ngx_win32_poll_module.c | 74 +++++++++++++++++++----------- src/os/win32/ngx_socket.h | 43 ++++++++++++++++++ src/os/win32/ngx_win32_init.c | 32 +++++++++++++ 5 files changed, 124 insertions(+), 27 deletions(-) diffs (322 lines): diff --git a/auto/os/win32 b/auto/os/win32 --- a/auto/os/win32 +++ b/auto/os/win32 @@ -11,6 +11,7 @@ CORE_SRCS="$WIN32_SRCS $IOCP_SRCS" OS_CONFIG="$WIN32_CONFIG" NGX_ICONS="$NGX_WIN32_ICONS" SELECT_SRCS=$WIN32_SELECT_SRCS +POLL_SRCS=$WIN32_POLL_SRCS ngx_pic_opt= ngx_binext=".exe" diff --git a/auto/sources b/auto/sources --- a/auto/sources +++ b/auto/sources @@ -106,6 +106,7 @@ WIN32_SELECT_SRCS=src/event/modules/ngx_ POLL_MODULE=ngx_poll_module POLL_SRCS=src/event/modules/ngx_poll_module.c +WIN32_POLL_SRCS=src/event/modules/ngx_win32_poll_module.c KQUEUE_MODULE=ngx_kqueue_module KQUEUE_SRCS=src/event/modules/ngx_kqueue_module.c diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_win32_poll_module.c copy from src/event/modules/ngx_poll_module.c copy to src/event/modules/ngx_win32_poll_module.c --- a/src/event/modules/ngx_poll_module.c +++ b/src/event/modules/ngx_win32_poll_module.c @@ -1,6 +1,7 @@ /* * Copyright (C) Igor Sysoev + * Copyright (C) Maxim Dounin * Copyright (C) Nginx, Inc. */ @@ -21,8 +22,9 @@ static ngx_int_t ngx_poll_process_events static char *ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf); -static struct pollfd *event_list; -static ngx_uint_t nevents; +static struct pollfd *event_list; +static ngx_connection_t **event_index; +static ngx_uint_t nevents; static ngx_str_t poll_name = ngx_string("poll"); @@ -67,7 +69,8 @@ ngx_module_t ngx_poll_module = { static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle, ngx_msec_t timer) { - struct pollfd *list; + struct pollfd *list; + ngx_connection_t **index; if (event_list == NULL) { nevents = 0; @@ -89,13 +92,27 @@ ngx_poll_init(ngx_cycle_t *cycle, ngx_ms } event_list = list; + + index = ngx_alloc(sizeof(ngx_connection_t *) * cycle->connection_n, + cycle->log); + if (index == NULL) { + return NGX_ERROR; + } + + if (event_index) { + ngx_memcpy(index, event_index, + sizeof(ngx_connection_t *) * nevents); + ngx_free(event_index); + } + + event_index = index; } ngx_io = ngx_os_io; ngx_event_actions = ngx_poll_module_ctx.actions; - ngx_event_flags = NGX_USE_LEVEL_EVENT|NGX_USE_FD_EVENT; + ngx_event_flags = NGX_USE_LEVEL_EVENT; return NGX_OK; } @@ -105,8 +122,10 @@ static void ngx_poll_done(ngx_cycle_t *cycle) { ngx_free(event_list); + ngx_free(event_index); event_list = NULL; + event_index = NULL; } @@ -143,10 +162,13 @@ ngx_poll_add_event(ngx_event_t *ev, ngx_ "poll add event: fd:%d ev:%i", c->fd, event); if (e == NULL || e->index == NGX_INVALID_INDEX) { + event_list[nevents].fd = c->fd; event_list[nevents].events = (short) event; event_list[nevents].revents = 0; + event_index[nevents] = c; + ev->index = nevents; nevents++; @@ -204,10 +226,11 @@ ngx_poll_del_event(ngx_event_t *ev, ngx_ "index: copy event %ui to %i", nevents, ev->index); event_list[ev->index] = event_list[nevents]; + event_index[ev->index] = event_index[nevents]; - c = ngx_cycle->files[event_list[nevents].fd]; + c = event_index[ev->index]; - if (c->fd == -1) { + if (c->fd == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_ALERT, ev->log, 0, "unexpected last event"); @@ -240,7 +263,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc { int ready, revents; ngx_err_t err; - ngx_uint_t i, found, level; + ngx_uint_t i, found; ngx_event_t *ev; ngx_queue_t *queue; ngx_connection_t *c; @@ -259,7 +282,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "poll timer: %M", timer); - ready = poll(event_list, (u_int) nevents, (int) timer); + ready = WSAPoll(event_list, (u_int) nevents, (int) timer); err = (ready == -1) ? ngx_errno : 0; @@ -271,20 +294,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc "poll ready %d of %ui", ready, nevents); if (err) { - if (err == NGX_EINTR) { - - if (ngx_event_timer_alarm) { - ngx_event_timer_alarm = 0; - return NGX_OK; - } - - level = NGX_LOG_INFO; - - } else { - level = NGX_LOG_ALERT; - } - - ngx_log_error(level, cycle->log, err, "poll() failed"); + ngx_log_error(NGX_LOG_ALERT, cycle->log, err, "WSAPoll() failed"); return NGX_ERROR; } @@ -294,7 +304,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc } ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, - "poll() returned no events without timeout"); + "WSAPoll() returned no events without timeout"); return NGX_ERROR; } @@ -326,7 +336,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc event_list[i].fd, event_list[i].events, revents); } - if (event_list[i].fd == -1) { + if (event_list[i].fd == (ngx_socket_t) -1) { /* * the disabled event, a workaround for our possible bug, * see the comment below @@ -334,9 +344,9 @@ ngx_poll_process_events(ngx_cycle_t *cyc continue; } - c = ngx_cycle->files[event_list[i].fd]; + c = event_index[i]; - if (c->fd == -1) { + if (c->fd == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "unexpected event"); /* @@ -347,7 +357,7 @@ ngx_poll_process_events(ngx_cycle_t *cyc if (i == nevents - 1) { nevents--; } else { - event_list[i].fd = -1; + event_list[i].fd = (ngx_socket_t) -1; } continue; @@ -411,5 +421,15 @@ ngx_poll_init_conf(ngx_cycle_t *cycle, v return NGX_CONF_OK; } +#if (NGX_LOAD_WSAPOLL) + + if (!ngx_have_wsapoll) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, + "poll is not available on this platform"); + return NGX_CONF_ERROR; + } + +#endif + return NGX_CONF_OK; } diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h --- a/src/os/win32/ngx_socket.h +++ b/src/os/win32/ngx_socket.h @@ -200,6 +200,49 @@ extern LPFN_CONNECTEX ngx_co extern LPFN_DISCONNECTEX ngx_disconnectex; +#if (NGX_HAVE_POLL && !defined POLLIN) + +/* + * WSAPoll() is only available if _WIN32_WINNT >= 0x0600. + * If it is not available during compilation, we try to + * load it dynamically at runtime. + */ + +#define NGX_LOAD_WSAPOLL 1 + +#define POLLRDNORM 0x0100 +#define POLLRDBAND 0x0200 +#define POLLIN (POLLRDNORM | POLLRDBAND) +#define POLLPRI 0x0400 + +#define POLLWRNORM 0x0010 +#define POLLOUT (POLLWRNORM) +#define POLLWRBAND 0x0020 + +#define POLLERR 0x0001 +#define POLLHUP 0x0002 +#define POLLNVAL 0x0004 + +typedef struct pollfd { + + SOCKET fd; + SHORT events; + SHORT revents; + +} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; + +typedef int (WSAAPI *ngx_wsapoll_pt)( + LPWSAPOLLFD fdArray, + ULONG fds, + INT timeout + ); + +extern ngx_wsapoll_pt WSAPoll; +extern ngx_uint_t ngx_have_wsapoll; + +#endif + + int ngx_tcp_push(ngx_socket_t s); #define ngx_tcp_push_n "tcp_push()" diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -58,6 +58,12 @@ static GUID cx_guid = WSAID_CONNECTEX; static GUID dx_guid = WSAID_DISCONNECTEX; +#if (NGX_LOAD_WSAPOLL) +ngx_wsapoll_pt WSAPoll; +ngx_uint_t ngx_have_wsapoll; +#endif + + ngx_int_t ngx_os_init(ngx_log_t *log) { @@ -223,6 +229,32 @@ ngx_os_init(ngx_log_t *log) ngx_close_socket_n " failed"); } +#if (NGX_LOAD_WSAPOLL) + { + HMODULE hmod; + + hmod = GetModuleHandle("ws2_32.dll"); + if (hmod == NULL) { + ngx_log_error(NGX_LOG_NOTICE, log, ngx_errno, + "GetModuleHandle(\"ws2_32.dll\") failed"); + goto nopoll; + } + + WSAPoll = (ngx_wsapoll_pt) GetProcAddress(hmod, "WSAPoll"); + if (WSAPoll == NULL) { + ngx_log_error(NGX_LOG_NOTICE, log, ngx_errno, + "GetProcAddress(\"WSAPoll\") failed"); + goto nopoll; + } + + ngx_have_wsapoll = 1; + + } + +nopoll: + +#endif + if (GetEnvironmentVariable("ngx_unique", ngx_unique, NGX_INT32_LEN + 1) != 0) { From mdounin at mdounin.ru Thu Jan 24 20:16:22 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 20:16:22 +0000 Subject: [nginx] Win32: enabled both select and poll on Windows by default. Message-ID: details: https://hg.nginx.org/nginx/rev/c9235164bbf1 branches: changeset: 7445:c9235164bbf1 user: Maxim Dounin date: Thu Jan 24 22:00:13 2019 +0300 description: Win32: enabled both select and poll on Windows by default. Since we now have both select and poll on Windows, it is enough to do not set EVENT_FOUND, auto/modules will enable both automatically. diffstat: auto/os/win32 | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-) diffs (18 lines): diff --git a/auto/os/win32 b/auto/os/win32 --- a/auto/os/win32 +++ b/auto/os/win32 @@ -32,13 +32,7 @@ case "$NGX_CC_NAME" in esac EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE" -EVENT_FOUND=YES - -if [ $EVENT_SELECT = NO ]; then - have=NGX_HAVE_SELECT . auto/have - CORE_SRCS="$CORE_SRCS $SELECT_SRCS" - EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE" -fi +#EVENT_FOUND=YES have=NGX_HAVE_INET6 . auto/have From mdounin at mdounin.ru Thu Jan 24 20:16:23 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 24 Jan 2019 20:16:23 +0000 Subject: [nginx] Win32: detection of connect() errors in select(). Message-ID: details: https://hg.nginx.org/nginx/rev/9234e8d61aa0 branches: changeset: 7446:9234e8d61aa0 user: Maxim Dounin date: Thu Jan 24 22:00:44 2019 +0300 description: Win32: detection of connect() errors in select(). On Windows, connect() errors are only reported via exceptfds descriptor set from select(). Previously exceptfds was set to NULL, and connect() errors were not detected at all, so connects to closed ports were waiting till a timeout occurred. Since ongoing connect() means that there will be a write event active, except descriptor set is copied from the write one. While it is possible to construct except descriptor set as a concatenation of both read and write descriptor sets, this looks unneeded. With this change, connect() errors are properly detected now when using select(). Note well that it is not possible to detect connect() errors with WSAPoll() (see https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/). diffstat: src/event/modules/ngx_win32_select_module.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diffs (56 lines): diff --git a/src/event/modules/ngx_win32_select_module.c b/src/event/modules/ngx_win32_select_module.c --- a/src/event/modules/ngx_win32_select_module.c +++ b/src/event/modules/ngx_win32_select_module.c @@ -26,6 +26,7 @@ static fd_set master_read_fd_set static fd_set master_write_fd_set; static fd_set work_read_fd_set; static fd_set work_write_fd_set; +static fd_set work_except_fd_set; static ngx_uint_t max_read; static ngx_uint_t max_write; @@ -251,9 +252,11 @@ ngx_select_process_events(ngx_cycle_t *c work_read_fd_set = master_read_fd_set; work_write_fd_set = master_write_fd_set; + work_except_fd_set = master_write_fd_set; if (max_read || max_write) { - ready = select(0, &work_read_fd_set, &work_write_fd_set, NULL, tp); + ready = select(0, &work_read_fd_set, &work_write_fd_set, + &work_except_fd_set, tp); } else { @@ -306,14 +309,20 @@ ngx_select_process_events(ngx_cycle_t *c if (ev->write) { if (FD_ISSET(c->fd, &work_write_fd_set)) { - found = 1; + found++; ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "select write %d", c->fd); } + if (FD_ISSET(c->fd, &work_except_fd_set)) { + found++; + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "select except %d", c->fd); + } + } else { if (FD_ISSET(c->fd, &work_read_fd_set)) { - found = 1; + found++; ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "select read %d", c->fd); } @@ -327,7 +336,7 @@ ngx_select_process_events(ngx_cycle_t *c ngx_post_event(ev, queue); - nready++; + nready += found; } } From mdounin at mdounin.ru Fri Jan 25 00:12:42 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Fri, 25 Jan 2019 03:12:42 +0300 Subject: PCRE2 support? In-Reply-To: <5f5a8d73-77b5-bf62-d963-5e2927aa72e1@gmail.com> References: <20180918121231.843FC2C50D50@mail.nginx.com> <20180918155518.GQ56558@mdounin.ru> <0522327a-8b2c-f066-ddd6-392207ec6c1d@thomas-ward.net> <20190124182121.GP1877@mdounin.ru> <5f5a8d73-77b5-bf62-d963-5e2927aa72e1@gmail.com> Message-ID: <20190125001242.GR1877@mdounin.ru> Hello! On Thu, Jan 24, 2019 at 10:47:48AM -0800, PGNet Dev wrote: > > Well, this depends on your point of view. If a project which > > actually developed the library fails to introduce support to the > > new version of the library - for an external observer this > > suggests that there is something wrong with the new version. > > FUD 'suggestions' simply aren't needed. Sure, they aren't. What is wrong with PCRE2 is clear from the very start: it's a different library with different API. And supporting PCRE2 is a question of advantages of PCRE2 over PCRE. > The Exim project didn't develop the pcre2 library ... Philip Hazel did > (https://www.pcre.org/current/doc/html/pcre2.html#SEC4), as a separate > project. Philip Hazel developed both Exim and the PCRE library, "originally written for the Exim MTA". And PCRE2 claims to be a "major version" of the PCRE library. > Exim's last (? something newer out there?) rationale for not adopting it > was simply, > > https://bugs.exim.org/show_bug.cgi?id=1878 > > "The original PCRE support is not broken. > > If it is going to go away, then adding PCRE2 support becomes much more > important, but I've seen nobody saying that yet." I've posted this link in my first response in this thread 4 month ago. The same rationale applies to any project already using the PCRE library. -- Maxim Dounin http://mdounin.ru/ From sepherosa at gmail.com Mon Jan 28 09:06:35 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Mon, 28 Jan 2019 17:06:35 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <20190124145914.GN1877@mdounin.ru> References: <47C75FB8-1DB2-4864-B5DA-13D915E73592@nginx.com> <20190117132251.GI99070@mdounin.ru> <76EB7D89-8048-4CB5-AB87-A94C2C52F808@nginx.com> <20190122145429.GE1877@mdounin.ru> <20190124145914.GN1877@mdounin.ru> Message-ID: Hi, Thank you for the information! Thanks, sephe On Thu, Jan 24, 2019 at 10:59 PM Maxim Dounin wrote: > > Hello! > > On Thu, Jan 24, 2019 at 10:07:57AM +0800, Sepherosa Ziehau wrote: > > > On Tue, Jan 22, 2019 at 10:54 PM Maxim Dounin wrote: > > > This needs to be extended with some background information - > > > notably why it used to be sigval_ptr, and why to switch to > > > sival_ptr. > > > > I am not sure why it used to be sigval_ptr; seems to be a miss name in > > FreeBSD. And the code seems to assume having KQUEUE == having sigval_ptr. > > > > As about why the switching: > > - It's POSIX standard. > > - It was noticed recently in DragonFly, since we removed this compat > > field (sigval_ptr), since after scanning the source code in ports > > system, nginx seems to be the only one using sigval_ptr. > > Yes, Sergey have details on hand. It was renamed (likely by > accident) in 1999 (FreeBSD 4.0) when introducing SA_SIGINFO > support[1]. Standard-complaint name was restored in 2005 (first > released in FreeBSD 7.0 in 2008), retaining compatibility with > previous versions[2][3]. Similar changes were committed in > DragonFly in 2009[4]. > > Since initial AIO support in nginx was introduced in 2003[5], it > used the only name available at the moment. > > Switching to a standard name now is fine, especially giving that > we can easily retain compatibility with previous versions. > > But at least some of these details need to be preserved in the > commit log, and that's what I was asking Sergey about. > > [1] https://github.com/freebsd/freebsd/commit/53573bf465904188986e8c982e8019835628d6b2 > [2] https://github.com/freebsd/freebsd/commit/ae161ac2394e00bb3afca0667a13243d7963dfe2 > [3] https://github.com/freebsd/freebsd/commit/54f35995c2ce65f23beb667de4ccf3d68139a81a > [4] https://gitweb.dragonflybsd.org/dragonfly.git/commit/36934016eeaca3abd418acb1c68bd391d3b54aa7 > [5] http://hg.nginx.org/nginx/rev/738fe44c70d5 > > -- > Maxim Dounin > http://mdounin.ru/ > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel -- Tomorrow Will Never Die From maxim at nginx.com Mon Jan 28 10:23:45 2019 From: maxim at nginx.com (Maxim Konovalov) Date: Mon, 28 Jan 2019 10:23:45 +0000 Subject: [nginx] Year 2019. Message-ID: details: https://hg.nginx.org/nginx/rev/f56a4c91b303 branches: changeset: 7447:f56a4c91b303 user: Maxim Konovalov date: Mon Jan 28 13:23:37 2019 +0300 description: Year 2019. diffstat: docs/text/LICENSE | 4 ++-- 1 ?????? ????????, 2 ???????(+), 2 ????????(-) ???????? (12 ?????): diff -r 9234e8d61aa0 -r f56a4c91b303 docs/text/LICENSE --- a/docs/text/LICENSE Thu Jan 24 22:00:44 2019 +0300 +++ b/docs/text/LICENSE Mon Jan 28 13:23:37 2019 +0300 @@ -1,6 +1,6 @@ /* - * Copyright (C) 2002-2018 Igor Sysoev - * Copyright (C) 2011-2018 Nginx, Inc. + * Copyright (C) 2002-2019 Igor Sysoev + * Copyright (C) 2011-2019 Nginx, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From xeioex at nginx.com Mon Jan 28 13:20:41 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Mon, 28 Jan 2019 13:20:41 +0000 Subject: [njs] HTTP: removed response object deprecated in 0.2.2. Message-ID: details: https://hg.nginx.org/njs/rev/23df46c40a53 branches: changeset: 737:23df46c40a53 user: Dmitry Volyntsev date: Mon Jan 28 16:17:42 2019 +0300 description: HTTP: removed response object deprecated in 0.2.2. diffstat: nginx/ngx_http_js_module.c | 303 +-------------------------------------------- 1 files changed, 5 insertions(+), 298 deletions(-) diffs (467 lines): diff -r 72fce46a7669 -r 23df46c40a53 nginx/ngx_http_js_module.c --- a/nginx/ngx_http_js_module.c Wed Jan 23 19:48:19 2019 +0300 +++ b/nginx/ngx_http_js_module.c Mon Jan 28 16:17:42 2019 +0300 @@ -15,7 +15,6 @@ typedef struct { njs_vm_t *vm; const njs_extern_t *req_proto; - const njs_extern_t *res_proto; } ngx_http_js_main_conf_t; @@ -27,9 +26,9 @@ typedef struct { typedef struct { njs_vm_t *vm; ngx_log_t *log; - njs_opaque_value_t args[2]; ngx_uint_t done; ngx_int_t status; + njs_opaque_value_t request; njs_opaque_value_t request_body; ngx_str_t redirect_uri; } ngx_http_js_ctx_t; @@ -62,8 +61,6 @@ static void ngx_http_js_cleanup_vm(void static njs_ret_t ngx_http_js_ext_get_string(njs_vm_t *vm, njs_value_t *value, void *obj, uintptr_t data); -static njs_ret_t ngx_http_js_ext_set_string(njs_vm_t *vm, void *obj, - uintptr_t data, nxt_str_t *value); static njs_ret_t ngx_http_js_ext_foreach_header(njs_vm_t *vm, void *obj, void *next, uintptr_t data); static njs_ret_t ngx_http_js_ext_next_header(njs_vm_t *vm, njs_value_t *value, @@ -80,10 +77,6 @@ static njs_ret_t ngx_http_js_ext_get_sta void *obj, uintptr_t data); static njs_ret_t ngx_http_js_ext_set_status(njs_vm_t *vm, void *obj, uintptr_t data, nxt_str_t *value); -static njs_ret_t ngx_http_js_ext_get_content_length(njs_vm_t *vm, - njs_value_t *value, void *obj, uintptr_t data); -static njs_ret_t ngx_http_js_ext_set_content_length(njs_vm_t *vm, void *obj, - uintptr_t data, nxt_str_t *value); static njs_ret_t ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused); static njs_ret_t ngx_http_js_ext_send(njs_vm_t *vm, njs_value_t *args, @@ -110,10 +103,6 @@ static njs_ret_t ngx_http_js_ext_get_rem njs_value_t *value, void *obj, uintptr_t data); static njs_ret_t ngx_http_js_ext_get_request_body(njs_vm_t *vm, njs_value_t *value, void *obj, uintptr_t data); -static njs_ret_t ngx_http_js_ext_get_headers(njs_vm_t *vm, njs_value_t *value, - void *obj, uintptr_t data); -static njs_ret_t ngx_http_js_ext_foreach_headers(njs_vm_t *vm, void *obj, - void *next); /*FIXME*/ static njs_ret_t ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value, void *obj, uintptr_t data); static njs_ret_t ngx_http_js_ext_foreach_header_in(njs_vm_t *vm, void *obj, @@ -126,8 +115,6 @@ static njs_ret_t ngx_http_js_ext_next_ar void *obj, void *next); static njs_ret_t ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value, void *obj, uintptr_t data); -static njs_ret_t ngx_http_js_ext_get_response(njs_vm_t *vm, njs_value_t *value, - void *obj, uintptr_t data); static njs_ret_t ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused); static ngx_int_t ngx_http_js_subrequest(ngx_http_request_t *r, @@ -217,106 +204,6 @@ ngx_module_t ngx_http_js_module = { }; -static njs_external_t ngx_http_js_ext_response[] = { - - { nxt_string("headers"), - NJS_EXTERN_OBJECT, - NULL, - 0, - ngx_http_js_ext_get_header_out, - ngx_http_js_ext_set_header_out, - NULL, - ngx_http_js_ext_foreach_header_out, - ngx_http_js_ext_next_header, - NULL, - 0 }, - - { nxt_string("status"), - NJS_EXTERN_PROPERTY, - NULL, - 0, - ngx_http_js_ext_get_status, - ngx_http_js_ext_set_status, - NULL, - NULL, - NULL, - NULL, - offsetof(ngx_http_request_t, headers_out.status) }, - - { nxt_string("contentType"), - NJS_EXTERN_PROPERTY, - NULL, - 0, - ngx_http_js_ext_get_string, - ngx_http_js_ext_set_string, - NULL, - NULL, - NULL, - NULL, - offsetof(ngx_http_request_t, headers_out.content_type) }, - - { nxt_string("contentLength"), - NJS_EXTERN_PROPERTY, - NULL, - 0, - ngx_http_js_ext_get_content_length, - ngx_http_js_ext_set_content_length, - NULL, - NULL, - NULL, - NULL, - 0 }, - - { nxt_string("sendHeader"), - NJS_EXTERN_METHOD, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - ngx_http_js_ext_send_header, - 0 }, - - { nxt_string("send"), - NJS_EXTERN_METHOD, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - ngx_http_js_ext_send, - 0 }, - - { nxt_string("finish"), - NJS_EXTERN_METHOD, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - ngx_http_js_ext_finish, - 0 }, - - { nxt_string("return"), - NJS_EXTERN_METHOD, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - ngx_http_js_ext_return, - 0 }, -}; - - static njs_external_t ngx_http_js_ext_request[] = { { nxt_string("uri"), @@ -379,18 +266,6 @@ static njs_external_t ngx_http_js_ext_r NULL, 0 }, - { nxt_string("body"), - NJS_EXTERN_PROPERTY, - NULL, - 0, - ngx_http_js_ext_get_reply_body, - NULL, - NULL, - NULL, - NULL, - NULL, - 0 }, - { nxt_string("requestBody"), NJS_EXTERN_PROPERTY, NULL, @@ -415,18 +290,6 @@ static njs_external_t ngx_http_js_ext_r NULL, 0 }, - { nxt_string("headers"), - NJS_EXTERN_OBJECT, - NULL, - 0, - ngx_http_js_ext_get_headers, - NULL, - NULL, - ngx_http_js_ext_foreach_headers, - ngx_http_js_ext_next_header, - NULL, - 0 }, - { nxt_string("headersIn"), NJS_EXTERN_OBJECT, NULL, @@ -487,18 +350,6 @@ static njs_external_t ngx_http_js_ext_r NULL, 0 }, - { nxt_string("response"), - NJS_EXTERN_PROPERTY, - NULL, - 0, - ngx_http_js_ext_get_response, - NULL, - NULL, - NULL, - NULL, - NULL, - 0 }, - { nxt_string("subrequest"), NJS_EXTERN_METHOD, NULL, @@ -622,18 +473,6 @@ static njs_external_t ngx_http_js_exter NULL, NULL, 0 }, - - { nxt_string("response"), - NJS_EXTERN_OBJECT, - ngx_http_js_ext_response, - nxt_nitems(ngx_http_js_ext_response), - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - 0 }, }; @@ -707,7 +546,7 @@ ngx_http_js_content_event_handler(ngx_ht ctx->status = NGX_HTTP_INTERNAL_SERVER_ERROR; - if (njs_vm_call(ctx->vm, func, njs_value_arg(ctx->args), 2) != NJS_OK) { + if (njs_vm_call(ctx->vm, func, njs_value_arg(&ctx->request), 1) != NJS_OK) { njs_vm_retval_to_ext_string(ctx->vm, &exception); ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, @@ -839,7 +678,7 @@ ngx_http_js_variable(ngx_http_request_t pending = njs_vm_pending(ctx->vm); - if (njs_vm_call(ctx->vm, func, njs_value_arg(ctx->args), 2) != NJS_OK) { + if (njs_vm_call(ctx->vm, func, njs_value_arg(&ctx->request), 1) != NJS_OK) { njs_vm_retval_to_ext_string(ctx->vm, &exception); ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, @@ -922,18 +761,12 @@ ngx_http_js_init_vm(ngx_http_request_t * return NGX_ERROR; } - rc = njs_vm_external_create(ctx->vm, njs_value_arg(&ctx->args[0]), + rc = njs_vm_external_create(ctx->vm, njs_value_arg(&ctx->request), jmcf->req_proto, r); if (rc != NXT_OK) { return NGX_ERROR; } - rc = njs_vm_external_create(ctx->vm, njs_value_arg(&ctx->args[1]), - jmcf->res_proto, r); - if (rc != NXT_OK) { - return NGX_ERROR; - } - return NGX_OK; } @@ -975,31 +808,6 @@ ngx_http_js_ext_get_string(njs_vm_t *vm, static njs_ret_t -ngx_http_js_ext_set_string(njs_vm_t *vm, void *obj, uintptr_t data, - nxt_str_t *value) -{ - char *p = obj; - - ngx_str_t *field; - ngx_http_request_t *r; - - r = (ngx_http_request_t *) obj; - - field = (ngx_str_t *) (p + data); - field->len = value->length; - - field->data = ngx_pnalloc(r->pool, value->length); - if (field->data == NULL) { - return NJS_ERROR; - } - - ngx_memcpy(field->data, value->start, value->length); - - return NJS_OK; -} - - -static njs_ret_t ngx_http_js_ext_foreach_header(njs_vm_t *vm, void *obj, void *next, uintptr_t data) { @@ -1217,40 +1025,6 @@ ngx_http_js_ext_set_status(njs_vm_t *vm, static njs_ret_t -ngx_http_js_ext_get_content_length(njs_vm_t *vm, njs_value_t *value, void *obj, - uintptr_t data) -{ - ngx_http_request_t *r; - - r = (ngx_http_request_t *) obj; - - njs_value_number_set(value, r->headers_out.content_length_n); - - return NJS_OK; -} - - -static njs_ret_t -ngx_http_js_ext_set_content_length(njs_vm_t *vm, void *obj, uintptr_t data, - nxt_str_t *value) -{ - ngx_int_t n; - ngx_http_request_t *r; - - n = ngx_atoi(value->start, value->length); - if (n == NGX_ERROR) { - return NJS_ERROR; - } - - r = (ngx_http_request_t *) obj; - - r->headers_out.content_length_n = n; - - return NJS_OK; -} - - -static njs_ret_t ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused) { @@ -1656,27 +1430,6 @@ done: static njs_ret_t -ngx_http_js_ext_get_headers(njs_vm_t *vm, njs_value_t *value, - void *obj, uintptr_t data) -{ - ngx_http_js_ctx_t *ctx; - ngx_http_request_t *r; - - r = (ngx_http_request_t *) obj; - - ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); - - if (ctx->done) { - /* simulate Reply.headers behavior */ - - return ngx_http_js_ext_get_header_out(vm, value, obj, data); - } - - return ngx_http_js_ext_get_header_in(vm, value, obj, data); -} - - -static njs_ret_t ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value, void *obj, uintptr_t data) { @@ -1698,26 +1451,6 @@ ngx_http_js_ext_get_header_in(njs_vm_t * static njs_ret_t -ngx_http_js_ext_foreach_headers(njs_vm_t *vm, void *obj, void *next) -{ - ngx_http_js_ctx_t *ctx; - ngx_http_request_t *r; - - r = (ngx_http_request_t *) obj; - - ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); - - if (ctx->done) { - /* simulate Reply.headers behavior */ - - return ngx_http_js_ext_foreach_header_out(vm, obj, next); - } - - return ngx_http_js_ext_foreach_header_in(vm, obj, next); -} - - -static njs_ret_t ngx_http_js_ext_foreach_header_in(njs_vm_t *vm, void *obj, void *next) { return ngx_http_js_ext_foreach_header(vm, obj, next, @@ -1834,23 +1567,6 @@ ngx_http_js_ext_get_variable(njs_vm_t *v static njs_ret_t -ngx_http_js_ext_get_response(njs_vm_t *vm, njs_value_t *value, void *obj, - uintptr_t data) -{ - ngx_http_js_ctx_t *ctx; - ngx_http_request_t *r; - - r = (ngx_http_request_t *) obj; - - ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); - - njs_value_assign(value, njs_value_arg(&ctx->args[1])); - - return NJS_OK; -} - - -static njs_ret_t ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused) { @@ -2189,7 +1905,7 @@ ngx_http_js_ext_get_parent(njs_vm_t *vm, return NJS_ERROR; } - njs_value_assign(value, njs_value_arg(&ctx->args[0])); + njs_value_assign(value, njs_value_arg(&ctx->request)); return NJS_OK; } @@ -2417,14 +2133,6 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_ return NGX_CONF_ERROR; } - jmcf->res_proto = njs_vm_external_prototype(jmcf->vm, - &ngx_http_js_externals[1]); - if (jmcf->res_proto == NULL) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "failed to add response proto"); - return NGX_CONF_ERROR; - } - rc = njs_vm_compile(jmcf->vm, &start, end); if (rc != NJS_OK) { @@ -2520,7 +2228,6 @@ ngx_http_js_create_main_conf(ngx_conf_t * * conf->vm = NULL; * conf->req_proto = NULL; - * conf->res_proto = NULL; */ return conf; From pluknet at nginx.com Mon Jan 28 17:16:32 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Mon, 28 Jan 2019 17:16:32 +0000 Subject: [nginx] Fixed portability issues with union sigval. Message-ID: details: https://hg.nginx.org/nginx/rev/7f035fd1ec7b branches: changeset: 7448:7f035fd1ec7b user: Sergey Kandaurov date: Mon Jan 28 14:33:31 2019 +0000 description: Fixed portability issues with union sigval. AIO support in nginx was originally developed against FreeBSD versions 4-6, where the sival_ptr field was named as sigval_ptr (seemingly by mistake[1]), which made nginx use the only name available then. The standard-complaint name was restored in 2005 (first appeared in FreeBSD 7.0, 2008), retaining compatibility with previous versions[2][3]. In DragonFly, similar changes were committed in 2009[4], with backward compatibility recently removed[5]. The change switches to the standard name, retaining compatibility with old FreeBSD versions. [1] https://svnweb.freebsd.org/changeset/base/48621 [2] https://svnweb.freebsd.org/changeset/base/152029 [3] https://svnweb.freebsd.org/changeset/base/174003 [4] https://gitweb.dragonflybsd.org/dragonfly.git/commit/3693401 [5] https://gitweb.dragonflybsd.org/dragonfly.git/commit/7875042 diffstat: src/os/unix/ngx_file_aio_read.c | 2 +- src/os/unix/ngx_freebsd_config.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletions(-) diffs (30 lines): diff -r f56a4c91b303 -r 7f035fd1ec7b src/os/unix/ngx_file_aio_read.c --- a/src/os/unix/ngx_file_aio_read.c Mon Jan 28 13:23:37 2019 +0300 +++ b/src/os/unix/ngx_file_aio_read.c Mon Jan 28 14:33:31 2019 +0000 @@ -110,7 +110,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch #if (NGX_HAVE_KQUEUE) aio->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue; aio->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; - aio->aiocb.aio_sigevent.sigev_value.sigval_ptr = ev; + aio->aiocb.aio_sigevent.sigev_value.sival_ptr = ev; #endif ev->handler = ngx_file_aio_event_handler; diff -r f56a4c91b303 -r 7f035fd1ec7b src/os/unix/ngx_freebsd_config.h --- a/src/os/unix/ngx_freebsd_config.h Mon Jan 28 13:23:37 2019 +0300 +++ b/src/os/unix/ngx_freebsd_config.h Mon Jan 28 14:33:31 2019 +0000 @@ -89,8 +89,14 @@ #if (NGX_HAVE_FILE_AIO) + #include typedef struct aiocb ngx_aiocb_t; + +#if (__FreeBSD_version < 700005 && !defined __DragonFly__) +#define sival_ptr sigval_ptr +#endif + #endif From pluknet at nginx.com Mon Jan 28 17:16:34 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Mon, 28 Jan 2019 17:16:34 +0000 Subject: [nginx] Removed --test-build-eventport workaround for old FreeBSD versions. Message-ID: details: https://hg.nginx.org/nginx/rev/3c51385e5da1 branches: changeset: 7449:3c51385e5da1 user: Sergey Kandaurov date: Mon Jan 28 14:34:02 2019 +0000 description: Removed --test-build-eventport workaround for old FreeBSD versions. diffstat: src/event/modules/ngx_eventport_module.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diffs (13 lines): diff -r 7f035fd1ec7b -r 3c51385e5da1 src/event/modules/ngx_eventport_module.c --- a/src/event/modules/ngx_eventport_module.c Mon Jan 28 14:33:31 2019 +0000 +++ b/src/event/modules/ngx_eventport_module.c Mon Jan 28 14:34:02 2019 +0000 @@ -250,9 +250,7 @@ ngx_eventport_init(ngx_cycle_t *cycle, n ngx_memzero(&sev, sizeof(struct sigevent)); sev.sigev_notify = SIGEV_PORT; -#if !(NGX_TEST_BUILD_EVENTPORT) sev.sigev_value.sival_ptr = &pn; -#endif if (timer_create(CLOCK_REALTIME, &sev, &event_timer) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, From pluknet at nginx.com Mon Jan 28 17:32:09 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Mon, 28 Jan 2019 20:32:09 +0300 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: References: Message-ID: <78F73F77-AD81-4962-9618-08745CBD46CF@nginx.com> > On 8 Jan 2019, at 06:37, Sepherosa Ziehau wrote: > > sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL > for quite a while. > > Patch: > https://leaf.dragonflybsd.org/~sephe/nginx_sival.diff Committed in 7f035fd1ec7b (with changes), thanks. -- Sergey Kandaurov From xeioex at nginx.com Mon Jan 28 18:18:49 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Mon, 28 Jan 2019 18:18:49 +0000 Subject: [njs] Renaming nxt_mem_cache_pool_t related structures and fields. Message-ID: details: https://hg.nginx.org/njs/rev/e98be67a10e2 branches: changeset: 738:e98be67a10e2 user: Dmitry Volyntsev date: Mon Jan 28 21:18:43 2019 +0300 description: Renaming nxt_mem_cache_pool_t related structures and fields. nxt_mem_cache_pool_t -> nxt_mp_t. nxt_mem_cache_* -> nxt_mp_*. vm->mem_cache_pool -> vm->mem_pool. diffstat: Makefile | 4 +- njs/njs.c | 72 +- njs/njs.h | 2 +- njs/njs_array.c | 18 +- njs/njs_builtin.c | 27 +- njs/njs_core.h | 2 +- njs/njs_crypto.c | 6 +- njs/njs_date.c | 2 +- njs/njs_error.c | 4 +- njs/njs_event.c | 4 +- njs/njs_extern.c | 19 +- njs/njs_fs.c | 2 +- njs/njs_function.c | 26 +- njs/njs_generator.c | 58 +- njs/njs_json.c | 50 +- njs/njs_lexer_keyword.c | 2 +- njs/njs_object.c | 24 +- njs/njs_parser.c | 13 +- njs/njs_parser.h | 5 +- njs/njs_regexp.c | 20 +- njs/njs_shell.c | 15 +- njs/njs_string.c | 40 +- njs/njs_time.c | 8 +- njs/njs_variable.c | 22 +- njs/njs_vm.c | 29 +- njs/njs_vm.h | 4 +- njs/test/njs_unit_test.c | 30 +- nxt/Makefile | 14 +- nxt/nxt_mem_cache_pool.c | 824 -------------------------------------------- nxt/nxt_mem_cache_pool.h | 40 -- nxt/nxt_mp.c | 818 +++++++++++++++++++++++++++++++++++++++++++ nxt/nxt_mp.h | 37 + nxt/test/Makefile | 4 +- nxt/test/lvlhsh_unit_test.c | 35 +- 34 files changed, 1123 insertions(+), 1157 deletions(-) diffs (truncated from 3916 to 1000 lines): diff -r 23df46c40a53 -r e98be67a10e2 Makefile --- a/Makefile Mon Jan 28 16:17:42 2019 +0300 +++ b/Makefile Mon Jan 28 21:18:43 2019 +0300 @@ -50,7 +50,7 @@ NXT_BUILDDIR = build $(NXT_BUILDDIR)/nxt_pcre.o \ $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_malloc.o \ - $(NXT_BUILDDIR)/nxt_mem_cache_pool.o \ + $(NXT_BUILDDIR)/nxt_mp.o \ ar -r -c $(NXT_BUILDDIR)/libnjs.a \ $(NXT_BUILDDIR)/njs_shell.o \ @@ -96,7 +96,7 @@ NXT_BUILDDIR = build $(NXT_BUILDDIR)/nxt_pcre.o \ $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_malloc.o \ - $(NXT_BUILDDIR)/nxt_mem_cache_pool.o \ + $(NXT_BUILDDIR)/nxt_mp.o \ all: test lib_test diff -r 23df46c40a53 -r e98be67a10e2 njs/njs.c --- a/njs/njs.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs.c Mon Jan 28 21:18:43 2019 +0300 @@ -49,7 +49,7 @@ njs_free(void *mem, void *p) } -const nxt_mem_proto_t njs_vm_mem_cache_pool_proto = { +const nxt_mem_proto_t njs_vm_mp_proto = { njs_alloc, njs_zalloc, njs_align, @@ -63,14 +63,14 @@ const nxt_mem_proto_t njs_vm_mem_cache_ static void * njs_array_mem_alloc(void *mem, size_t size) { - return nxt_mem_cache_alloc(mem, size); + return nxt_mp_alloc(mem, size); } static void njs_array_mem_free(void *mem, void *p) { - nxt_mem_cache_free(mem, p); + nxt_mp_free(mem, p); } @@ -88,22 +88,22 @@ const nxt_mem_proto_t njs_array_mem_pro njs_vm_t * njs_vm_create(njs_vm_opt_t *options) { + nxt_mp_t *mp; njs_vm_t *vm; nxt_int_t ret; nxt_array_t *debug; - nxt_mem_cache_pool_t *mcp; njs_regexp_pattern_t *pattern; - mcp = nxt_mem_cache_pool_create(&njs_vm_mem_cache_pool_proto, NULL, - NULL, 2 * nxt_pagesize(), 128, 512, 16); - if (nxt_slow_path(mcp == NULL)) { + mp = nxt_mp_create(&njs_vm_mp_proto, NULL, NULL, 2 * nxt_pagesize(), + 128, 512, 16); + if (nxt_slow_path(mp == NULL)) { return NULL; } - vm = nxt_mem_cache_zalign(mcp, sizeof(njs_value_t), sizeof(njs_vm_t)); + vm = nxt_mp_zalign(mp, sizeof(njs_value_t), sizeof(njs_vm_t)); if (nxt_fast_path(vm != NULL)) { - vm->mem_cache_pool = mcp; + vm->mem_pool = mp; ret = njs_regexp_init(vm); if (nxt_slow_path(ret != NXT_OK)) { @@ -116,7 +116,7 @@ njs_vm_create(njs_vm_opt_t *options) vm->shared = options->shared; } else { - vm->shared = nxt_mem_cache_zalloc(mcp, sizeof(njs_vm_shared_t)); + vm->shared = nxt_mp_zalloc(mp, sizeof(njs_vm_shared_t)); if (nxt_slow_path(vm->shared == NULL)) { return NULL; } @@ -125,7 +125,7 @@ njs_vm_create(njs_vm_opt_t *options) nxt_lvlhsh_init(&vm->shared->keywords_hash); - ret = njs_lexer_keywords_init(mcp, &vm->shared->keywords_hash); + ret = njs_lexer_keywords_init(mp, &vm->shared->keywords_hash); if (nxt_slow_path(ret != NXT_OK)) { return NULL; } @@ -154,7 +154,7 @@ njs_vm_create(njs_vm_opt_t *options) vm->external_objects = nxt_array_create(4, sizeof(void *), &njs_array_mem_proto, - vm->mem_cache_pool); + vm->mem_pool); if (nxt_slow_path(vm->external_objects == NULL)) { return NULL; } @@ -169,8 +169,7 @@ njs_vm_create(njs_vm_opt_t *options) if (options->backtrace) { debug = nxt_array_create(4, sizeof(njs_function_debug_t), - &njs_array_mem_proto, - vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(debug == NULL)) { return NULL; } @@ -210,7 +209,7 @@ njs_vm_destroy(njs_vm_t *vm) } } - nxt_mem_cache_pool_destroy(vm->mem_cache_pool); + nxt_mp_destroy(vm->mem_pool); } @@ -222,7 +221,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st njs_parser_t *parser, *prev; njs_generator_t *generator; - parser = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_parser_t)); + parser = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_parser_t)); if (nxt_slow_path(parser == NULL)) { return NJS_ERROR; } @@ -234,7 +233,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st prev = vm->parser; vm->parser = parser; - lexer = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_lexer_t)); + lexer = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_lexer_t)); if (nxt_slow_path(lexer == NULL)) { return NJS_ERROR; } @@ -269,8 +268,8 @@ njs_vm_compile(njs_vm_t *vm, u_char **st */ vm->code = NULL; - generator = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - sizeof(njs_generator_t)); + generator = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_generator_t)); if (nxt_slow_path(generator == NULL)) { goto fail; @@ -310,11 +309,11 @@ fail: njs_vm_t * njs_vm_clone(njs_vm_t *vm, njs_external_ptr_t external) { - njs_vm_t *nvm; - uint32_t items; - nxt_int_t ret; - nxt_array_t *externals; - nxt_mem_cache_pool_t *nmcp; + nxt_mp_t *nmp; + njs_vm_t *nvm; + uint32_t items; + nxt_int_t ret; + nxt_array_t *externals; nxt_thread_log_debug("CLONE:"); @@ -322,16 +321,16 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ return NULL; } - nmcp = nxt_mem_cache_pool_create(&njs_vm_mem_cache_pool_proto, NULL, - NULL, 2 * nxt_pagesize(), 128, 512, 16); - if (nxt_slow_path(nmcp == NULL)) { + nmp = nxt_mp_create(&njs_vm_mp_proto, NULL, NULL, 2 * nxt_pagesize(), + 128, 512, 16); + if (nxt_slow_path(nmp == NULL)) { return NULL; } - nvm = nxt_mem_cache_zalign(nmcp, sizeof(njs_value_t), sizeof(njs_vm_t)); + nvm = nxt_mp_zalign(nmp, sizeof(njs_value_t), sizeof(njs_vm_t)); if (nxt_fast_path(nvm != NULL)) { - nvm->mem_cache_pool = nmcp; + nvm->mem_pool = nmp; nvm->shared = vm->shared; nvm->trace = vm->trace; @@ -345,7 +344,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ items = vm->external_objects->items; externals = nxt_array_create(items + 4, sizeof(void *), - &njs_array_mem_proto, nvm->mem_cache_pool); + &njs_array_mem_proto, nvm->mem_pool); if (nxt_slow_path(externals == NULL)) { return NULL; @@ -380,7 +379,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_ fail: - nxt_mem_cache_pool_destroy(nmcp); + nxt_mp_destroy(nmp); return NULL; } @@ -400,7 +399,7 @@ njs_vm_init(njs_vm_t *vm) size = NJS_GLOBAL_FRAME_SIZE + scope_size + NJS_FRAME_SPARE_SIZE; size = nxt_align_size(size, NJS_FRAME_SPARE_SIZE); - frame = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), size); + frame = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), size); if (nxt_slow_path(frame == NULL)) { return NXT_ERROR; } @@ -436,7 +435,7 @@ njs_vm_init(njs_vm_t *vm) if (vm->debug != NULL) { backtrace = nxt_array_create(4, sizeof(njs_backtrace_entry_t), - &njs_array_mem_proto, vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(backtrace == NULL)) { return NXT_ERROR; } @@ -486,7 +485,7 @@ njs_vm_add_event(njs_vm_t *vm, njs_funct { njs_event_t *event; - event = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_event_t)); + event = nxt_mp_alloc(vm->mem_pool, sizeof(njs_event_t)); if (nxt_slow_path(event == NULL)) { return NULL; } @@ -542,8 +541,7 @@ njs_vm_post_event(njs_vm_t *vm, njs_vm_e if (nargs != 0 && !event->posted) { event->nargs = nargs; - event->args = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_value_t) * nargs); + event->args = nxt_mp_alloc(vm->mem_pool, sizeof(njs_value_t) * nargs); if (nxt_slow_path(event->args == NULL)) { return NJS_ERROR; } @@ -709,7 +707,7 @@ njs_vm_object_alloc(njs_vm_t *vm, njs_va } lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; lhq.proto = &njs_object_hash_proto; njs_string_get(name, &lhq.key); diff -r 23df46c40a53 -r e98be67a10e2 njs/njs.h --- a/njs/njs.h Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs.h Mon Jan 28 21:18:43 2019 +0300 @@ -273,6 +273,6 @@ NXT_EXPORT njs_ret_t njs_vm_object_alloc NXT_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm, const njs_value_t *value, const nxt_str_t *key); -extern const nxt_mem_proto_t njs_vm_mem_cache_pool_proto; +extern const nxt_mem_proto_t njs_vm_mp_proto; #endif /* _NJS_H_INCLUDED_ */ diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_array.c --- a/njs/njs_array.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_array.c Mon Jan 28 21:18:43 2019 +0300 @@ -130,7 +130,7 @@ njs_array_alloc(njs_vm_t *vm, uint32_t l uint64_t size; njs_array_t *array; - array = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_array_t)); + array = nxt_mp_alloc(vm->mem_pool, sizeof(njs_array_t)); if (nxt_slow_path(array == NULL)) { goto memory_error; } @@ -141,8 +141,8 @@ njs_array_alloc(njs_vm_t *vm, uint32_t l goto memory_error; } - array->data = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - size * sizeof(njs_value_t)); + array->data = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + size * sizeof(njs_value_t)); if (nxt_slow_path(array->data == NULL)) { goto memory_error; } @@ -224,8 +224,8 @@ njs_array_expand(njs_vm_t *vm, njs_array goto memory_error; } - start = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - (prepend + size) * sizeof(njs_value_t)); + start = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + (prepend + size) * sizeof(njs_value_t)); if (nxt_slow_path(start == NULL)) { goto memory_error; } @@ -240,7 +240,7 @@ njs_array_expand(njs_vm_t *vm, njs_array array->start = start; - nxt_mem_cache_free(vm->mem_cache_pool, old); + nxt_mp_free(vm->mem_pool, old); return NXT_OK; @@ -970,8 +970,8 @@ njs_array_prototype_join(njs_vm_t *vm, n } if (max != 0) { - values = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - sizeof(njs_value_t) * max); + values = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_value_t) * max); if (nxt_slow_path(values == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -1105,7 +1105,7 @@ njs_array_prototype_join_continuation(nj njs_release(vm, &values[i]); } - nxt_mem_cache_free(vm->mem_cache_pool, values); + nxt_mp_free(vm->mem_pool, values); return NXT_OK; } diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_builtin.c --- a/njs/njs_builtin.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_builtin.c Mon Jan 28 21:18:43 2019 +0300 @@ -284,12 +284,12 @@ njs_builtin_objects_create(njs_vm_t *vm) } lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; for (p = njs_module_init; *p != NULL; p++) { obj = *p; - module = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_module_t)); + module = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_module_t)); if (nxt_slow_path(module == NULL)) { return NJS_ERROR; } @@ -629,7 +629,7 @@ njs_builtin_completions(njs_vm_t *vm, nx njs_string_get(&prop->name, &string); len = obj->name.length + string.length + 2; - compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + compl = nxt_mp_zalloc(vm->mem_pool, len); if (compl == NULL) { return NULL; } @@ -649,7 +649,7 @@ njs_builtin_completions(njs_vm_t *vm, nx njs_string_get(&prop->name, &string); len = string.length + 2; - compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + compl = nxt_mp_zalloc(vm->mem_pool, len); if (compl == NULL) { return NULL; } @@ -679,7 +679,7 @@ njs_builtin_completions(njs_vm_t *vm, nx njs_string_get(&prop->name, &string); len = obj->name.length + string.length + 2; - compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + compl = nxt_mp_zalloc(vm->mem_pool, len); if (compl == NULL) { return NULL; } @@ -705,7 +705,7 @@ njs_builtin_completions(njs_vm_t *vm, nx nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto); len = ev->name.length + 1; - compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + compl = nxt_mp_zalloc(vm->mem_pool, len); if (compl == NULL) { return NULL; } @@ -723,7 +723,7 @@ njs_builtin_completions(njs_vm_t *vm, nx } len = ev->name.length + ev->name.length + 2; - compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + compl = nxt_mp_zalloc(vm->mem_pool, len); if (compl == NULL) { return NULL; } @@ -753,8 +753,7 @@ njs_vm_completions(njs_vm_t *vm, nxt_str size = njs_builtin_completions_size(vm); completions = nxt_array_create(size, sizeof(nxt_str_t), - &njs_array_mem_proto, - vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(completions == NULL)) { return NULL; @@ -879,7 +878,7 @@ njs_object_completions(njs_vm_t *vm, njs } while (o != NULL); completions = nxt_array_create(size, sizeof(nxt_str_t), - &njs_array_mem_proto, vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(completions == NULL)) { return NULL; @@ -993,7 +992,7 @@ njs_builtin_match_native_function(njs_vm njs_string_get(&prop->name, &string); len = obj->name.length + string.length + sizeof("."); - buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + buf = nxt_mp_zalloc(vm->mem_pool, len); if (buf == NULL) { return NXT_ERROR; } @@ -1012,7 +1011,7 @@ njs_builtin_match_native_function(njs_vm njs_string_get(&prop->name, &string); len = obj->name.length + string.length + sizeof(".prototype."); - buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + buf = nxt_mp_zalloc(vm->mem_pool, len); if (buf == NULL) { return NXT_ERROR; } @@ -1031,7 +1030,7 @@ njs_builtin_match_native_function(njs_vm njs_string_get(&prop->name, &string); len = obj->name.length + string.length + sizeof("."); - buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + buf = nxt_mp_zalloc(vm->mem_pool, len); if (buf == NULL) { return NXT_ERROR; } @@ -1060,7 +1059,7 @@ njs_builtin_match_native_function(njs_vm njs_string_get(&prop->name, &string); len = obj->name.length + string.length + sizeof("."); - buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + buf = nxt_mp_zalloc(vm->mem_pool, len); if (buf == NULL) { return NXT_ERROR; } diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_core.h --- a/njs/njs_core.h Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_core.h Mon Jan 28 21:18:43 2019 +0300 @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_crypto.c --- a/njs/njs_crypto.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_crypto.c Mon Jan 28 21:18:43 2019 +0300 @@ -132,7 +132,7 @@ njs_crypto_object_value_alloc(njs_vm_t * { njs_object_value_t *ov; - ov = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_object_value_t)); + ov = nxt_mp_alloc(vm->mem_pool, sizeof(njs_object_value_t)); if (nxt_fast_path(ov != NULL)) { nxt_lvlhsh_init(&ov->object.hash); @@ -177,7 +177,7 @@ njs_crypto_create_hash(njs_vm_t *vm, njs return NJS_ERROR; } - dgst = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_digest_t)); + dgst = nxt_mp_alloc(vm->mem_pool, sizeof(njs_digest_t)); if (nxt_slow_path(dgst == NULL)) { njs_memory_error(vm); return NJS_ERROR; @@ -408,7 +408,7 @@ njs_crypto_create_hmac(njs_vm_t *vm, njs njs_string_get(&args[2], &key); - ctx = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_hmac_t)); + ctx = nxt_mp_alloc(vm->mem_pool, sizeof(njs_hmac_t)); if (nxt_slow_path(ctx == NULL)) { njs_memory_error(vm); return NJS_ERROR; diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_date.c --- a/njs/njs_date.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_date.c Mon Jan 28 21:18:43 2019 +0300 @@ -127,7 +127,7 @@ njs_date_constructor(njs_vm_t *vm, njs_v done: - date = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_date_t)); + date = nxt_mp_alloc(vm->mem_pool, sizeof(njs_date_t)); if (nxt_slow_path(date == NULL)) { njs_memory_error(vm); return NXT_ERROR; diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_error.c --- a/njs/njs_error.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_error.c Mon Jan 28 21:18:43 2019 +0300 @@ -57,7 +57,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_ njs_object_prop_t *prop; nxt_lvlhsh_query_t lhq; - error = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_object_t)); + error = nxt_mp_alloc(vm->mem_pool, sizeof(njs_object_t)); if (nxt_slow_path(error == NULL)) { njs_memory_error(vm); return NULL; @@ -71,7 +71,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_ error->__proto__ = &vm->prototypes[njs_error_prototype_index(type)].object; lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; if (name != NULL) { lhq.key = nxt_string_value("name"); diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_event.c --- a/njs/njs_event.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_event.c Mon Jan 28 21:18:43 2019 +0300 @@ -52,7 +52,7 @@ njs_add_event(njs_vm_t *vm, njs_event_t lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length); lhq.value = event; lhq.proto = &njs_event_hash_proto; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; ret = nxt_lvlhsh_insert(&vm->events_hash, &lhq); if (nxt_slow_path(ret != NXT_OK)) { @@ -86,7 +86,7 @@ njs_del_event(njs_vm_t *vm, njs_event_t njs_string_get(&ev->id, &lhq.key); lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length); lhq.proto = &njs_event_hash_proto; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; if (ev->posted) { ev->posted = 0; diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_extern.c --- a/njs/njs_extern.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_extern.c Mon Jan 28 21:18:43 2019 +0300 @@ -79,7 +79,7 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv nxt_lvlhsh_query_t lhq; do { - ext = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_extern_t)); + ext = nxt_mp_alloc(vm->mem_pool, sizeof(njs_extern_t)); if (nxt_slow_path(ext == NULL)) { goto memory_error; } @@ -97,14 +97,13 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv ext->data = external->data; if (external->method != NULL) { - function = nxt_mem_cache_zalloc(vm->mem_cache_pool, - sizeof(njs_function_t)); + function = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_function_t)); if (nxt_slow_path(function == NULL)) { goto memory_error; } /* - * nxt_mem_cache_zalloc() does also: + * nxt_mp_zalloc() does also: * nxt_lvlhsh_init(&function->object.hash); * function->object.__proto__ = NULL; */ @@ -139,7 +138,7 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv lhq.key = ext->name; lhq.replace = 0; lhq.value = ext; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; lhq.proto = &njs_extern_hash_proto; ret = nxt_lvlhsh_insert(hash, &lhq); @@ -182,7 +181,7 @@ njs_vm_external_create(njs_vm_t *vm, njs } obj = nxt_array_add(vm->external_objects, &njs_array_mem_proto, - vm->mem_cache_pool); + vm->mem_pool); if (nxt_slow_path(obj == NULL)) { return NXT_ERROR; } @@ -210,8 +209,8 @@ njs_vm_external_bind(njs_vm_t *vm, const return NXT_ERROR; } - ev = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - sizeof(njs_extern_value_t)); + ev = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_extern_value_t)); if (nxt_slow_path(ev == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -225,7 +224,7 @@ njs_vm_external_bind(njs_vm_t *vm, const lhq.proto = &njs_extern_value_hash_proto; lhq.value = ev; lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; ret = nxt_lvlhsh_insert(&vm->externals_hash, &lhq); if (nxt_slow_path(ret != NXT_OK)) { @@ -367,7 +366,7 @@ found: len += pr->str.length + nxt_length("."); } - buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len); + buf = nxt_mp_zalloc(vm->mem_pool, len); if (buf == NULL) { return NXT_ERROR; } diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_fs.c --- a/njs/njs_fs.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_fs.c Mon Jan 28 21:18:43 2019 +0300 @@ -903,7 +903,7 @@ static njs_ret_t njs_fs_error(njs_vm_t * } lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; if (errn != 0) { lhq.key = nxt_string_value("errno"); diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_function.c --- a/njs/njs_function.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_function.c Mon Jan 28 21:18:43 2019 +0300 @@ -18,11 +18,11 @@ njs_function_alloc(njs_vm_t *vm) { njs_function_t *function; - function = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_function_t)); + function = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_function_t)); if (nxt_fast_path(function != NULL)) { /* - * nxt_mem_cache_zalloc() does also: + * nxt_mp_zalloc() does also: * nxt_lvlhsh_init(&function->object.hash); * function->object.__proto__ = NULL; */ @@ -33,8 +33,8 @@ njs_function_alloc(njs_vm_t *vm) function->object.extensible = 1; function->args_offset = 1; - function->u.lambda = nxt_mem_cache_zalloc(vm->mem_cache_pool, - sizeof(njs_function_lambda_t)); + function->u.lambda = nxt_mp_zalloc(vm->mem_pool, + sizeof(njs_function_lambda_t)); if (nxt_slow_path(function->u.lambda == NULL)) { njs_memory_error(vm); return NULL; @@ -66,7 +66,7 @@ njs_function_value_copy(njs_vm_t *vm, nj size = sizeof(njs_function_t) + nesting * sizeof(njs_closure_t *); - copy = nxt_mem_cache_alloc(vm->mem_cache_pool, size); + copy = nxt_mp_alloc(vm->mem_pool, size); if (nxt_slow_path(copy == NULL)) { njs_memory_error(vm); return NULL; @@ -134,7 +134,7 @@ njs_function_arguments_object_init(njs_v njs_string_get(&prop->name, &lhq.key); lhq.replace = 0; - lhq.pool = vm->mem_cache_pool; + lhq.pool = vm->mem_pool; lhq.proto = &njs_object_hash_proto; ret = nxt_lvlhsh_insert(&arguments->hash, &lhq); @@ -369,8 +369,7 @@ njs_function_frame_alloc(njs_vm_t *vm, s return NULL; } - frame = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - spare_size); + frame = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), spare_size); if (nxt_slow_path(frame == NULL)) { njs_memory_error(vm); return NULL; @@ -454,8 +453,7 @@ njs_function_lambda_call(njs_vm_t *vm, n size = lambda->closure_size; if (size != 0) { - closure = nxt_mem_cache_align(vm->mem_cache_pool, - sizeof(njs_value_t), size); + closure = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), size); if (nxt_slow_path(closure == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -706,7 +704,7 @@ njs_function_frame_free(njs_vm_t *vm, nj if (frame->size != 0) { vm->stack_size -= frame->size; - nxt_mem_cache_free(vm->mem_cache_pool, frame); + nxt_mp_free(vm->mem_pool, frame); } frame = previous; @@ -994,7 +992,7 @@ njs_function_prototype_bind(njs_vm_t *vm return NXT_ERROR; } - function = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_function_t)); + function = nxt_mp_alloc(vm->mem_pool, sizeof(njs_function_t)); if (nxt_slow_path(function == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -1017,10 +1015,10 @@ njs_function_prototype_bind(njs_vm_t *vm function->args_offset = nargs; size = nargs * sizeof(njs_value_t); - values = nxt_mem_cache_alloc(vm->mem_cache_pool, size); + values = nxt_mp_alloc(vm->mem_pool, size); if (nxt_slow_path(values == NULL)) { njs_memory_error(vm); - nxt_mem_cache_free(vm->mem_cache_pool, function); + nxt_mp_free(vm->mem_pool, function); return NXT_ERROR; } diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_generator.c --- a/njs/njs_generator.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_generator.c Mon Jan 28 21:18:43 2019 +0300 @@ -461,7 +461,7 @@ njs_generate_reserve(njs_vm_t *vm, njs_g size += size / 2; } - p = nxt_mem_cache_alloc(vm->mem_cache_pool, size); + p = nxt_mp_alloc(vm->mem_pool, size); if (nxt_slow_path(p == NULL)) { njs_memory_error(vm); return NULL; @@ -472,7 +472,7 @@ njs_generate_reserve(njs_vm_t *vm, njs_g size = generator->code_end - generator->code_start; memcpy(p, generator->code_start, size); - nxt_mem_cache_free(vm->mem_cache_pool, generator->code_start); + nxt_mp_free(vm->mem_pool, generator->code_start); generator->code_start = p; generator->code_end = p + size; @@ -880,8 +880,7 @@ njs_generate_switch_statement(njs_vm_t * return ret; } - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_slow_path(patch == NULL)) { return NXT_ERROR; } @@ -921,7 +920,7 @@ njs_generate_switch_statement(njs_vm_t * next = patch->next; - nxt_mem_cache_free(vm->mem_cache_pool, patch); + nxt_mp_free(vm->mem_pool, patch); patch = next; node = branch->right; @@ -1259,8 +1258,7 @@ njs_generate_start_block(njs_vm_t *vm, n { njs_generator_block_t *block; - block = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_block_t)); + block = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_block_t)); if (nxt_fast_path(block != NULL)) { block->next = generator->block; @@ -1301,8 +1299,7 @@ njs_generate_make_continuation_patch(njs { njs_generator_patch_t *patch; - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_slow_path(patch == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -1327,7 +1324,7 @@ njs_generate_patch_block(njs_vm_t *vm, n njs_code_update_offset(generator, patch); next = patch->next; - nxt_mem_cache_free(vm->mem_cache_pool, patch); + nxt_mp_free(vm->mem_pool, patch); } } @@ -1338,8 +1335,7 @@ njs_generate_make_exit_patch(njs_vm_t *v { njs_generator_patch_t *patch; - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_slow_path(patch == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -1364,7 +1360,7 @@ njs_generate_patch_block_exit(njs_vm_t * njs_generate_patch_block(vm, generator, block->exit); - nxt_mem_cache_free(vm->mem_cache_pool, block); + nxt_mp_free(vm->mem_pool, block); } @@ -1391,8 +1387,7 @@ njs_generate_continue_statement(njs_vm_t /* TODO: LABEL */ - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_fast_path(patch != NULL)) { patch->next = block->continuation; @@ -1441,8 +1436,7 @@ njs_generate_break_statement(njs_vm_t *v /* TODO: LABEL: loop and switch may have label, block must have label. */ - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_fast_path(patch != NULL)) { patch->next = block->exit; @@ -2293,8 +2287,8 @@ njs_generate_function_scope(njs_vm_t *vm nxt_array_t *closure; njs_generator_t *generator; - generator = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - sizeof(njs_generator_t)); + generator = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_generator_t)); if (nxt_slow_path(generator == NULL)) { return NXT_ERROR; } @@ -2326,7 +2320,7 @@ njs_generate_function_scope(njs_vm_t *vm lambda->start = generator->code_start; } - nxt_mem_cache_free(vm->mem_cache_pool, generator); + nxt_mp_free(vm->mem_pool, generator); return ret; } @@ -2346,7 +2340,7 @@ njs_generate_scope(njs_vm_t *vm, njs_gen generator->code_size = 128; - p = nxt_mem_cache_alloc(vm->mem_cache_pool, generator->code_size); + p = nxt_mp_alloc(vm->mem_pool, generator->code_size); if (nxt_slow_path(p == NULL)) { return NXT_ERROR; } @@ -2371,8 +2365,7 @@ njs_generate_scope(njs_vm_t *vm, njs_gen scope_size -= NJS_INDEX_GLOBAL_OFFSET; } - generator->local_scope = nxt_mem_cache_alloc(vm->mem_cache_pool, - scope_size); + generator->local_scope = nxt_mp_alloc(vm->mem_pool, scope_size); if (nxt_slow_path(generator->local_scope == NULL)) { return NXT_ERROR; } @@ -2392,13 +2385,13 @@ njs_generate_scope(njs_vm_t *vm, njs_gen if (vm->code == NULL) { vm->code = nxt_array_create(4, sizeof(njs_vm_code_t), - &njs_array_mem_proto, vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(vm->code == NULL)) { return NXT_ERROR; } } - code = nxt_array_add(vm->code, &njs_array_mem_proto, vm->mem_cache_pool); + code = nxt_array_add(vm->code, &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(code == NULL)) { return NXT_ERROR; } @@ -2489,8 +2482,7 @@ njs_generate_return_statement(njs_vm_t * return NXT_OK; } - patch = nxt_mem_cache_alloc(vm->mem_cache_pool, - sizeof(njs_generator_patch_t)); + patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t)); if (nxt_slow_path(patch == NULL)) { return NXT_ERROR; } @@ -3087,8 +3079,8 @@ njs_generate_temp_index_get(njs_vm_t *vm * all global variables are allocated in absolute scope * to simplify global scope handling. */ - value = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), - sizeof(njs_value_t)); + value = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_value_t)); if (nxt_slow_path(value == NULL)) { return NJS_INDEX_ERROR; } @@ -3097,7 +3089,7 @@ njs_generate_temp_index_get(njs_vm_t *vm } else { value = nxt_array_add(scope->values[0], &njs_array_mem_proto, - vm->mem_cache_pool); + vm->mem_pool); if (nxt_slow_path(value == NULL)) { return NJS_INDEX_ERROR; } @@ -3153,7 +3145,7 @@ njs_generate_index_release(njs_vm_t *vm, if (cache == NULL) { cache = nxt_array_create(4, sizeof(njs_value_t *), - &njs_array_mem_proto, vm->mem_cache_pool); + &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(cache == NULL)) { return NXT_ERROR; } @@ -3161,7 +3153,7 @@ njs_generate_index_release(njs_vm_t *vm, generator->index_cache = cache; } - last = nxt_array_add(cache, &njs_array_mem_proto, vm->mem_cache_pool); + last = nxt_array_add(cache, &njs_array_mem_proto, vm->mem_pool); if (nxt_fast_path(last != NULL)) { *last = index; return NXT_OK; @@ -3177,7 +3169,7 @@ njs_generate_function_debug(njs_vm_t *vm { njs_function_debug_t *debug; - debug = nxt_array_add(vm->debug, &njs_array_mem_proto, vm->mem_cache_pool); + debug = nxt_array_add(vm->debug, &njs_array_mem_proto, vm->mem_pool); if (nxt_slow_path(debug == NULL)) { return NXT_ERROR; } diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_json.c --- a/njs/njs_json.c Mon Jan 28 16:17:42 2019 +0300 +++ b/njs/njs_json.c Mon Jan 28 21:18:43 2019 +0300 @@ -13,7 +13,7 @@ typedef struct { njs_vm_t *vm; - nxt_mem_cache_pool_t *pool; + nxt_mp_t *pool; nxt_uint_t depth; const u_char *start; const u_char *end; @@ -82,7 +82,7 @@ typedef struct { njs_value_t key; njs_vm_t *vm; - nxt_mem_cache_pool_t *pool; + nxt_mp_t *pool; njs_chb_node_t *nodes; njs_chb_node_t *last; nxt_array_t stack; @@ -169,7 +169,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t njs_string_prop_t string; njs_json_parse_ctx_t ctx; - value = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_value_t)); + value = nxt_mp_alloc(vm->mem_pool, sizeof(njs_value_t)); if (nxt_slow_path(value == NULL)) { njs_memory_error(vm); return NXT_ERROR; @@ -187,7 +187,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t end = p + string.size; ctx.vm = vm; - ctx.pool = vm->mem_cache_pool; + ctx.pool = vm->mem_pool; ctx.depth = 32; ctx.start = string.start; ctx.end = end; @@ -220,7 +220,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t parse->function = args[2].data.u.function; if (nxt_array_init(&parse->stack, NULL, 4, sizeof(njs_json_state_t), - &njs_array_mem_proto, vm->mem_cache_pool) + &njs_array_mem_proto, vm->mem_pool) == NULL) { goto memory_error; @@ -262,7 +262,7 @@ njs_json_stringify(njs_vm_t *vm, njs_val From xeioex at nginx.com Tue Jan 29 12:00:27 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Tue, 29 Jan 2019 12:00:27 +0000 Subject: [njs] Improved next index allocation. Message-ID: details: https://hg.nginx.org/njs/rev/b4b1280ae790 branches: changeset: 739:b4b1280ae790 user: hongzhidao date: Sun Jan 27 05:21:32 2019 +0800 description: Improved next index allocation. diffstat: njs/njs_generator.c | 33 +---------------- njs/njs_variable.c | 97 ++++++++++++++++++++++++++++++---------------------- njs/njs_variable.h | 2 + 3 files changed, 60 insertions(+), 72 deletions(-) diffs (187 lines): diff -r e98be67a10e2 -r b4b1280ae790 njs/njs_generator.c --- a/njs/njs_generator.c Mon Jan 28 21:18:43 2019 +0300 +++ b/njs/njs_generator.c Sun Jan 27 05:21:32 2019 +0800 @@ -3053,8 +3053,7 @@ njs_generate_temp_index_get(njs_vm_t *vm njs_parser_node_t *node) { nxt_array_t *cache; - njs_value_t *value; - njs_index_t index, *last; + njs_index_t *last; njs_parser_scope_t *scope; cache = generator->index_cache; @@ -3073,34 +3072,8 @@ njs_generate_temp_index_get(njs_vm_t *vm scope = scope->parent; } - if (vm->options.accumulative && scope->type == NJS_SCOPE_GLOBAL) { - /* - * When non-clonable VM runs in accumulative mode - * all global variables are allocated in absolute scope - * to simplify global scope handling. - */ - value = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), - sizeof(njs_value_t)); - if (nxt_slow_path(value == NULL)) { - return NJS_INDEX_ERROR; - } - - index = (njs_index_t) value; - - } else { - value = nxt_array_add(scope->values[0], &njs_array_mem_proto, - vm->mem_pool); - if (nxt_slow_path(value == NULL)) { - return NJS_INDEX_ERROR; - } - - index = scope->next_index[0]; - scope->next_index[0] += sizeof(njs_value_t); - } - - *value = njs_value_invalid; - - return index; + return njs_scope_next_index(vm, scope, NJS_SCOPE_INDEX_LOCAL, + &njs_value_invalid); } diff -r e98be67a10e2 -r b4b1280ae790 njs/njs_variable.c --- a/njs/njs_variable.c Mon Jan 28 21:18:43 2019 +0300 +++ b/njs/njs_variable.c Sun Jan 27 05:21:32 2019 +0800 @@ -286,10 +286,9 @@ njs_variable_resolve(njs_vm_t *vm, njs_p { nxt_int_t ret; nxt_uint_t scope_index; - nxt_array_t *values; njs_index_t index; - njs_value_t *value; njs_variable_t *var; + const njs_value_t *default_value; njs_variable_reference_t *vr; vr = &node->u.reference; @@ -331,48 +330,12 @@ njs_variable_resolve(njs_vm_t *vm, njs_p goto not_found; } - if (vm->options.accumulative && vr->scope->type == NJS_SCOPE_GLOBAL) { - /* - * When non-clonable VM runs in accumulative mode all - * global variables should be allocated in absolute scope - * to share them among consecutive VM invocations. - */ - value = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), - sizeof(njs_value_t)); - if (nxt_slow_path(value == NULL)) { - njs_memory_error(vm); - return NULL; - } - - index = (njs_index_t) value; - - } else { - values = vr->scope->values[scope_index]; + default_value = njs_is_object(&var->value) ? &var->value : &njs_value_void; - if (values == NULL) { - values = nxt_array_create(4, sizeof(njs_value_t), - &njs_array_mem_proto, vm->mem_pool); - if (nxt_slow_path(values == NULL)) { - return NULL; - } - - vr->scope->values[scope_index] = values; - } + index = njs_scope_next_index(vm, vr->scope, scope_index, default_value); - value = nxt_array_add(values, &njs_array_mem_proto, vm->mem_pool); - if (nxt_slow_path(value == NULL)) { - return NULL; - } - - index = vr->scope->next_index[scope_index]; - vr->scope->next_index[scope_index] += sizeof(njs_value_t); - } - - if (njs_is_object(&var->value)) { - *value = var->value; - - } else { - *value = njs_value_void; + if (nxt_slow_path(index == NJS_INDEX_ERROR)) { + return NULL; } var->index = index; @@ -448,6 +411,56 @@ njs_variable_reference_resolve(njs_vm_t } +njs_index_t +njs_scope_next_index(njs_vm_t *vm, njs_parser_scope_t *scope, + nxt_uint_t scope_index, const njs_value_t *default_value) +{ + njs_index_t index; + njs_value_t *value; + nxt_array_t *values; + + if (vm->options.accumulative && scope->type == NJS_SCOPE_GLOBAL) { + /* + * When non-clonable VM runs in accumulative mode all + * global variables should be allocated in absolute scope + * to share them among consecutive VM invocations. + */ + value = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), + sizeof(njs_value_t)); + if (nxt_slow_path(value == NULL)) { + return NJS_INDEX_ERROR; + } + + index = (njs_index_t) value; + + } else { + values = scope->values[scope_index]; + + if (values == NULL) { + values = nxt_array_create(4, sizeof(njs_value_t), + &njs_array_mem_proto, vm->mem_pool); + if (nxt_slow_path(values == NULL)) { + return NJS_INDEX_ERROR; + } + + scope->values[scope_index] = values; + } + + value = nxt_array_add(values, &njs_array_mem_proto, vm->mem_pool); + if (nxt_slow_path(value == NULL)) { + return NJS_INDEX_ERROR; + } + + index = scope->next_index[scope_index]; + scope->next_index[scope_index] += sizeof(njs_value_t); + } + + *value = *default_value; + + return index; +} + + static njs_variable_t * njs_variable_alloc(njs_vm_t *vm, nxt_str_t *name, njs_variable_type_t type) { diff -r e98be67a10e2 -r b4b1280ae790 njs/njs_variable.h --- a/njs/njs_variable.h Mon Jan 28 21:18:43 2019 +0300 +++ b/njs/njs_variable.h Sun Jan 27 05:21:32 2019 +0800 @@ -59,6 +59,8 @@ njs_ret_t njs_variable_reference(njs_vm_ njs_reference_type_t type); njs_ret_t njs_variables_scope_reference(njs_vm_t *vm, njs_parser_scope_t *scope); +njs_index_t njs_scope_next_index(njs_vm_t *vm, njs_parser_scope_t *scope, + nxt_uint_t scope_index, const njs_value_t *default_value); njs_ret_t njs_name_copy(njs_vm_t *vm, nxt_str_t *dst, nxt_str_t *src); extern const nxt_lvlhsh_proto_t njs_variables_hash_proto; From xeioex at nginx.com Tue Jan 29 15:15:21 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Tue, 29 Jan 2019 15:15:21 +0000 Subject: [njs] Added support for multiline tests. Message-ID: details: https://hg.nginx.org/njs/rev/ef39ae753b9e branches: changeset: 740:ef39ae753b9e user: Dmitry Volyntsev date: Tue Jan 29 16:49:36 2019 +0300 description: Added support for multiline tests. diffstat: njs/test/njs_interactive_test.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (27 lines): diff -r b4b1280ae790 -r ef39ae753b9e njs/test/njs_interactive_test.c --- a/njs/test/njs_interactive_test.c Sun Jan 27 05:21:32 2019 +0800 +++ b/njs/test/njs_interactive_test.c Tue Jan 29 16:49:36 2019 +0300 @@ -17,7 +17,7 @@ typedef struct { } njs_interactive_test_t; -#define ENTER "\n" +#define ENTER "\n\3" static njs_interactive_test_t njs_test[] = @@ -276,12 +276,12 @@ njs_interactive_test(nxt_bool_t verbose) end = NULL; for ( ;; ) { - start = (end != NULL) ? end + 1 : start; + start = (end != NULL) ? end + nxt_length(ENTER) : start; if (start >= last) { break; } - end = (u_char *) strchr((char *) start, '\n'); + end = (u_char *) strstr((char *) start, ENTER); ret = njs_vm_compile(vm, &start, end); if (ret == NXT_OK) { From xeioex at nginx.com Tue Jan 29 15:15:21 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Tue, 29 Jan 2019 15:15:21 +0000 Subject: [njs] Fixed parsing multiline comments. Message-ID: details: https://hg.nginx.org/njs/rev/348a34597bab branches: changeset: 741:348a34597bab user: Dmitry Volyntsev date: Tue Jan 29 18:15:03 2019 +0300 description: Fixed parsing multiline comments. diffstat: njs/njs_lexer.c | 6 ++---- njs/test/njs_interactive_test.c | 17 +++++++++++++++++ njs/test/njs_unit_test.c | 3 +++ 3 files changed, 22 insertions(+), 4 deletions(-) diffs (56 lines): diff -r ef39ae753b9e -r 348a34597bab njs/njs_lexer.c --- a/njs/njs_lexer.c Tue Jan 29 16:49:36 2019 +0300 +++ b/njs/njs_lexer.c Tue Jan 29 18:15:03 2019 +0300 @@ -704,10 +704,8 @@ njs_lexer_division(njs_lexer_t *lexer, n } if (*p == '*') { - p++; - - if (p < lexer->end && *p == '/') { - lexer->start = p + 1; + if (p + 1 < lexer->end && p[1] == '/') { + lexer->start = p + 2; return NJS_TOKEN_AGAIN; } } diff -r ef39ae753b9e -r 348a34597bab njs/test/njs_interactive_test.c --- a/njs/test/njs_interactive_test.c Tue Jan 29 16:49:36 2019 +0300 +++ b/njs/test/njs_interactive_test.c Tue Jan 29 18:15:03 2019 +0300 @@ -233,6 +233,23 @@ static njs_interactive_test_t njs_test[ nxt_string("TypeError: Cannot convert object to primitive value\n" " at main (native)\n") }, + /* line numbers */ + + { nxt_string("/**/(function(){throw Error();})()" ENTER), + nxt_string("Error\n" + " at anonymous (:1)\n" + " at main (native)\n") }, + + { nxt_string("/***/(function(){throw Error();})()" ENTER), + nxt_string("Error\n" + " at anonymous (:1)\n" + " at main (native)\n") }, + + { nxt_string("/*\n**/(function(){throw Error();})()" ENTER), + nxt_string("Error\n" + " at anonymous (:2)\n" + " at main (native)\n") }, + }; diff -r ef39ae753b9e -r 348a34597bab njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Tue Jan 29 16:49:36 2019 +0300 +++ b/njs/test/njs_unit_test.c Tue Jan 29 18:15:03 2019 +0300 @@ -28,6 +28,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("1}"), nxt_string("SyntaxError: Unexpected token \"}\" in 1") }, + { nxt_string("/***/1/*\n**/"), + nxt_string("1") }, + /* Variable declarations. */ { nxt_string("var x"), From sepherosa at gmail.com Wed Jan 30 03:16:41 2019 From: sepherosa at gmail.com (Sepherosa Ziehau) Date: Wed, 30 Jan 2019 11:16:41 +0800 Subject: aio/unix: Use signal.sival which is standard In-Reply-To: <78F73F77-AD81-4962-9618-08745CBD46CF@nginx.com> References: <78F73F77-AD81-4962-9618-08745CBD46CF@nginx.com> Message-ID: Thank you very much! On Tue, Jan 29, 2019 at 1:32 AM Sergey Kandaurov wrote: > > > > > On 8 Jan 2019, at 06:37, Sepherosa Ziehau wrote: > > > > sigval.sigval is for FreeBSD 6 compability, while FreeBSD 6 was EOL > > for quite a while. > > > > Patch: > > https://leaf.dragonflybsd.org/~sephe/nginx_sival.diff > > Committed in 7f035fd1ec7b (with changes), thanks. > > -- > Sergey Kandaurov > > _______________________________________________ > nginx-devel mailing list > nginx-devel at nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel -- Tomorrow Will Never Die From xeioex at nginx.com Wed Jan 30 11:58:41 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 11:58:41 +0000 Subject: [njs] Style. Message-ID: details: https://hg.nginx.org/njs/rev/c7e18bd12776 branches: changeset: 742:c7e18bd12776 user: hongzhidao date: Tue Jan 29 01:30:04 2019 +0800 description: Style. diffstat: njs/njs_lexer_keyword.c | 8 ++++---- njs/njs_module.h | 6 ++++-- njs/njs_parser.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diffs (53 lines): diff -r 348a34597bab -r c7e18bd12776 njs/njs_lexer_keyword.c --- a/njs/njs_lexer_keyword.c Tue Jan 29 18:15:03 2019 +0300 +++ b/njs/njs_lexer_keyword.c Tue Jan 29 01:30:04 2019 +0800 @@ -88,10 +88,10 @@ static const njs_keyword_t njs_keywords { nxt_string("encodeURIComponent"), NJS_TOKEN_ENCODE_URI_COMPONENT, 0 }, { nxt_string("decodeURI"), NJS_TOKEN_DECODE_URI, 0 }, { nxt_string("decodeURIComponent"), NJS_TOKEN_DECODE_URI_COMPONENT, 0 }, - { nxt_string("require"), NJS_TOKEN_REQUIRE, 0 }, - { nxt_string("setTimeout"), NJS_TOKEN_SET_TIMEOUT, 0 }, - { nxt_string("setImmediate"), NJS_TOKEN_SET_IMMEDIATE, 0 }, - { nxt_string("clearTimeout"), NJS_TOKEN_CLEAR_TIMEOUT, 0 }, + { nxt_string("require"), NJS_TOKEN_REQUIRE, 0 }, + { nxt_string("setTimeout"), NJS_TOKEN_SET_TIMEOUT, 0 }, + { nxt_string("setImmediate"), NJS_TOKEN_SET_IMMEDIATE, 0 }, + { nxt_string("clearTimeout"), NJS_TOKEN_CLEAR_TIMEOUT, 0 }, /* Reserved words. */ diff -r 348a34597bab -r c7e18bd12776 njs/njs_module.h --- a/njs/njs_module.h Tue Jan 29 18:15:03 2019 +0300 +++ b/njs/njs_module.h Tue Jan 29 01:30:04 2019 +0800 @@ -7,6 +7,7 @@ #ifndef _NJS_MODULE_H_INCLUDED_ #define _NJS_MODULE_H_INCLUDED_ + typedef struct { nxt_str_t name; njs_object_t object; @@ -16,8 +17,9 @@ typedef struct { njs_ret_t njs_module_require(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused); -extern const nxt_lvlhsh_proto_t njs_modules_hash_proto; -extern const njs_object_init_t njs_require_function_init; +extern const nxt_lvlhsh_proto_t njs_modules_hash_proto; +extern const njs_object_init_t njs_require_function_init; + #endif /* _NJS_MODULE_H_INCLUDED_ */ diff -r 348a34597bab -r c7e18bd12776 njs/njs_parser.c --- a/njs/njs_parser.c Tue Jan 29 18:15:03 2019 +0300 +++ b/njs/njs_parser.c Tue Jan 29 01:30:04 2019 +0800 @@ -720,7 +720,7 @@ njs_parser_function_lambda(njs_vm_t *vm, } } - token = njs_parser_token(parser); + token = njs_parser_token(parser); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; } From xeioex at nginx.com Wed Jan 30 15:56:39 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 15:56:39 +0000 Subject: [njs] Fixed lexer->text state for the last token. Message-ID: details: https://hg.nginx.org/njs/rev/e136756f6bb2 branches: changeset: 744:e136756f6bb2 user: Dmitry Volyntsev date: Wed Jan 30 18:48:23 2019 +0300 description: Fixed lexer->text state for the last token. diffstat: njs/njs_lexer.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diffs (12 lines): diff -r ea483ef4631a -r e136756f6bb2 njs/njs_lexer.c --- a/njs/njs_lexer.c Wed Jan 30 18:47:59 2019 +0300 +++ b/njs/njs_lexer.c Wed Jan 30 18:48:23 2019 +0300 @@ -450,6 +450,8 @@ njs_lexer_next_token(njs_lexer_t *lexer) return njs_lexer_multi(lexer, token, n, multi); } + lexer->text.length = lexer->start - lexer->text.start; + return NJS_TOKEN_END; } From xeioex at nginx.com Wed Jan 30 15:56:39 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 15:56:39 +0000 Subject: [njs] Fixed SyntaxError message for unterminated regexp token. Message-ID: details: https://hg.nginx.org/njs/rev/d99f8ee4255c branches: changeset: 745:d99f8ee4255c user: Dmitry Volyntsev date: Wed Jan 30 18:49:16 2019 +0300 description: Fixed SyntaxError message for unterminated regexp token. diffstat: njs/njs_regexp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r e136756f6bb2 -r d99f8ee4255c njs/njs_regexp.c --- a/njs/njs_regexp.c Wed Jan 30 18:48:23 2019 +0300 +++ b/njs/njs_regexp.c Wed Jan 30 18:49:16 2019 +0300 @@ -184,7 +184,7 @@ njs_regexp_literal(njs_vm_t *vm, njs_par } njs_parser_syntax_error(vm, parser, "Unterminated RegExp \"%.*s\"", - p - lexer->start - 1, lexer->start - 1); + p - (lexer->start - 1), lexer->start - 1); return NJS_TOKEN_ILLEGAL; } From xeioex at nginx.com Wed Jan 30 15:56:39 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 15:56:39 +0000 Subject: [njs] Imported nxt_sprintf.c. Message-ID: details: https://hg.nginx.org/njs/rev/ea483ef4631a branches: changeset: 743:ea483ef4631a user: Dmitry Volyntsev date: Wed Jan 30 18:47:59 2019 +0300 description: Imported nxt_sprintf.c. diffstat: Makefile | 2 + njs/njs_core.h | 1 + nxt/Makefile | 13 + nxt/nxt_sprintf.c | 587 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ nxt/nxt_sprintf.h | 16 + nxt/nxt_stub.h | 2 - nxt/nxt_types.h | 19 + 7 files changed, 638 insertions(+), 2 deletions(-) diffs (723 lines): diff -r c7e18bd12776 -r ea483ef4631a Makefile --- a/Makefile Tue Jan 29 01:30:04 2019 +0800 +++ b/Makefile Wed Jan 30 18:47:59 2019 +0300 @@ -51,6 +51,7 @@ NXT_BUILDDIR = build $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_malloc.o \ $(NXT_BUILDDIR)/nxt_mp.o \ + $(NXT_BUILDDIR)/nxt_sprintf.o \ ar -r -c $(NXT_BUILDDIR)/libnjs.a \ $(NXT_BUILDDIR)/njs_shell.o \ @@ -97,6 +98,7 @@ NXT_BUILDDIR = build $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_malloc.o \ $(NXT_BUILDDIR)/nxt_mp.o \ + $(NXT_BUILDDIR)/nxt_sprintf.o \ all: test lib_test diff -r c7e18bd12776 -r ea483ef4631a njs/njs_core.h --- a/njs/njs_core.h Tue Jan 29 01:30:04 2019 +0800 +++ b/njs/njs_core.h Wed Jan 30 18:47:59 2019 +0300 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff -r c7e18bd12776 -r ea483ef4631a nxt/Makefile --- a/nxt/Makefile Tue Jan 29 01:30:04 2019 +0800 +++ b/nxt/Makefile Wed Jan 30 18:47:59 2019 +0300 @@ -22,6 +22,7 @@ NXT_LIB = nxt $(NXT_BUILDDIR)/nxt_trace.o \ $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_mp.o \ + $(NXT_BUILDDIR)/nxt_sprintf.o \ ar -r -c $(NXT_BUILDDIR)/libnxt.a \ $(NXT_BUILDDIR)/nxt_diyfp.o \ @@ -41,6 +42,7 @@ NXT_LIB = nxt $(NXT_BUILDDIR)/nxt_time.o \ $(NXT_BUILDDIR)/nxt_trace.o \ $(NXT_BUILDDIR)/nxt_mp.o \ + $(NXT_BUILDDIR)/nxt_sprintf.o \ $(NXT_BUILDDIR)/nxt_diyfp.o: \ $(NXT_LIB)/nxt_types.h \ @@ -244,4 +246,15 @@ NXT_LIB = nxt -I$(NXT_LIB) \ $(NXT_LIB)/nxt_mp.c +$(NXT_BUILDDIR)/nxt_sprintf.o: \ + $(NXT_LIB)/nxt_types.h \ + $(NXT_LIB)/nxt_clang.h \ + $(NXT_LIB)/nxt_alignment.h \ + $(NXT_LIB)/nxt_sprintf.h \ + $(NXT_LIB)/nxt_sprintf.c \ + + $(NXT_CC) -c -o $(NXT_BUILDDIR)/nxt_sprintf.o $(NXT_CFLAGS) \ + -I$(NXT_LIB) \ + $(NXT_LIB)/nxt_sprintf.c + include $(NXT_LIB)/test/Makefile diff -r c7e18bd12776 -r ea483ef4631a nxt/nxt_sprintf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nxt/nxt_sprintf.c Wed Jan 30 18:47:59 2019 +0300 @@ -0,0 +1,587 @@ + +/* + * Copyright (C) Igor Sysoev + * Copyright (C) NGINX, Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +/* + * Supported formats: + * + * %[0][width][x][X]O nxt_off_t + * %[0][width]T nxt_time_t + * %[0][width][u][x|X]z ssize_t/size_t + * %[0][width][u][x|X]d int/u_int + * %[0][width][u][x|X]l long + * %[0][width|m][u][x|X]i nxt_int_t/nxt_uint_t + * %[0][width][u][x|X]D int32_t/uint32_t + * %[0][width][u][x|X]L int64_t/uint64_t + * %[0][width][.width]f double, max valid number fits to %18.15f + * + * %d int + * + * %s null-terminated string + * %*s length and string + * + * %p void * + * %b nxt_bool_t + * %V nxt_str_t * + * %Z '\0' + * %n '\n' + * %c char + * %% % + * + * Reserved: + * %t ptrdiff_t + * %S null-terminated wchar string + * %C wchar + * %[0][width][u][x|X]Q int128_t/uint128_t + */ + + +u_char * +nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...) +{ + u_char *p; + va_list args; + + va_start(args, fmt); + p = nxt_vsprintf(buf, end, fmt, args); + va_end(args); + + return p; +} + + +/* + * nxt_sprintf_t is used: + * to pass several parameters of nxt_integer() via single pointer + * and to store little used variables of nxt_vsprintf(). + */ + +typedef struct { + u_char *end; + const u_char *hex; + uint32_t width; + int32_t frac_width; + uint8_t max_width; + u_char padding; +} nxt_sprintf_t; + + +static u_char *nxt_integer(nxt_sprintf_t *spf, u_char *buf, uint64_t ui64); +static u_char *nxt_number(nxt_sprintf_t *spf, u_char *buf, double n); + + +/* A right way of "f == 0.0". */ +#define nxt_double_is_zero(f) (fabs(f) <= FLT_EPSILON) + + +u_char * +nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) +{ + u_char *p; + int d; + double f, i; + size_t length; + int64_t i64; + uint64_t ui64, frac; + nxt_str_t *v; + nxt_uint_t scale, n; + nxt_bool_t sign; + nxt_sprintf_t spf; + + static const u_char hexadecimal[16] = "0123456789abcdef"; + static const u_char HEXADECIMAL[16] = "0123456789ABCDEF"; + static const u_char nan[] = "[nan]"; + static const u_char infinity[] = "[infinity]"; + + spf.end = end; + + while (*fmt != '\0' && buf < end) { + + /* + * "buf < end" means that we could copy at least one character: + * a plain character, "%%", "%c", or a minus without test. + */ + + if (*fmt != '%') { + *buf++ = *fmt++; + continue; + } + + fmt++; + + /* Test some often used text formats first. */ + + switch (*fmt) { + + case 'V': + fmt++; + v = va_arg(args, nxt_str_t *); + + if (nxt_fast_path(v != NULL)) { + length = v->length; + p = v->start; + goto copy; + } + + continue; + + case 's': + p = va_arg(args, u_char *); + + if (nxt_fast_path(p != NULL)) { + while (*p != '\0' && buf < end) { + *buf++ = *p++; + } + } + + fmt++; + continue; + + case '*': + length = va_arg(args, size_t); + + fmt++; + + if (*fmt == 's') { + fmt++; + p = va_arg(args, u_char *); + + if (nxt_fast_path(p != NULL)) { + goto copy; + } + } + + continue; + + default: + break; + } + + spf.hex = NULL; + spf.width = 0; + spf.frac_width = -1; + spf.max_width = 0; + spf.padding = (*fmt == '0') ? '0' : ' '; + + sign = 1; + + i64 = 0; + ui64 = 0; + + while (*fmt >= '0' && *fmt <= '9') { + spf.width = spf.width * 10 + (*fmt++ - '0'); + } + + + for ( ;; ) { + switch (*fmt) { + + case 'u': + sign = 0; + fmt++; + continue; + + case 'm': + spf.max_width = 1; + fmt++; + continue; + + case 'X': + spf.hex = HEXADECIMAL; + sign = 0; + fmt++; + continue; + + case 'x': + spf.hex = hexadecimal; + sign = 0; + fmt++; + continue; + + case '.': + fmt++; + spf.frac_width = 0; + + while (*fmt >= '0' && *fmt <= '9') { + spf.frac_width = spf.frac_width * 10 + *fmt++ - '0'; + } + + break; + + default: + break; + } + + break; + } + + + switch (*fmt) { + + case 'O': + i64 = (int64_t) va_arg(args, nxt_off_t); + sign = 1; + goto number; + + case 'T': + i64 = (int64_t) va_arg(args, nxt_time_t); + sign = 1; + goto number; + + case 'z': + if (sign) { + i64 = (int64_t) va_arg(args, ssize_t); + } else { + ui64 = (uint64_t) va_arg(args, size_t); + } + goto number; + + case 'i': + if (sign) { + i64 = (int64_t) va_arg(args, nxt_int_t); + } else { + ui64 = (uint64_t) va_arg(args, nxt_uint_t); + } + + if (spf.max_width != 0) { + spf.width = NXT_INT_T_LEN; + } + + goto number; + + case 'd': + if (sign) { + i64 = (int64_t) va_arg(args, int); + } else { + ui64 = (uint64_t) va_arg(args, u_int); + } + goto number; + + case 'l': + if (sign) { + i64 = (int64_t) va_arg(args, long); + } else { + ui64 = (uint64_t) va_arg(args, u_long); + } + goto number; + + case 'D': + if (sign) { + i64 = (int64_t) va_arg(args, int32_t); + } else { + ui64 = (uint64_t) va_arg(args, uint32_t); + } + goto number; + + case 'L': + if (sign) { + i64 = va_arg(args, int64_t); + } else { + ui64 = va_arg(args, uint64_t); + } + goto number; + + case 'b': + ui64 = (uint64_t) va_arg(args, nxt_bool_t); + sign = 0; + goto number; + + case 'f': + fmt++; + + f = va_arg(args, double); + + if (f < 0) { + *buf++ = '-'; + f = -f; + } + + if (nxt_slow_path(isnan(f))) { + p = (u_char *) nan; + length = nxt_length(nan); + + goto copy; + + } else if (nxt_slow_path(isinf(f))) { + p = (u_char *) infinity; + length = nxt_length(infinity); + + goto copy; + } + + (void) modf(f, &i); + frac = 0; + + if (spf.frac_width > 0) { + + scale = 1; + for (n = spf.frac_width; n != 0; n--) { + scale *= 10; + } + + frac = (uint64_t) ((f - i) * scale + 0.5); + + if (frac == scale) { + i += 1; + frac = 0; + } + } + + buf = nxt_number(&spf, buf, i); + + if (spf.frac_width > 0) { + + if (buf < end) { + *buf++ = '.'; + + spf.hex = NULL; + spf.padding = '0'; + spf.width = spf.frac_width; + buf = nxt_integer(&spf, buf, frac); + } + + } else if (spf.frac_width < 0) { + f = modf(f, &i); + + if (!nxt_double_is_zero(f) && buf < end) { + *buf++ = '.'; + + while (!nxt_double_is_zero(f) && buf < end) { + f *= 10; + f = modf(f, &i); + *buf++ = (u_char) i + '0'; + } + } + } + + continue; + + case 'p': + ui64 = (uintptr_t) va_arg(args, void *); + sign = 0; + spf.hex = HEXADECIMAL; + /* + * spf.width = NXT_PTR_SIZE * 2; + * spf.padding = '0'; + */ + goto number; + + case 'c': + d = va_arg(args, int); + *buf++ = (u_char) (d & 0xFF); + fmt++; + + continue; + + case 'Z': + *buf++ = '\0'; + fmt++; + continue; + + case 'n': + *buf++ = '\n'; + fmt++; + continue; + + case '%': + *buf++ = '%'; + fmt++; + continue; + + default: + *buf++ = *fmt++; + continue; + } + + number: + + if (sign) { + if (i64 < 0) { + *buf++ = '-'; + ui64 = (uint64_t) -i64; + + } else { + ui64 = (uint64_t) i64; + } + } + + buf = nxt_integer(&spf, buf, ui64); + + fmt++; + continue; + + copy: + + buf = nxt_cpymem(buf, p, nxt_min((size_t) (end - buf), length)); + continue; + } + + return buf; +} + + +static u_char * +nxt_integer(nxt_sprintf_t *spf, u_char *buf, uint64_t ui64) +{ + u_char *p, *end; + size_t length; + u_char temp[NXT_INT64_T_LEN]; + + p = temp + NXT_INT64_T_LEN; + + if (spf->hex == NULL) { + +#if (NXT_32BIT) + + for ( ;; ) { + u_char *start; + uint32_t ui32; + + /* + * 32-bit platforms usually lack hardware support of 64-bit + * division and remainder operations. For this reason C compiler + * adds calls to the runtime library functions which provides + * these operations. These functions usually have about hundred + * lines of code. + * + * For 32-bit numbers and some constant divisors GCC, Clang and + * other compilers can use inlined multiplications and shifts + * which are faster than division or remainder operations. + * For example, unsigned "ui32 / 10" is compiled to + * + * ((uint64_t) ui32 * 0xCCCCCCCD) >> 35 + * + * So a 64-bit number is split to parts by 10^9. The parts fit + * to 32 bits and are processed separately as 32-bit numbers. A + * number of 64-bit division/remainder operations is significantly + * decreased depending on the 64-bit number's value, it is + * 0 if the 64-bit value is less than 4294967296, + * 1 if the 64-bit value is greater than 4294967295 + * and less than 4294967296000000000, + * 2 otherwise. + */ + + if (ui64 <= 0xFFFFFFFF) { + ui32 = (uint32_t) ui64; + start = NULL; + + } else { + ui32 = (uint32_t) (ui64 % 1000000000); + start = p - 9; + } + + do { + *(--p) = (u_char) (ui32 % 10 + '0'); + ui32 /= 10; + } while (ui32 != 0); + + if (start == NULL) { + break; + } + + /* Add leading zeros of part. */ + + while (p > start) { + *(--p) = '0'; + } + + ui64 /= 1000000000; + } + +#else /* NXT_64BIT */ + + do { + *(--p) = (u_char) (ui64 % 10 + '0'); + ui64 /= 10; + } while (ui64 != 0); + +#endif + + } else { + + do { + *(--p) = spf->hex[ui64 & 0xF]; + ui64 >>= 4; + } while (ui64 != 0); + } + + /* Zero or space padding. */ + + if (spf->width != 0) { + + length = (temp + NXT_INT64_T_LEN) - p; + end = buf + (spf->width - length); + end = nxt_min(end, spf->end); + + while (buf < end) { + *buf++ = spf->padding; + } + } + + /* Number copying. */ + + length = (temp + NXT_INT64_T_LEN) - p; + end = buf + length; + end = nxt_min(end, spf->end); + + while (buf < end) { + *buf++ = *p++; + } + + return buf; +} + + +static u_char * +nxt_number(nxt_sprintf_t *spf, u_char *buf, double n) +{ + u_char *p, *end; + size_t length; + u_char temp[NXT_DOUBLE_LEN]; + + p = temp + NXT_DOUBLE_LEN; + + do { + *(--p) = (u_char) (fmod(n, 10) + '0'); + n = trunc(n / 10); + } while (!nxt_double_is_zero(n)); + + /* Zero or space padding. */ + + if (spf->width != 0) { + length = (temp + NXT_DOUBLE_LEN) - p; + end = buf + (spf->width - length); + end = nxt_min(end, spf->end); + + while (buf < end) { + *buf++ = spf->padding; + } + } + + /* Number copying. */ + + length = (temp + NXT_DOUBLE_LEN) - p; + + end = buf + length; + end = nxt_min(end, spf->end); + + while (buf < end) { + *buf++ = *p++; + } + + return buf; +} diff -r c7e18bd12776 -r ea483ef4631a nxt/nxt_sprintf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nxt/nxt_sprintf.h Wed Jan 30 18:47:59 2019 +0300 @@ -0,0 +1,16 @@ + +/* + * Copyright (C) Igor Sysoev + * Copyright (C) NGINX, Inc. + */ + +#ifndef _NXT_SPRINTF_H_INCLUDED_ +#define _NXT_SPRINTF_H_INCLUDED_ + + +NXT_EXPORT u_char *nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...); +NXT_EXPORT u_char *nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, + va_list args); + + +#endif /* _NXT_SPRINTF_H_INCLUDED_ */ diff -r c7e18bd12776 -r ea483ef4631a nxt/nxt_stub.h --- a/nxt/nxt_stub.h Tue Jan 29 01:30:04 2019 +0800 +++ b/nxt/nxt_stub.h Wed Jan 30 18:47:59 2019 +0300 @@ -38,8 +38,6 @@ typedef struct { #define nxt_log_error(...) #define nxt_thread_log_debug(...) -#define NXT_DOUBLE_LEN 1024 - #include #define nxt_pagesize() getpagesize() diff -r c7e18bd12776 -r ea483ef4631a nxt/nxt_types.h --- a/nxt/nxt_types.h Tue Jan 29 01:30:04 2019 +0800 +++ b/nxt/nxt_types.h Wed Jan 30 18:47:59 2019 +0300 @@ -55,7 +55,20 @@ typedef unsigned __int128 nxt_uint128_t; #endif +#if (NXT_INT_T_SIZE == 8) +#define NXT_INT_T_LEN NXT_INT64_T_LEN +#define NXT_INT_T_HEXLEN NXT_INT64_T_HEXLEN +#define NXT_INT_T_MAX NXT_INT64_T_MAX + +#else +#define NXT_INT_T_LEN NXT_INT32_T_LEN +#define NXT_INT_T_HEXLEN NXT_INT32_T_HEXLEN +#define NXT_INT_T_MAX NXT_INT32_T_MAX +#endif + + typedef nxt_uint_t nxt_bool_t; +typedef int nxt_err_t; /* @@ -98,4 +111,10 @@ typedef time_t nxt_time_t; typedef pid_t nxt_pid_t; +#define NXT_INT32_T_LEN nxt_length("-2147483648") +#define NXT_INT64_T_LEN nxt_length("-9223372036854775808") + +#define NXT_DOUBLE_LEN (1 + DBL_MAX_10_EXP) + + #endif /* _NXT_TYPES_H_INCLUDED_ */ From xeioex at nginx.com Wed Jan 30 15:56:39 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 15:56:39 +0000 Subject: [njs] Replacing vsprintf with nxt_vsprintf in exceptions. Message-ID: details: https://hg.nginx.org/njs/rev/dbffb3031c77 branches: changeset: 746:dbffb3031c77 user: Dmitry Volyntsev date: Wed Jan 30 18:49:33 2019 +0300 description: Replacing vsprintf with nxt_vsprintf in exceptions. diffstat: njs/njs_crypto.c | 6 +--- njs/njs_error.c | 6 +++- njs/njs_fs.c | 24 +++++++-------------- njs/njs_generator.c | 7 ++--- njs/njs_json.c | 2 +- njs/njs_module.c | 3 +- njs/njs_object.c | 7 ++--- njs/njs_parser.c | 57 +++++++++++++++++++++------------------------------- njs/njs_regexp.c | 9 +++---- njs/njs_string.c | 5 +-- njs/njs_variable.c | 3 +- njs/njs_vm.c | 18 ++++++---------- 12 files changed, 59 insertions(+), 88 deletions(-) diffs (465 lines): diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_crypto.c --- a/njs/njs_crypto.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_crypto.c Wed Jan 30 18:49:33 2019 +0300 @@ -691,8 +691,7 @@ njs_crypto_alg(njs_vm_t *vm, const nxt_s } } - njs_type_error(vm, "not supported algorithm: '%.*s'", - (int) name->length, name->start); + njs_type_error(vm, "not supported algorithm: '%V'", name); return NULL; } @@ -709,8 +708,7 @@ njs_crypto_encoding(njs_vm_t *vm, const } } - njs_type_error(vm, "Unknown digest encoding: '%.*s'", - (int) name->length, name->start); + njs_type_error(vm, "Unknown digest encoding: '%V'", name); return NULL; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_error.c --- a/njs/njs_error.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_error.c Wed Jan 30 18:49:33 2019 +0300 @@ -23,13 +23,15 @@ njs_exception_error_create(njs_vm_t *vm, nxt_int_t ret; njs_value_t string; njs_object_t *error; - char buf[256]; + u_char buf[256], *p; if (fmt != NULL) { va_start(args, fmt); - size = vsnprintf(buf, sizeof(buf), fmt, args); + p = nxt_vsprintf(buf, buf + sizeof(buf), fmt, args); va_end(args); + size = p - buf; + } else { size = 0; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_fs.c --- a/njs/njs_fs.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_fs.c Wed Jan 30 18:49:33 2019 +0300 @@ -165,8 +165,7 @@ njs_fs_read_file(njs_vm_t *vm, njs_value flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%.*s'", - (int) flag.length, flag.start); + njs_type_error(vm, "Unknown file open flags: '%V'", &flag); return NJS_ERROR; } @@ -178,8 +177,7 @@ njs_fs_read_file(njs_vm_t *vm, njs_value if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%.*s'", - (int) encoding.length, encoding.start); + njs_type_error(vm, "Unknown encoding: '%V'", &encoding); return NJS_ERROR; } @@ -362,8 +360,7 @@ njs_fs_read_file_sync(njs_vm_t *vm, njs_ flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%.*s'", - (int) flag.length, flag.start); + njs_type_error(vm, "Unknown file open flags: '%V'", &flag); return NJS_ERROR; } @@ -375,8 +372,7 @@ njs_fs_read_file_sync(njs_vm_t *vm, njs_ if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%.*s'", - (int) encoding.length, encoding.start); + njs_type_error(vm, "Unknown encoding: '%V'", &encoding); return NJS_ERROR; } @@ -611,8 +607,7 @@ static njs_ret_t njs_fs_write_file_inter if (flag.start != NULL) { flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%.*s'", - (int) flag.length, flag.start); + njs_type_error(vm, "Unknown file open flags: '%V'", &flag); return NJS_ERROR; } @@ -635,8 +630,7 @@ static njs_ret_t njs_fs_write_file_inter if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%.*s'", - (int) encoding.length, encoding.start); + njs_type_error(vm, "Unknown encoding: '%V'", &encoding); return NJS_ERROR; } @@ -785,8 +779,7 @@ njs_fs_write_file_sync_internal(njs_vm_t if (flag.start != NULL) { flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%.*s'", - (int) flag.length, flag.start); + njs_type_error(vm, "Unknown file open flags: '%V'", &flag); return NJS_ERROR; } @@ -809,8 +802,7 @@ njs_fs_write_file_sync_internal(njs_vm_t if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%.*s'", - (int) encoding.length, encoding.start); + njs_type_error(vm, "Unknown encoding: '%V'", &encoding); return NJS_ERROR; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_generator.c --- a/njs/njs_generator.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_generator.c Wed Jan 30 18:49:33 2019 +0300 @@ -3166,12 +3166,11 @@ njs_generate_syntax_error(njs_vm_t *vm, const char* fmt, ...) { va_list args; - - static char buf[256]; + u_char buf[256], *end; va_start(args, fmt); - (void) vsnprintf(buf, sizeof(buf), fmt, args); + end = nxt_vsprintf(buf, buf + sizeof(buf), fmt, args); va_end(args); - njs_syntax_error(vm, "%s in %u", buf, token_line); + njs_syntax_error(vm, "%*s in %uD", end - buf, buf, token_line); } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_json.c --- a/njs/njs_json.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_json.c Wed Jan 30 18:49:33 2019 +0300 @@ -1131,7 +1131,7 @@ njs_json_parse_exception(njs_json_parse_ length = 0; } - njs_syntax_error(ctx->vm, "%s at position %zu", msg, length); + njs_syntax_error(ctx->vm, "%s at position %z", msg, length); } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_module.c --- a/njs/njs_module.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_module.c Wed Jan 30 18:49:33 2019 +0300 @@ -62,8 +62,7 @@ njs_ret_t njs_module_require(njs_vm_t *v return NXT_OK; } - njs_error(vm, "Cannot find module '%.*s'", - (int) lhq.key.length, lhq.key.start); + njs_error(vm, "Cannot find module '%V'", &lhq.key); return NJS_ERROR; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_object.c --- a/njs/njs_object.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_object.c Wed Jan 30 18:49:33 2019 +0300 @@ -364,8 +364,8 @@ njs_property_query(njs_vm_t *vm, njs_pro if (nxt_fast_path(ret == NXT_OK)) { njs_string_get(&pq->value, &pq->lhq.key); - njs_type_error(vm, "cannot get property '%.*s' of undefined", - (int) pq->lhq.key.length, pq->lhq.key.start); + njs_type_error(vm, "cannot get property '%V' of undefined", + &pq->lhq.key); return NXT_ERROR; } @@ -1535,8 +1535,7 @@ njs_define_property(njs_vm_t *vm, njs_va exception: - njs_type_error(vm, "Cannot redefine property: '%.*s'", - (int) pq.lhq.key.length, pq.lhq.key.start); + njs_type_error(vm, "Cannot redefine property: '%V'", &pq.lhq.key); return NXT_ERROR; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_parser.c --- a/njs/njs_parser.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_parser.c Wed Jan 30 18:49:33 2019 +0300 @@ -510,10 +510,9 @@ njs_parser_function_declaration(njs_vm_t if (token != NJS_TOKEN_NAME) { if (token == NJS_TOKEN_ARGUMENTS || token == NJS_TOKEN_EVAL) { - njs_parser_syntax_error(vm, parser, "Identifier \"%.*s\" " + njs_parser_syntax_error(vm, parser, "Identifier \"%V\" " "is forbidden in function declaration", - (int) parser->lexer->text.length, - parser->lexer->text.start); + &parser->lexer->text); } return NJS_TOKEN_ILLEGAL; @@ -854,10 +853,9 @@ njs_parser_var_statement(njs_vm_t *vm, n if (token != NJS_TOKEN_NAME) { if (token == NJS_TOKEN_ARGUMENTS || token == NJS_TOKEN_EVAL) { - njs_parser_syntax_error(vm, parser, "Identifier \"%.*s\" " + njs_parser_syntax_error(vm, parser, "Identifier \"%V\" " "is forbidden in var declaration", - (int) parser->lexer->text.length, - parser->lexer->text.start); + &parser->lexer->text); } return NJS_TOKEN_ILLEGAL; @@ -1317,10 +1315,9 @@ njs_parser_for_var_statement(njs_vm_t *v if (token != NJS_TOKEN_NAME) { if (token == NJS_TOKEN_ARGUMENTS || token == NJS_TOKEN_EVAL) { - njs_parser_syntax_error(vm, parser, "Identifier \"%.*s\" " + njs_parser_syntax_error(vm, parser, "Identifier \"%V\" " "is forbidden in for-in var declaration", - (int) parser->lexer->text.length, - parser->lexer->text.start); + &parser->lexer->text); } return NJS_TOKEN_ILLEGAL; @@ -1457,9 +1454,8 @@ njs_parser_for_in_statement(njs_vm_t *vm node = parser->node->left; if (node->token != NJS_TOKEN_NAME) { - njs_parser_ref_error(vm, parser, "Invalid left-hand side \"%.*s\" " - "in for-in statement", (int) name->length, - name->start); + njs_parser_ref_error(vm, parser, "Invalid left-hand side \"%V\" " + "in for-in statement", name); return NJS_TOKEN_ILLEGAL; } @@ -1936,9 +1932,8 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa break; case NJS_TOKEN_UNTERMINATED_STRING: - njs_parser_syntax_error(vm, parser, "Unterminated string \"%.*s\"", - (int) parser->lexer->text.length, - parser->lexer->text.start); + njs_parser_syntax_error(vm, parser, "Unterminated string \"%V\"", + &parser->lexer->text); return NJS_TOKEN_ILLEGAL; @@ -2007,10 +2002,8 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa nxt_thread_log_debug("JS: arguments"); if (parser->scope->type <= NJS_SCOPE_GLOBAL) { - njs_parser_syntax_error(vm, parser, "\"%.*s\" object " - "in global scope", - (int) parser->lexer->text.length, - parser->lexer->text.start); + njs_parser_syntax_error(vm, parser, "\"%V\" object " + "in global scope", &parser->lexer->text); return NJS_TOKEN_ILLEGAL; } @@ -2591,9 +2584,8 @@ njs_parser_escape_string_create(njs_vm_t invalid: - njs_parser_syntax_error(vm, parser, "Invalid Unicode code point \"%.*s\"", - (int) parser->lexer->text.length, - parser->lexer->text.start); + njs_parser_syntax_error(vm, parser, "Invalid Unicode code point \"%V\"", + &parser->lexer->text); return NJS_TOKEN_ILLEGAL; } @@ -2635,9 +2627,8 @@ njs_parser_unexpected_token(njs_vm_t *vm njs_token_t token) { if (token != NJS_TOKEN_END) { - njs_parser_syntax_error(vm, parser, "Unexpected token \"%.*s\"", - (int) parser->lexer->text.length, - parser->lexer->text.start); + njs_parser_syntax_error(vm, parser, "Unexpected token \"%V\"", + &parser->lexer->text); } else { njs_parser_syntax_error(vm, parser, "Unexpected end of input"); @@ -2665,7 +2656,7 @@ njs_parser_trace_handler(nxt_trace_t *tr p = trace->handler(trace, td, p); if (vm->parser != NULL) { - njs_internal_error(vm, "%s in %u", start, vm->parser->lexer->line); + njs_internal_error(vm, "%s in %uD", start, vm->parser->lexer->line); } else { njs_internal_error(vm, "%s", start); } @@ -2679,14 +2670,13 @@ njs_parser_syntax_error(njs_vm_t *vm, nj ...) { va_list args; - - static char buf[256]; + u_char buf[256], *end; va_start(args, fmt); - (void) vsnprintf(buf, sizeof(buf), fmt, args); + end = nxt_vsprintf(buf, buf + sizeof(buf), fmt, args); va_end(args); - njs_syntax_error(vm, "%s in %u", buf, parser->lexer->line); + njs_syntax_error(vm, "%*s in %uD", end - buf, buf, parser->lexer->line); } @@ -2695,12 +2685,11 @@ njs_parser_ref_error(njs_vm_t *vm, njs_p ...) { va_list args; - - static char buf[256]; + u_char buf[256], *end; va_start(args, fmt); - (void) vsnprintf(buf, sizeof(buf), fmt, args); + end = nxt_vsprintf(buf, buf + sizeof(buf), fmt, args); va_end(args); - njs_reference_error(vm, "%s in %u", buf, parser->lexer->line); + njs_reference_error(vm, "%*s in %uD", end - buf, buf, parser->lexer->line); } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_regexp.c --- a/njs/njs_regexp.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_regexp.c Wed Jan 30 18:49:33 2019 +0300 @@ -88,8 +88,7 @@ njs_regexp_constructor(njs_vm_t *vm, njs flags = njs_regexp_flags(&start, start + string.length, 1); if (nxt_slow_path(flags < 0)) { - njs_syntax_error(vm, "Invalid RegExp flags \"%.*s\"", - (int) string.length, string.start); + njs_syntax_error(vm, "Invalid RegExp flags \"%V\"", &string); return NXT_ERROR; } @@ -163,7 +162,7 @@ njs_regexp_literal(njs_vm_t *vm, njs_par if (nxt_slow_path(flags < 0)) { njs_parser_syntax_error(vm, parser, - "Invalid RegExp flags \"%.*s\"", + "Invalid RegExp flags \"%*s\"", p - lexer->start, lexer->start); return NJS_TOKEN_ILLEGAL; @@ -183,7 +182,7 @@ njs_regexp_literal(njs_vm_t *vm, njs_par } } - njs_parser_syntax_error(vm, parser, "Unterminated RegExp \"%.*s\"", + njs_parser_syntax_error(vm, parser, "Unterminated RegExp \"%*s\"", p - (lexer->start - 1), lexer->start - 1); return NJS_TOKEN_ILLEGAL; @@ -379,7 +378,7 @@ njs_regexp_compile_trace_handler(nxt_tra p = trace->handler(trace, td, start); if (vm->parser != NULL) { - njs_syntax_error(vm, "%s in %u", start, vm->parser->lexer->line); + njs_syntax_error(vm, "%s in %uD", start, vm->parser->lexer->line); } else { njs_syntax_error(vm, "%s", start); diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_string.c --- a/njs/njs_string.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_string.c Wed Jan 30 18:49:33 2019 +0300 @@ -808,7 +808,7 @@ njs_string_prototype_to_string(njs_vm_t return njs_string_base64url(vm, &vm->retval, &str); } - njs_type_error(vm, "Unknown encoding: '%.*s'", (int) enc.length, enc.start); + njs_type_error(vm, "Unknown encoding: '%V'", &enc); return NJS_ERROR; } @@ -1486,8 +1486,7 @@ njs_string_bytes_from_string(njs_vm_t *v return njs_string_decode_base64url(vm, &vm->retval, &str); } - njs_type_error(vm, "Unknown encoding: '%.*s'", (int) enc.length, - enc.start); + njs_type_error(vm, "Unknown encoding: '%V'", &enc); return NJS_ERROR; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_variable.c --- a/njs/njs_variable.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_variable.c Wed Jan 30 18:49:33 2019 +0300 @@ -345,8 +345,7 @@ njs_variable_resolve(njs_vm_t *vm, njs_p not_found: - njs_parser_ref_error(vm, vm->parser, "\"%.*s\" is not defined", - (int) vr->name.length, vr->name.start); + njs_parser_ref_error(vm, vm->parser, "\"%V\" is not defined", &vr->name); return NULL; } diff -r d99f8ee4255c -r dbffb3031c77 njs/njs_vm.c --- a/njs/njs_vm.c Wed Jan 30 18:49:16 2019 +0300 +++ b/njs/njs_vm.c Wed Jan 30 18:49:33 2019 +0300 @@ -566,9 +566,8 @@ njs_vmcode_property_set(njs_vm_t *vm, nj case NXT_DECLINED: if (nxt_slow_path(!object->data.u.object->extensible)) { - njs_type_error(vm, "Cannot add property '%.*s', " - "object is not extensible", pq.lhq.key.length, - pq.lhq.key.start); + njs_type_error(vm, "Cannot add property '%V', " + "object is not extensible", &pq.lhq.key); return NXT_ERROR; } @@ -610,9 +609,8 @@ njs_vmcode_property_set(njs_vm_t *vm, nj } if (nxt_slow_path(!prop->writable)) { - njs_type_error(vm, "Cannot assign to read-only property '%.*s' of %s", - pq.lhq.key.length, pq.lhq.key.start, - njs_type_string(object->type)); + njs_type_error(vm, "Cannot assign to read-only property '%V' of %s", + &pq.lhq.key, njs_type_string(object->type)); return NXT_ERROR; } @@ -722,9 +720,8 @@ njs_vmcode_property_delete(njs_vm_t *vm, } if (nxt_slow_path(!prop->configurable)) { - njs_type_error(vm, "Cannot delete property '%.*s' of %s", - pq.lhq.key.length, pq.lhq.key.start, - njs_type_string(object->type)); + njs_type_error(vm, "Cannot delete property '%V' of %s", + &pq.lhq.key, njs_type_string(object->type)); return NXT_ERROR; } @@ -1994,8 +1991,7 @@ njs_vmcode_method_frame(njs_vm_t *vm, nj if (value == NULL || !njs_is_function(value)) { njs_string_get(name, &string); - njs_type_error(vm, "'%.*s' is not a function", (int) string.length, - string.start); + njs_type_error(vm, "'%V' is not a function", &string); return NXT_ERROR; } From xeioex at nginx.com Wed Jan 30 15:56:40 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Wed, 30 Jan 2019 15:56:40 +0000 Subject: [njs] Unifying quotes usage in exceptions. Message-ID: details: https://hg.nginx.org/njs/rev/ac9b1c01a9b0 branches: changeset: 747:ac9b1c01a9b0 user: Dmitry Volyntsev date: Wed Jan 30 18:50:33 2019 +0300 description: Unifying quotes usage in exceptions. diffstat: njs/njs_crypto.c | 20 ++-- njs/njs_date.c | 2 +- njs/njs_error.c | 2 +- njs/njs_fs.c | 16 +- njs/njs_function.c | 8 +- njs/njs_module.c | 2 +- njs/njs_object.c | 8 +- njs/njs_regexp.c | 6 +- njs/njs_string.c | 6 +- njs/njs_vm.c | 16 +- njs/test/njs_expect_test.exp | 4 +- njs/test/njs_interactive_test.c | 16 +- njs/test/njs_unit_test.c | 162 ++++++++++++++++++++-------------------- 13 files changed, 134 insertions(+), 134 deletions(-) diffs (truncated from 1067 to 1000 lines): diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_crypto.c --- a/njs/njs_crypto.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_crypto.c Wed Jan 30 18:50:33 2019 +0300 @@ -211,12 +211,12 @@ njs_hash_prototype_update(njs_vm_t *vm, } if (nxt_slow_path(!njs_is_object_value(&args[0]))) { - njs_type_error(vm, "'this' is not an object_value"); + njs_type_error(vm, "\"this\" is not an object_value"); return NJS_ERROR; } if (nxt_slow_path(!njs_is_data(&args[0].data.u.object_value->value))) { - njs_type_error(vm, "value of 'this' is not a data type"); + njs_type_error(vm, "value of \"this\" is not a data type"); return NJS_ERROR; } @@ -257,12 +257,12 @@ njs_hash_prototype_digest(njs_vm_t *vm, } if (nxt_slow_path(!njs_is_object_value(&args[0]))) { - njs_type_error(vm, "'this' is not an object_value"); + njs_type_error(vm, "\"this\" is not an object_value"); return NJS_ERROR; } if (nxt_slow_path(!njs_is_data(&args[0].data.u.object_value->value))) { - njs_type_error(vm, "value of 'this' is not a data type"); + njs_type_error(vm, "value of \"this\" is not a data type"); return NJS_ERROR; } @@ -470,12 +470,12 @@ njs_hmac_prototype_update(njs_vm_t *vm, } if (nxt_slow_path(!njs_is_object_value(&args[0]))) { - njs_type_error(vm, "'this' is not an object_value"); + njs_type_error(vm, "\"this\" is not an object_value"); return NJS_ERROR; } if (nxt_slow_path(!njs_is_data(&args[0].data.u.object_value->value))) { - njs_type_error(vm, "value of 'this' is not a data type"); + njs_type_error(vm, "value of \"this\" is not a data type"); return NJS_ERROR; } @@ -516,12 +516,12 @@ njs_hmac_prototype_digest(njs_vm_t *vm, } if (nxt_slow_path(!njs_is_object_value(&args[0]))) { - njs_type_error(vm, "'this' is not an object_value"); + njs_type_error(vm, "\"this\" is not an object_value"); return NJS_ERROR; } if (nxt_slow_path(!njs_is_data(&args[0].data.u.object_value->value))) { - njs_type_error(vm, "value of 'this' is not a data type"); + njs_type_error(vm, "value of \"this\" is not a data type"); return NJS_ERROR; } @@ -691,7 +691,7 @@ njs_crypto_alg(njs_vm_t *vm, const nxt_s } } - njs_type_error(vm, "not supported algorithm: '%V'", name); + njs_type_error(vm, "not supported algorithm: \"%V\"", name); return NULL; } @@ -708,7 +708,7 @@ njs_crypto_encoding(njs_vm_t *vm, const } } - njs_type_error(vm, "Unknown digest encoding: '%V'", name); + njs_type_error(vm, "Unknown digest encoding: \"%V\"", name); return NULL; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_date.c --- a/njs/njs_date.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_date.c Wed Jan 30 18:50:33 2019 +0300 @@ -1901,7 +1901,7 @@ njs_date_prototype_to_json(njs_vm_t *vm, } } - njs_type_error(vm, "'this' argument is not an object"); + njs_type_error(vm, "\"this\" argument is not an object"); return NXT_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_error.c --- a/njs/njs_error.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_error.c Wed Jan 30 18:50:33 2019 +0300 @@ -583,7 +583,7 @@ njs_error_prototype_to_string(njs_vm_t * njs_index_t unused) { if (nargs < 1 || !njs_is_object(&args[0])) { - njs_type_error(vm, "'this' argument is not an object"); + njs_type_error(vm, "\"this\" argument is not an object"); return NXT_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_fs.c --- a/njs/njs_fs.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_fs.c Wed Jan 30 18:50:33 2019 +0300 @@ -165,7 +165,7 @@ njs_fs_read_file(njs_vm_t *vm, njs_value flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%V'", &flag); + njs_type_error(vm, "Unknown file open flags: \"%V\"", &flag); return NJS_ERROR; } @@ -177,7 +177,7 @@ njs_fs_read_file(njs_vm_t *vm, njs_value if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%V'", &encoding); + njs_type_error(vm, "Unknown encoding: \"%V\"", &encoding); return NJS_ERROR; } @@ -360,7 +360,7 @@ njs_fs_read_file_sync(njs_vm_t *vm, njs_ flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%V'", &flag); + njs_type_error(vm, "Unknown file open flags: \"%V\"", &flag); return NJS_ERROR; } @@ -372,7 +372,7 @@ njs_fs_read_file_sync(njs_vm_t *vm, njs_ if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%V'", &encoding); + njs_type_error(vm, "Unknown encoding: \"%V\"", &encoding); return NJS_ERROR; } @@ -607,7 +607,7 @@ static njs_ret_t njs_fs_write_file_inter if (flag.start != NULL) { flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%V'", &flag); + njs_type_error(vm, "Unknown file open flags: \"%V\"", &flag); return NJS_ERROR; } @@ -630,7 +630,7 @@ static njs_ret_t njs_fs_write_file_inter if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%V'", &encoding); + njs_type_error(vm, "Unknown encoding: \"%V\"", &encoding); return NJS_ERROR; } @@ -779,7 +779,7 @@ njs_fs_write_file_sync_internal(njs_vm_t if (flag.start != NULL) { flags = njs_fs_flags(&flag); if (nxt_slow_path(flags == -1)) { - njs_type_error(vm, "Unknown file open flags: '%V'", &flag); + njs_type_error(vm, "Unknown file open flags: \"%V\"", &flag); return NJS_ERROR; } @@ -802,7 +802,7 @@ njs_fs_write_file_sync_internal(njs_vm_t if (encoding.length != 0 && (encoding.length != 4 || memcmp(encoding.start, "utf8", 4) != 0)) { - njs_type_error(vm, "Unknown encoding: '%V'", &encoding); + njs_type_error(vm, "Unknown encoding: \"%V\"", &encoding); return NJS_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_function.c --- a/njs/njs_function.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_function.c Wed Jan 30 18:50:33 2019 +0300 @@ -208,7 +208,7 @@ njs_ret_t njs_function_arguments_thrower(njs_vm_t *vm, njs_value_t *value, njs_value_t *setval, njs_value_t *retval) { - njs_type_error(vm, "'caller', 'callee' properties may not be accessed"); + njs_type_error(vm, "\"caller\", \"callee\" properties may not be accessed"); return NXT_ERROR; } @@ -865,7 +865,7 @@ njs_function_prototype_call(njs_vm_t *vm njs_function_t *function; if (!njs_is_function(&args[0])) { - njs_type_error(vm, "'this' argument is not a function"); + njs_type_error(vm, "\"this\" argument is not a function"); return NXT_ERROR; } @@ -903,7 +903,7 @@ njs_function_prototype_apply(njs_vm_t *v njs_function_t *function; if (!njs_is_function(&args[0])) { - njs_type_error(vm, "'this' argument is not a function"); + njs_type_error(vm, "\"this\" argument is not a function"); return NXT_ERROR; } @@ -988,7 +988,7 @@ njs_function_prototype_bind(njs_vm_t *vm njs_function_t *function; if (!njs_is_function(&args[0])) { - njs_type_error(vm, "'this' argument is not a function"); + njs_type_error(vm, "\"this\" argument is not a function"); return NXT_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_module.c --- a/njs/njs_module.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_module.c Wed Jan 30 18:50:33 2019 +0300 @@ -62,7 +62,7 @@ njs_ret_t njs_module_require(njs_vm_t *v return NXT_OK; } - njs_error(vm, "Cannot find module '%V'", &lhq.key); + njs_error(vm, "Cannot find module \"%V\"", &lhq.key); return NJS_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_object.c --- a/njs/njs_object.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_object.c Wed Jan 30 18:50:33 2019 +0300 @@ -364,12 +364,12 @@ njs_property_query(njs_vm_t *vm, njs_pro if (nxt_fast_path(ret == NXT_OK)) { njs_string_get(&pq->value, &pq->lhq.key); - njs_type_error(vm, "cannot get property '%V' of undefined", + njs_type_error(vm, "cannot get property \"%V\" of undefined", &pq->lhq.key); return NXT_ERROR; } - njs_type_error(vm, "cannot get property 'unknown' of undefined"); + njs_type_error(vm, "cannot get property \"unknown\" of undefined"); return NXT_ERROR; } @@ -1483,7 +1483,7 @@ njs_define_property(njs_vm_t *vm, njs_va return NXT_OK; default: - njs_internal_error(vm, "unexpected property type '%s' " + njs_internal_error(vm, "unexpected property type \"%s\" " "while defining property", njs_prop_type_string(current->type)); @@ -1535,7 +1535,7 @@ njs_define_property(njs_vm_t *vm, njs_va exception: - njs_type_error(vm, "Cannot redefine property: '%V'", &pq.lhq.key); + njs_type_error(vm, "Cannot redefine property: \"%V\"", &pq.lhq.key); return NXT_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_regexp.c --- a/njs/njs_regexp.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_regexp.c Wed Jan 30 18:50:33 2019 +0300 @@ -540,7 +540,7 @@ njs_regexp_prototype_to_string(njs_vm_t return njs_regexp_to_string(vm, &vm->retval, &args[0]); } - njs_type_error(vm, "'this' argument is not a regexp"); + njs_type_error(vm, "\"this\" argument is not a regexp"); return NXT_ERROR; } @@ -577,7 +577,7 @@ njs_regexp_prototype_test(njs_vm_t *vm, njs_regexp_pattern_t *pattern; if (!njs_is_regexp(&args[0])) { - njs_type_error(vm, "'this' argument is not a regexp"); + njs_type_error(vm, "\"this\" argument is not a regexp"); return NXT_ERROR; } @@ -627,7 +627,7 @@ njs_regexp_prototype_exec(njs_vm_t *vm, nxt_regex_match_data_t *match_data; if (!njs_is_regexp(&args[0])) { - njs_type_error(vm, "'this' argument is not a regexp"); + njs_type_error(vm, "\"this\" argument is not a regexp"); return NXT_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_string.c --- a/njs/njs_string.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_string.c Wed Jan 30 18:50:33 2019 +0300 @@ -808,7 +808,7 @@ njs_string_prototype_to_string(njs_vm_t return njs_string_base64url(vm, &vm->retval, &str); } - njs_type_error(vm, "Unknown encoding: '%V'", &enc); + njs_type_error(vm, "Unknown encoding: \"%V\"", &enc); return NJS_ERROR; } @@ -829,7 +829,7 @@ njs_string_prototype_concat(njs_vm_t *vm njs_string_prop_t string; if (njs_is_null_or_void(&args[0])) { - njs_type_error(vm, "'this' argument is null or undefined"); + njs_type_error(vm, "\"this\" argument is null or undefined"); return NXT_ERROR; } @@ -1486,7 +1486,7 @@ njs_string_bytes_from_string(njs_vm_t *v return njs_string_decode_base64url(vm, &vm->retval, &str); } - njs_type_error(vm, "Unknown encoding: '%V'", &enc); + njs_type_error(vm, "Unknown encoding: \"%V\"", &enc); return NJS_ERROR; } diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/njs_vm.c --- a/njs/njs_vm.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/njs_vm.c Wed Jan 30 18:50:33 2019 +0300 @@ -555,7 +555,7 @@ njs_vmcode_property_set(njs_vm_t *vm, nj break; default: - njs_internal_error(vm, "unexpected property type '%s' " + njs_internal_error(vm, "unexpected property type \"%s\" " "while setting", njs_prop_type_string(prop->type)); @@ -566,7 +566,7 @@ njs_vmcode_property_set(njs_vm_t *vm, nj case NXT_DECLINED: if (nxt_slow_path(!object->data.u.object->extensible)) { - njs_type_error(vm, "Cannot add property '%V', " + njs_type_error(vm, "Cannot add property \"%V\", " "object is not extensible", &pq.lhq.key); return NXT_ERROR; } @@ -609,7 +609,7 @@ njs_vmcode_property_set(njs_vm_t *vm, nj } if (nxt_slow_path(!prop->writable)) { - njs_type_error(vm, "Cannot assign to read-only property '%V' of %s", + njs_type_error(vm, "Cannot assign to read-only property \"%V\" of %s", &pq.lhq.key, njs_type_string(object->type)); return NXT_ERROR; } @@ -712,7 +712,7 @@ njs_vmcode_property_delete(njs_vm_t *vm, break; default: - njs_internal_error(vm, "unexpected property type '%s' " + njs_internal_error(vm, "unexpected property type \"%s\" " "while deleting", njs_prop_type_string(prop->type)); @@ -720,7 +720,7 @@ njs_vmcode_property_delete(njs_vm_t *vm, } if (nxt_slow_path(!prop->configurable)) { - njs_type_error(vm, "Cannot delete property '%V' of %s", + njs_type_error(vm, "Cannot delete property \"%V\" of %s", &pq.lhq.key, njs_type_string(object->type)); return NXT_ERROR; } @@ -1968,7 +1968,7 @@ njs_vmcode_method_frame(njs_vm_t *vm, nj break; default: - njs_internal_error(vm, "unexpected property type '%s' " + njs_internal_error(vm, "unexpected property type \"%s\" " "while getting method", njs_prop_type_string(prop->type)); @@ -1991,7 +1991,7 @@ njs_vmcode_method_frame(njs_vm_t *vm, nj if (value == NULL || !njs_is_function(value)) { njs_string_get(name, &string); - njs_type_error(vm, "'%V' is not a function", &string); + njs_type_error(vm, "\"%V\" is not a function", &string); return NXT_ERROR; } @@ -3020,7 +3020,7 @@ njs_value_property(njs_vm_t *vm, njs_val break; default: - njs_internal_error(vm, "unexpected property type '%s' " + njs_internal_error(vm, "unexpected property type \"%s\" " "while getting", njs_prop_type_string(prop->type)); diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/test/njs_expect_test.exp --- a/njs/test/njs_expect_test.exp Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/test/njs_expect_test.exp Wed Jan 30 18:50:33 2019 +0300 @@ -208,7 +208,7 @@ njs_test { njs_test { {"console.ll()\r\n" - "console.ll()\r\nTypeError: 'll' is not a function"} + "console.ll()\r\nTypeError: \"ll\" is not a function"} } njs_test { @@ -606,7 +606,7 @@ njs_test { njs_test { {"var fs = require('fs')\r\n" - "Error: Cannot find module 'fs'\r\n"} + "Error: Cannot find module \"fs\"\r\n"} } "-s" njs_test { diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/test/njs_interactive_test.c --- a/njs/test/njs_interactive_test.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/test/njs_interactive_test.c Wed Jan 30 18:50:33 2019 +0300 @@ -115,7 +115,7 @@ static njs_interactive_test_t njs_test[ { nxt_string("function ff(o) {return o.a.a}" ENTER "function f(o) {return ff(o)}" ENTER "f({})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at ff (:1)\n" " at f (:1)\n" " at main (native)\n") }, @@ -124,20 +124,20 @@ static njs_interactive_test_t njs_test[ "function f(o) {try {return ff(o)} " "finally {return o.a.a}}" ENTER "f({})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at f (:1)\n" " at main (native)\n") }, { nxt_string("function f(ff, o) {return ff(o)}" ENTER "f(function (o) {return o.a.a}, {})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at anonymous (:1)\n" " at f (:1)\n" " at main (native)\n") }, { nxt_string("'str'.replace(/t/g," " function(m) {return m.a.a})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at anonymous (:1)\n" " at String.prototype.replace (native)\n" " at main (native)\n") }, @@ -155,7 +155,7 @@ static njs_interactive_test_t njs_test[ " at main (native)\n") }, { nxt_string("Math.log({}.a.a)" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at Math.log (native)\n" " at main (native)\n") }, @@ -175,7 +175,7 @@ static njs_interactive_test_t njs_test[ " at main (native)\n") }, { nxt_string("require('crypto').createHash('sha')" ENTER), - nxt_string("TypeError: not supported algorithm: 'sha'\n" + nxt_string("TypeError: not supported algorithm: \"sha\"\n" " at crypto.createHash (native)\n" " at main (native)\n") }, @@ -198,14 +198,14 @@ static njs_interactive_test_t njs_test[ { nxt_string("function f(o) {function f_in(o) {return o.a.a};" " return f_in(o)}; f({})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at f_in (:1)\n" " at f (:1)\n" " at main (native)\n") }, { nxt_string("function f(o) {var ff = function (o) {return o.a.a};" " return ff(o)}; f({})" ENTER), - nxt_string("TypeError: cannot get property 'a' of undefined\n" + nxt_string("TypeError: cannot get property \"a\" of undefined\n" " at anonymous (:1)\n" " at f (:1)\n" " at main (native)\n") }, diff -r dbffb3031c77 -r ac9b1c01a9b0 njs/test/njs_unit_test.c --- a/njs/test/njs_unit_test.c Wed Jan 30 18:49:33 2019 +0300 +++ b/njs/test/njs_unit_test.c Wed Jan 30 18:50:33 2019 +0300 @@ -551,7 +551,7 @@ static njs_unit_test_t njs_test[] = nxt_string("TypeError: argument must be a byte string") }, { nxt_string("'A'.toBytes().toString('latin1')"), - nxt_string("TypeError: Unknown encoding: 'latin1'") }, + nxt_string("TypeError: Unknown encoding: \"latin1\"") }, { nxt_string("'ABCD'.toBytes().toString('hex')"), nxt_string("41424344") }, @@ -2624,7 +2624,7 @@ static njs_unit_test_t njs_test[] = nxt_string("undefined") }, { nxt_string("var a = {}; a.b.c"), - nxt_string("TypeError: cannot get property 'c' of undefined") }, + nxt_string("TypeError: cannot get property \"c\" of undefined") }, { nxt_string("'a'[0]"), nxt_string("a") }, @@ -2672,10 +2672,10 @@ static njs_unit_test_t njs_test[] = nxt_string("3") }, { nxt_string("var a = undefined; a.b++; a.b"), - nxt_string("TypeError: cannot get property 'b' of undefined") }, + nxt_string("TypeError: cannot get property \"b\" of undefined") }, { nxt_string("var a = null; a.b++; a.b"), - nxt_string("TypeError: cannot get property 'b' of undefined") }, + nxt_string("TypeError: cannot get property \"b\" of undefined") }, { nxt_string("var a = true; a.b++; a.b"), nxt_string("TypeError: property set on primitive boolean type") }, @@ -2738,7 +2738,7 @@ static njs_unit_test_t njs_test[] = nxt_string("SyntaxError: Unexpected token \";\" in 1") }, { nxt_string("var x = { a: 1, b: x.a }"), - nxt_string("TypeError: cannot get property 'a' of undefined") }, + nxt_string("TypeError: cannot get property \"a\" of undefined") }, { nxt_string("var a = { b: 2 }; a.b += 1"), nxt_string("3") }, @@ -2829,10 +2829,10 @@ static njs_unit_test_t njs_test[] = /* Math object is immutable. */ { nxt_string("delete Math.max"), - nxt_string("TypeError: Cannot delete property 'max' of object") }, + nxt_string("TypeError: Cannot delete property \"max\" of object") }, { nxt_string("Math.E = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'E' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"E\" of object") }, { nxt_string("var o = { 'a': 1, 'b': 2 }; var i; " "for (i in o) { delete o.a; delete o.b; }; njs.dump(o)"), @@ -4365,9 +4365,9 @@ static njs_unit_test_t njs_test[] = nxt_string("12") }, { nxt_string("var p = $r3.props; p.a = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of external") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of external") }, { nxt_string("var p = $r3.props; delete p.a"), - nxt_string("TypeError: Cannot delete property 'a' of external") }, + nxt_string("TypeError: Cannot delete property \"a\" of external") }, { nxt_string("$r.vars.p + $r2.vars.q + $r3.vars.k"), nxt_string("pvalqvalkval") }, @@ -4400,10 +4400,10 @@ static njs_unit_test_t njs_test[] = nxt_string("b") }, { nxt_string("$r3.vars.error = 1"), - nxt_string("Error: cannot set 'error' prop") }, + nxt_string("Error: cannot set \"error\" prop") }, { nxt_string("delete $r3.vars.error"), - nxt_string("Error: cannot delete 'error' prop") }, + nxt_string("Error: cannot delete \"error\" prop") }, { nxt_string("delete $r3.vars.e"), nxt_string("true") }, @@ -4412,10 +4412,10 @@ static njs_unit_test_t njs_test[] = nxt_string("kval") }, { nxt_string("$r3.consts.k = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'k' of external") }, + nxt_string("TypeError: Cannot assign to read-only property \"k\" of external") }, { nxt_string("delete $r3.consts.k"), - nxt_string("TypeError: Cannot delete property 'k' of external") }, + nxt_string("TypeError: Cannot delete property \"k\" of external") }, { nxt_string("delete $r3.vars.p; $r3.vars.p"), nxt_string("undefined") }, @@ -4464,10 +4464,10 @@ static njs_unit_test_t njs_test[] = nxt_string("true") }, { nxt_string("delete $r.uri"), - nxt_string("TypeError: Cannot delete property 'uri' of external") }, + nxt_string("TypeError: Cannot delete property \"uri\" of external") }, { nxt_string("delete $r.one"), - nxt_string("TypeError: Cannot delete property 'one' of external") }, + nxt_string("TypeError: Cannot delete property \"one\" of external") }, { nxt_string("$r.some_method.call($r, 'YES')"), nxt_string("???") }, @@ -4488,7 +4488,7 @@ static njs_unit_test_t njs_test[] = nxt_string("undefined") }, { nxt_string("$r.error = 'OK'"), - nxt_string("TypeError: Cannot assign to read-only property 'error' of external") }, + nxt_string("TypeError: Cannot assign to read-only property \"error\" of external") }, { nxt_string("var a = { toString: function() { return 1 } }; a"), nxt_string("1") }, @@ -5314,7 +5314,7 @@ static njs_unit_test_t njs_test[] = nxt_string("0") }, { nxt_string("function f() { }; f.length = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'length' of function") }, + nxt_string("TypeError: Cannot assign to read-only property \"length\" of function") }, { nxt_string("function f(...rest) { }; f.length"), nxt_string("0") }, @@ -5396,7 +5396,7 @@ static njs_unit_test_t njs_test[] = nxt_string("TypeError: number is not a function") }, { nxt_string("var o = {a:1}; o.a()"), - nxt_string("TypeError: 'a' is not a function") }, + nxt_string("TypeError: \"a\" is not a function") }, { nxt_string("(function(){})()"), nxt_string("undefined") }, @@ -5769,7 +5769,7 @@ static njs_unit_test_t njs_test[] = nxt_string("[object Function]") }, { nxt_string("''.concat.call()"), - nxt_string("TypeError: 'this' argument is null or undefined") }, + nxt_string("TypeError: \"this\" argument is null or undefined") }, { nxt_string("''.concat.call('a', 'b', 'c')"), nxt_string("abc") }, @@ -5784,7 +5784,7 @@ static njs_unit_test_t njs_test[] = nxt_string("ab,cd") }, { nxt_string("''.concat.apply()"), - nxt_string("TypeError: 'this' argument is null or undefined") }, + nxt_string("TypeError: \"this\" argument is null or undefined") }, { nxt_string("''.concat.apply('a')"), nxt_string("a") }, @@ -5855,7 +5855,7 @@ static njs_unit_test_t njs_test[] = nxt_string("01") }, { nxt_string("var concat = ''.concat; concat(1,2,3)"), - nxt_string("TypeError: 'this' argument is null or undefined") }, + nxt_string("TypeError: \"this\" argument is null or undefined") }, { nxt_string("var concat = ''.concat; concat.call(1,2,3)"), nxt_string("123") }, @@ -6064,10 +6064,10 @@ static njs_unit_test_t njs_test[] = nxt_string("1") }, { nxt_string("(function(){return arguments.callee;})()"), - nxt_string("TypeError: 'caller', 'callee' properties may not be accessed") }, + nxt_string("TypeError: \"caller\", \"callee\" properties may not be accessed") }, { nxt_string("(function(){return arguments.caller;})()"), - nxt_string("TypeError: 'caller', 'callee' properties may not be accessed") }, + nxt_string("TypeError: \"caller\", \"callee\" properties may not be accessed") }, { nxt_string("function sum() { var args = Array.prototype.slice.call(arguments); " "return args.reduce(function(prev, curr) {return prev + curr})};" @@ -6273,7 +6273,7 @@ static njs_unit_test_t njs_test[] = nxt_string("SyntaxError: Invalid RegExp flags \"x\"") }, { nxt_string("[0].map(RegExp().toString)"), - nxt_string("TypeError: 'this' argument is not a regexp") }, + nxt_string("TypeError: \"this\" argument is not a regexp") }, /* Non-standard ECMA-262 features. */ @@ -6403,7 +6403,7 @@ static njs_unit_test_t njs_test[] = /* Memory object is immutable. */ { nxt_string("var e = MemoryError('e'); e.name = 'E'"), - nxt_string("TypeError: Cannot add property 'name', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"name\", object is not extensible") }, { nxt_string("EvalError.prototype.name"), nxt_string("EvalError") }, @@ -6564,10 +6564,10 @@ static njs_unit_test_t njs_test[] = nxt_string("SyntaxError: Unexpected token \"null\" in 1") }, { nxt_string("'a'.f()"), - nxt_string("TypeError: 'f' is not a function") }, + nxt_string("TypeError: \"f\" is not a function") }, { nxt_string("1..f()"), - nxt_string("TypeError: 'f' is not a function") }, + nxt_string("TypeError: \"f\" is not a function") }, { nxt_string("try {}"), nxt_string("SyntaxError: Missing catch or finally after try in 1") }, @@ -7002,13 +7002,13 @@ static njs_unit_test_t njs_test[] = nxt_string("1") }, { nxt_string("this.undefined = 42"), - nxt_string("TypeError: Cannot assign to read-only property 'undefined' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"undefined\" of object") }, { nxt_string("this.Infinity = 42"), - nxt_string("TypeError: Cannot assign to read-only property 'Infinity' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"Infinity\" of object") }, { nxt_string("this.NaN = 42"), - nxt_string("TypeError: Cannot assign to read-only property 'NaN' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"NaN\" of object") }, { nxt_string("typeof this.undefined"), nxt_string("undefined") }, @@ -7077,7 +7077,7 @@ static njs_unit_test_t njs_test[] = nxt_string("true") }, { nxt_string("Object.prototype.__proto__.f()"), - nxt_string("TypeError: cannot get property 'f' of undefined") }, + nxt_string("TypeError: cannot get property \"f\" of undefined") }, { nxt_string("Object.prototype.toString.call(Object.prototype)"), nxt_string("[object Object]") }, @@ -7098,7 +7098,7 @@ static njs_unit_test_t njs_test[] = nxt_string("true") }, { nxt_string("({}).__proto__ = 1"), - nxt_string("TypeError: Cannot assign to read-only property '__proto__' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"__proto__\" of object") }, { nxt_string("({}).__proto__.constructor === Object"), nxt_string("true") }, @@ -7504,7 +7504,7 @@ static njs_unit_test_t njs_test[] = nxt_string("?") }, { nxt_string("var s = new String('??'); s[1] = 'b'"), - nxt_string("TypeError: Cannot assign to read-only property '1' of object string") }, + nxt_string("TypeError: Cannot assign to read-only property \"1\" of object string") }, { nxt_string("var s = new String('??'); s[4] = 'ab'; s[4]"), nxt_string("ab") }, @@ -7861,10 +7861,10 @@ static njs_unit_test_t njs_test[] = nxt_string("a,1,c,3,b,2") }, { nxt_string("var o = {}; Object.defineProperty(o, 'a', {}); o.a = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of object") }, { nxt_string("var o = {}; Object.defineProperty(o, 'a', {writable:false}); o.a = 1"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of object") }, { nxt_string("var o = {}; Object.defineProperty(o, 'a', {writable:true});" "o.a = 1; o.a"), @@ -7872,7 +7872,7 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {value:1}); delete o.a"), - nxt_string("TypeError: Cannot delete property 'a' of object") }, + nxt_string("TypeError: Cannot delete property \"a\" of object") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {value:1, configurable:true});" @@ -7882,7 +7882,7 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {value:1, configurable:false});" "delete o.a"), - nxt_string("TypeError: Cannot delete property 'a' of object") }, + nxt_string("TypeError: Cannot delete property \"a\" of object") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', Object.create({value:2})); o.a"), @@ -7891,17 +7891,17 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {configurable:false});" "Object.defineProperty(o, 'a', {configurable:true})"), - nxt_string("TypeError: Cannot redefine property: 'a'") }, + nxt_string("TypeError: Cannot redefine property: \"a\"") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {configurable:false});" "Object.defineProperty(o, 'a', {enumerable:true})"), - nxt_string("TypeError: Cannot redefine property: 'a'") }, + nxt_string("TypeError: Cannot redefine property: \"a\"") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {configurable:false});" "Object.defineProperty(o, 'a', {writable:true})"), - nxt_string("TypeError: Cannot redefine property: 'a'") }, + nxt_string("TypeError: Cannot redefine property: \"a\"") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {configurable:false});" @@ -7936,7 +7936,7 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {value:1});" "Object.defineProperty(o, 'a', {value:2}).a"), - nxt_string("TypeError: Cannot redefine property: 'a'") }, + nxt_string("TypeError: Cannot redefine property: \"a\"") }, { nxt_string("var o = {};" "Object.defineProperty(o, 'a', {configurable:true});" @@ -7973,7 +7973,7 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = {a:1}; delete o.a;" "Object.defineProperty(o, 'a', { value: 1 }); o.a = 2; o.a"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of object") }, { nxt_string("var o = {a:1}; delete o.a;" "Object.defineProperty(o, 'a', { value: 1, writable:1 }); o.a = 2; o.a"), @@ -8227,16 +8227,16 @@ static njs_unit_test_t njs_test[] = nxt_string("undefined") }, { nxt_string("var o = Object.freeze({a:1}); o.a = 2"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of object") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of object") }, { nxt_string("var o = Object.freeze({a:1}); delete o.a"), - nxt_string("TypeError: Cannot delete property 'a' of object") }, + nxt_string("TypeError: Cannot delete property \"a\" of object") }, { nxt_string("var o = Object.freeze({a:1}); o.b = 1; o.b"), - nxt_string("TypeError: Cannot add property 'b', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"b\", object is not extensible") }, { nxt_string("var o = Object.freeze(Object.create({a:1})); o.a = 2; o.a"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("var o = Object.freeze({a:{b:1}}); o.a.b = 2; o.a.b"), nxt_string("2") }, @@ -8249,13 +8249,13 @@ static njs_unit_test_t njs_test[] = nxt_string("TypeError: object is not extensible") }, { nxt_string("var a = [1,2]; a.a = 1; Object.freeze(a); delete a.a"), - nxt_string("TypeError: Cannot delete property 'a' of array") }, + nxt_string("TypeError: Cannot delete property \"a\" of array") }, { nxt_string("var a = [1,2]; a.a = 1; Object.freeze(a); a.a = 2"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of array") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of array") }, { nxt_string("var a = Object.freeze([1,2]); a.a = 1"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("Object.defineProperty(function() {}, 'a', {value:1}).a"), nxt_string("1") }, @@ -8265,13 +8265,13 @@ static njs_unit_test_t njs_test[] = nxt_string("TypeError: object is not extensible") }, { nxt_string("var f = function() {}; f.a = 1; Object.freeze(f); delete f.a"), - nxt_string("TypeError: Cannot delete property 'a' of function") }, + nxt_string("TypeError: Cannot delete property \"a\" of function") }, { nxt_string("var f = function() {}; f.a = 1; Object.freeze(f); f.a = 2"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of function") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of function") }, { nxt_string("var f = Object.freeze(function() {}); f.a = 1"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("Object.defineProperty(new Date(''), 'a', {value:1}).a"), nxt_string("1") }, @@ -8282,13 +8282,13 @@ static njs_unit_test_t njs_test[] = { nxt_string("var d = new Date(''); d.a = 1; Object.freeze(d);" "delete d.a"), - nxt_string("TypeError: Cannot delete property 'a' of date") }, + nxt_string("TypeError: Cannot delete property \"a\" of date") }, { nxt_string("var d = new Date(''); d.a = 1; Object.freeze(d); d.a = 2"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of date") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of date") }, { nxt_string("var d = Object.freeze(new Date('')); d.a = 1"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("Object.defineProperty(new RegExp(''), 'a', {value:1}).a"), nxt_string("1") }, @@ -8298,13 +8298,13 @@ static njs_unit_test_t njs_test[] = nxt_string("TypeError: object is not extensible") }, { nxt_string("var r = new RegExp(''); r.a = 1; Object.freeze(r); delete r.a"), - nxt_string("TypeError: Cannot delete property 'a' of regexp") }, + nxt_string("TypeError: Cannot delete property \"a\" of regexp") }, { nxt_string("var r = new RegExp(''); r.a = 1; Object.freeze(r); r.a = 2"), - nxt_string("TypeError: Cannot assign to read-only property 'a' of regexp") }, + nxt_string("TypeError: Cannot assign to read-only property \"a\" of regexp") }, { nxt_string("var r = Object.freeze(new RegExp('')); r.a = 1"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("Object.isFrozen({a:1})"), nxt_string("false") }, @@ -8364,13 +8364,13 @@ static njs_unit_test_t njs_test[] = nxt_string("2") }, { nxt_string("var o = Object.seal({a:1}); delete o.a"), - nxt_string("TypeError: Cannot delete property 'a' of object") }, + nxt_string("TypeError: Cannot delete property \"a\" of object") }, { nxt_string("var o = Object.seal({a:1}); o.b = 1; o.b"), - nxt_string("TypeError: Cannot add property 'b', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"b\", object is not extensible") }, { nxt_string("var o = Object.seal(Object.create({a:1})); o.a = 2; o.a"), - nxt_string("TypeError: Cannot add property 'a', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"a\", object is not extensible") }, { nxt_string("var o = Object.seal({a:{b:1}}); o.a.b = 2; o.a.b"), nxt_string("2") }, @@ -8453,7 +8453,7 @@ static njs_unit_test_t njs_test[] = nxt_string("undefined") }, { nxt_string("var o = Object.preventExtensions({a:1}); o.b = 1; o.b"), - nxt_string("TypeError: Cannot add property 'b', object is not extensible") }, + nxt_string("TypeError: Cannot add property \"b\", object is not extensible") }, { nxt_string("Object.preventExtensions()"), nxt_string("undefined") }, @@ -10296,7 +10296,7 @@ static njs_unit_test_t njs_test[] = { nxt_string("var o = JSON.parse('{\"a\":1}', " " function(k, v) {return v.a.a;}); o"), - nxt_string("TypeError: cannot get property 'a' of undefined") }, + nxt_string("TypeError: cannot get property \"a\" of undefined") }, /* JSON.stringify() */ @@ -10630,7 +10630,7 @@ static njs_unit_test_t njs_test[] = /* require(). */ { nxt_string("require('unknown_module')"), - nxt_string("Error: Cannot find module 'unknown_module'") }, + nxt_string("Error: Cannot find module \"unknown_module\"") }, { nxt_string("require()"), nxt_string("TypeError: missing path") }, @@ -10658,15 +10658,15 @@ static njs_unit_test_t njs_test[] = { nxt_string("var fs = require('fs');" "fs.readFile('/njs_unknown_path', {flag:'xx'}, function () {})"), - nxt_string("TypeError: Unknown file open flags: 'xx'") }, + nxt_string("TypeError: Unknown file open flags: \"xx\"") }, { nxt_string("var fs = require('fs');" "fs.readFile('/njs_unknown_path', {encoding:'ascii'}, function () {})"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, { nxt_string("var fs = require('fs');" "fs.readFile('/njs_unknown_path', 'ascii', function () {})"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, /* require('fs').readFileSync() */ @@ -10680,15 +10680,15 @@ static njs_unit_test_t njs_test[] = { nxt_string("var fs = require('fs');" "fs.readFileSync('/njs_unknown_path', {flag:'xx'})"), - nxt_string("TypeError: Unknown file open flags: 'xx'") }, + nxt_string("TypeError: Unknown file open flags: \"xx\"") }, { nxt_string("var fs = require('fs');" "fs.readFileSync('/njs_unknown_path', {encoding:'ascii'})"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, { nxt_string("var fs = require('fs');" "fs.readFileSync('/njs_unknown_path', 'ascii')"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, { nxt_string("var fs = require('fs');" "fs.readFileSync('/njs_unknown_path', true)"), @@ -10719,15 +10719,15 @@ static njs_unit_test_t njs_test[] = { nxt_string("var fs = require('fs');" "fs.writeFile('/njs_unknown_path', '', {flag:'xx'}, function () {})"), - nxt_string("TypeError: Unknown file open flags: 'xx'") }, + nxt_string("TypeError: Unknown file open flags: \"xx\"") }, { nxt_string("var fs = require('fs');" "fs.writeFile('/njs_unknown_path', '', {encoding:'ascii'}, function () {})"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, { nxt_string("var fs = require('fs');" "fs.writeFile('/njs_unknown_path', '', 'ascii', function () {})"), - nxt_string("TypeError: Unknown encoding: 'ascii'") }, + nxt_string("TypeError: Unknown encoding: \"ascii\"") }, From pluknet at nginx.com Thu Jan 31 11:56:10 2019 From: pluknet at nginx.com (Sergey Kandaurov) Date: Thu, 31 Jan 2019 11:56:10 +0000 Subject: [nginx] Configure: added explicit ngx_binext to the linker output argument. Message-ID: details: https://hg.nginx.org/nginx/rev/2d9ab7717e23 branches: changeset: 7450:2d9ab7717e23 user: Sergey Kandaurov date: Wed Jan 30 19:28:27 2019 +0300 description: Configure: added explicit ngx_binext to the linker output argument. Unlike with GCC or MSVC, Clang linker doesn't auto-append ".exe" to the name of the output binary when building on win32. diffstat: auto/make | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 3c51385e5da1 -r 2d9ab7717e23 auto/make --- a/auto/make Mon Jan 28 14:34:02 2019 +0000 +++ b/auto/make Wed Jan 30 19:28:27 2019 +0300 @@ -229,7 +229,7 @@ build: binary modules manpage binary: $NGX_OBJS${ngx_dirsep}nginx$ngx_binext $NGX_OBJS${ngx_dirsep}nginx$ngx_binext: $ngx_deps$ngx_spacer - \$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_link + \$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_binext$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_link $ngx_rcc $ngx_long_end From xeioex at nginx.com Thu Jan 31 12:46:27 2019 From: xeioex at nginx.com (Dmitry Volyntsev) Date: Thu, 31 Jan 2019 12:46:27 +0000 Subject: [njs] Simplified parser tree building. Message-ID: details: https://hg.nginx.org/njs/rev/9f2779de4cdd branches: changeset: 748:9f2779de4cdd user: hongzhidao date: Tue Jan 29 16:30:13 2019 +0800 description: Simplified parser tree building. diffstat: njs/njs_parser.c | 146 +++++++++++++------------------------------ njs/njs_parser.h | 20 ++++- njs/njs_parser_expression.c | 62 ++++------------- 3 files changed, 77 insertions(+), 151 deletions(-) diffs (896 lines): diff -r ac9b1c01a9b0 -r 9f2779de4cdd njs/njs_parser.c --- a/njs/njs_parser.c Wed Jan 30 18:50:33 2019 +0300 +++ b/njs/njs_parser.c Tue Jan 29 16:30:13 2019 +0800 @@ -134,14 +134,13 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p if (node == NULL) { /* Empty string, just semicolons or variables declarations. */ - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, 0); if (nxt_slow_path(node == NULL)) { return NXT_ERROR; } } node->token = NJS_TOKEN_END; - node->scope = parser->scope; parser->scope->node = node; @@ -263,12 +262,11 @@ njs_parser_statement_chain(njs_vm_t *vm, if (parser->node != NULL) { /* The statement is not empty block or just semicolon. */ - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_STATEMENT; node->left = last; node->right = parser->node; parser->node = node; @@ -418,12 +416,11 @@ njs_parser_block_statement(njs_vm_t *vm, if (parser->node != NULL) { /* The statement is not empty block or just semicolon. */ - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_BLOCK); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_BLOCK; node->left = parser->node; node->right = NULL; parser->node = node; @@ -495,12 +492,11 @@ njs_parser_function_declaration(njs_vm_t njs_function_t *function; njs_parser_node_t *node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_FUNCTION; node->token_line = parser->lexer->token_line; token = njs_parser_token(parser); @@ -560,14 +556,12 @@ njs_parser_function_expression(njs_vm_t njs_parser_node_t *node; njs_function_lambda_t *lambda; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION_EXPRESSION); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_FUNCTION_EXPRESSION; node->token_line = parser->lexer->token_line; - node->scope = parser->scope; parser->node = node; token = njs_parser_token(parser); @@ -745,26 +739,22 @@ njs_parser_function_lambda(njs_vm_t *vm, * There is no function body or the last function body * body statement is not "return" statement. */ - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_STATEMENT; node->left = parser->node; - parser->node = node; - - node->right = njs_parser_node_alloc(vm); + node->right = njs_parser_node_new(vm, parser, NJS_TOKEN_RETURN); if (nxt_slow_path(node->right == NULL)) { return NJS_TOKEN_ERROR; } - node->right->token = NJS_TOKEN_RETURN; + parser->node = node; } parent->right = parser->node; - parser->node->scope = parser->scope; parser->scope->node = parser->node; parser->node = parent; @@ -793,12 +783,11 @@ njs_parser_return_statement(njs_vm_t *vm } } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_RETURN); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_RETURN; parser->node = node; token = njs_lexer_token(parser->lexer); @@ -866,13 +855,11 @@ njs_parser_var_statement(njs_vm_t *vm, n return NJS_TOKEN_ERROR; } - name = njs_parser_node_alloc(vm); + name = njs_parser_node_new(vm, parser, NJS_TOKEN_NAME); if (nxt_slow_path(name == NULL)) { return NJS_TOKEN_ERROR; } - name->token = NJS_TOKEN_NAME; - ret = njs_parser_variable_reference(vm, parser, name, NJS_DECLARATION); if (nxt_slow_path(ret != NXT_OK)) { return NJS_TOKEN_ERROR; @@ -900,22 +887,20 @@ njs_parser_var_statement(njs_vm_t *vm, n expr = parser->node; } - assign = njs_parser_node_alloc(vm); + assign = njs_parser_node_new(vm, parser, NJS_TOKEN_VAR); if (nxt_slow_path(assign == NULL)) { return NJS_TOKEN_ERROR; } - assign->token = NJS_TOKEN_VAR; assign->u.operation = njs_vmcode_move; assign->left = name; assign->right = expr; - stmt = njs_parser_node_alloc(vm); + stmt = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(stmt == NULL)) { return NJS_TOKEN_ERROR; } - stmt->token = NJS_TOKEN_STATEMENT; stmt->left = left; stmt->right = assign; parser->node = stmt; @@ -960,23 +945,21 @@ njs_parser_if_statement(njs_vm_t *vm, nj return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_BRANCHING); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_BRANCHING; node->left = stmt; node->right = parser->node; parser->node = node; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_IF); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_IF; node->left = cond; node->right = parser->node; parser->node = node; @@ -1000,13 +983,11 @@ njs_parser_switch_statement(njs_vm_t *vm return token; } - swtch = njs_parser_node_alloc(vm); + swtch = njs_parser_node_new(vm, parser, NJS_TOKEN_SWITCH); if (nxt_slow_path(swtch == NULL)) { return NJS_TOKEN_ERROR; } - swtch->token = NJS_TOKEN_SWITCH; - swtch->scope = parser->scope; swtch->left = parser->node; last = &swtch->right; @@ -1020,7 +1001,7 @@ njs_parser_switch_statement(njs_vm_t *vm if (token == NJS_TOKEN_CASE || token == NJS_TOKEN_DEFAULT) { do { - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, 0); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } @@ -1038,7 +1019,7 @@ njs_parser_switch_statement(njs_vm_t *vm node->left = parser->node; - branch = njs_parser_node_alloc(vm); + branch = njs_parser_node_new(vm, parser, 0); if (nxt_slow_path(branch == NULL)) { return NJS_TOKEN_ERROR; } @@ -1117,12 +1098,11 @@ njs_parser_while_statement(njs_vm_t *vm, return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_WHILE); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_WHILE; node->left = parser->node; node->right = cond; parser->node = node; @@ -1158,12 +1138,11 @@ njs_parser_do_while_statement(njs_vm_t * return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_DO); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_DO; node->left = stmt; node->right = parser->node; parser->node = node; @@ -1265,22 +1244,21 @@ njs_parser_for_statement(njs_vm_t *vm, n return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_FOR); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - cond = njs_parser_node_alloc(vm); + cond = njs_parser_node_new(vm, parser, 0); if (nxt_slow_path(cond == NULL)) { return NJS_TOKEN_ERROR; } - body = njs_parser_node_alloc(vm); + body = njs_parser_node_new(vm, parser, 0); if (nxt_slow_path(body == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_FOR; node->left = init; node->right = cond; @@ -1328,13 +1306,11 @@ njs_parser_for_var_statement(njs_vm_t *v return NJS_TOKEN_ERROR; } - name = njs_parser_node_alloc(vm); + name = njs_parser_node_new(vm, parser, NJS_TOKEN_NAME); if (nxt_slow_path(name == NULL)) { return NJS_TOKEN_ERROR; } - name->token = NJS_TOKEN_NAME; - ret = njs_parser_variable_reference(vm, parser, name, NJS_DECLARATION); if (nxt_slow_path(ret != NXT_OK)) { return NJS_TOKEN_ERROR; @@ -1366,22 +1342,20 @@ njs_parser_for_var_statement(njs_vm_t *v expr = parser->node; } - assign = njs_parser_node_alloc(vm); + assign = njs_parser_node_new(vm, parser, NJS_TOKEN_VAR); if (nxt_slow_path(assign == NULL)) { return NJS_TOKEN_ERROR; } - assign->token = NJS_TOKEN_VAR; assign->u.operation = njs_vmcode_move; assign->left = name; assign->right = expr; - stmt = njs_parser_node_alloc(vm); + stmt = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(stmt == NULL)) { return NJS_TOKEN_ERROR; } - stmt->token = NJS_TOKEN_STATEMENT; stmt->left = left; stmt->right = assign; parser->node = stmt; @@ -1411,12 +1385,11 @@ njs_parser_for_var_in_statement(njs_vm_t return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_IN); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_IN; node->left = name; node->right = parser->node; @@ -1430,12 +1403,11 @@ njs_parser_for_var_in_statement(njs_vm_t return token; } - foreach = njs_parser_node_alloc(vm); + foreach = njs_parser_node_new(vm, parser, NJS_TOKEN_FOR_IN); if (nxt_slow_path(foreach == NULL)) { return NJS_TOKEN_ERROR; } - foreach->token = NJS_TOKEN_FOR_IN; foreach->left = node; foreach->right = parser->node; @@ -1460,12 +1432,11 @@ njs_parser_for_in_statement(njs_vm_t *vm return NJS_TOKEN_ILLEGAL; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_FOR_IN); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_FOR_IN; node->left = parser->node; token = njs_parser_match(vm, parser, token, NJS_TOKEN_CLOSE_PARENTHESIS); @@ -1491,12 +1462,11 @@ njs_parser_continue_statement(njs_vm_t * njs_token_t token; njs_parser_node_t *node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_CONTINUE); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_CONTINUE; node->token_line = parser->lexer->token_line; parser->node = node; @@ -1525,12 +1495,11 @@ njs_parser_break_statement(njs_vm_t *vm, njs_token_t token; njs_parser_node_t *node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_BREAK); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_BREAK; node->token_line = parser->lexer->token_line; parser->node = node; @@ -1566,13 +1535,11 @@ njs_parser_try_statement(njs_vm_t *vm, n return token; } - try = njs_parser_node_alloc(vm); + try = njs_parser_node_new(vm, parser, NJS_TOKEN_TRY); if (nxt_slow_path(try == NULL)) { return NJS_TOKEN_ERROR; } - try->token = NJS_TOKEN_TRY; - try->scope = parser->scope; try->left = parser->node; if (token == NJS_TOKEN_CATCH) { @@ -1590,12 +1557,11 @@ njs_parser_try_statement(njs_vm_t *vm, n return NJS_TOKEN_ILLEGAL; } - catch = njs_parser_node_alloc(vm); + catch = njs_parser_node_new(vm, parser, NJS_TOKEN_CATCH); if (nxt_slow_path(catch == NULL)) { return NJS_TOKEN_ERROR; } - catch->token = NJS_TOKEN_CATCH; try->right = catch; /* @@ -1612,13 +1578,11 @@ njs_parser_try_statement(njs_vm_t *vm, n return NJS_TOKEN_ERROR; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_NAME); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_NAME; - ret = njs_parser_variable_reference(vm, parser, node, NJS_DECLARATION); if (nxt_slow_path(ret != NXT_OK)) { return NJS_TOKEN_ERROR; @@ -1652,12 +1616,11 @@ njs_parser_try_statement(njs_vm_t *vm, n return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_FINALLY); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_FINALLY; node->right = parser->node; if (try->right != NULL) { @@ -1714,13 +1677,11 @@ njs_parser_throw_statement(njs_vm_t *vm, njs_token_t token; njs_parser_node_t *node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_THROW); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_THROW; - token = njs_lexer_token(parser->lexer); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { return token; @@ -1831,14 +1792,11 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa return njs_parser_function_expression(vm, parser); } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; - node->scope = parser->scope; - switch (token) { case NJS_TOKEN_NAME: @@ -1862,7 +1820,6 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa case NJS_TOKEN_OPEN_BRACE: node->token = NJS_TOKEN_OBJECT; - node->scope = parser->scope; nxt_thread_log_debug("JS: OBJECT"); @@ -1880,7 +1837,6 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa case NJS_TOKEN_OPEN_BRACKET: node->token = NJS_TOKEN_ARRAY; - node->scope = parser->scope; nxt_thread_log_debug("JS: ARRAY"); @@ -1905,7 +1861,6 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa nxt_thread_log_debug("REGEX: '%V'", &parser->lexer->text); node->token = NJS_TOKEN_REGEXP; - node->scope = parser->scope; break; @@ -2008,8 +1963,6 @@ njs_parser_terminal(njs_vm_t *vm, njs_pa return NJS_TOKEN_ILLEGAL; } - node->token = NJS_TOKEN_ARGUMENTS; - break; case NJS_TOKEN_OBJECT_CONSTRUCTOR: @@ -2219,20 +2172,18 @@ njs_parser_object(njs_vm_t *vm, njs_pars break; } - object = njs_parser_node_alloc(vm); + object = njs_parser_node_new(vm, parser, NJS_TOKEN_OBJECT_VALUE); if (nxt_slow_path(object == NULL)) { return NJS_TOKEN_ERROR; } - object->token = NJS_TOKEN_OBJECT_VALUE; object->u.object = obj; - propref = njs_parser_node_alloc(vm); + propref = njs_parser_node_new(vm, parser, NJS_TOKEN_PROPERTY); if (nxt_slow_path(propref == NULL)) { return NJS_TOKEN_ERROR; } - propref->token = NJS_TOKEN_PROPERTY; propref->left = object; propref->right = parser->node; @@ -2250,22 +2201,20 @@ njs_parser_object(njs_vm_t *vm, njs_pars return token; } - assign = njs_parser_node_alloc(vm); + assign = njs_parser_node_new(vm, parser, NJS_TOKEN_ASSIGNMENT); if (nxt_slow_path(assign == NULL)) { return NJS_TOKEN_ERROR; } - assign->token = NJS_TOKEN_ASSIGNMENT; assign->u.operation = njs_vmcode_move; assign->left = propref; assign->right = parser->node; - stmt = njs_parser_node_alloc(vm); + stmt = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(stmt == NULL)) { return NJS_TOKEN_ERROR; } - stmt->token = NJS_TOKEN_STATEMENT; stmt->left = left; stmt->right = assign; @@ -2310,31 +2259,28 @@ njs_parser_array(njs_vm_t *vm, njs_parse continue; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_NUMBER); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_NUMBER; node->u.value.data.u.number = index; node->u.value.type = NJS_NUMBER; node->u.value.data.truth = (index != 0); index++; - object = njs_parser_node_alloc(vm); + object = njs_parser_node_new(vm, parser, NJS_TOKEN_OBJECT_VALUE); if (nxt_slow_path(object == NULL)) { return NJS_TOKEN_ERROR; } - object->token = NJS_TOKEN_OBJECT_VALUE; object->u.object = obj; - propref = njs_parser_node_alloc(vm); + propref = njs_parser_node_new(vm, parser, NJS_TOKEN_PROPERTY); if (nxt_slow_path(propref == NULL)) { return NJS_TOKEN_ERROR; } - propref->token = NJS_TOKEN_PROPERTY; propref->left = object; propref->right = node; @@ -2343,22 +2289,20 @@ njs_parser_array(njs_vm_t *vm, njs_parse return token; } - assign = njs_parser_node_alloc(vm); + assign = njs_parser_node_new(vm, parser, NJS_TOKEN_ASSIGNMENT); if (nxt_slow_path(assign == NULL)) { return NJS_TOKEN_ERROR; } - assign->token = NJS_TOKEN_ASSIGNMENT; assign->u.operation = njs_vmcode_move; assign->left = propref; assign->right = parser->node; - stmt = njs_parser_node_alloc(vm); + stmt = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT); if (nxt_slow_path(stmt == NULL)) { return NJS_TOKEN_ERROR; } - stmt->token = NJS_TOKEN_STATEMENT; stmt->left = left; stmt->right = assign; diff -r ac9b1c01a9b0 -r 9f2779de4cdd njs/njs_parser.h --- a/njs/njs_parser.h Wed Jan 30 18:50:33 2019 +0300 +++ b/njs/njs_parser.h Tue Jan 29 16:30:13 2019 +0800 @@ -283,10 +283,6 @@ struct njs_parser_node_s { }; -#define njs_parser_node_alloc(vm) \ - nxt_mp_zalloc((vm)->mem_pool, sizeof(njs_parser_node_t)) - - struct njs_parser_s { njs_lexer_t *lexer; njs_parser_node_t *node; @@ -337,6 +333,22 @@ void njs_parser_ref_error(njs_vm_t *vm, ...); +nxt_inline njs_parser_node_t * +njs_parser_node_new(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token) +{ + njs_parser_node_t *node; + + node = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_parser_node_t)); + + if (nxt_fast_path(node != NULL)) { + node->token = token; + node->scope = parser->scope; + } + + return node; +} + + extern const nxt_lvlhsh_proto_t njs_keyword_hash_proto; diff -r ac9b1c01a9b0 -r 9f2779de4cdd njs/njs_parser_expression.c --- a/njs/njs_parser_expression.c Wed Jan 30 18:50:33 2019 +0300 +++ b/njs/njs_parser_expression.c Tue Jan 29 16:30:13 2019 +0800 @@ -235,14 +235,12 @@ njs_parser_var_expression(njs_vm_t *vm, return NJS_TOKEN_ILLEGAL; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = operation; - node->scope = parser->scope; node->left = parser->node; token = njs_parser_token(parser); @@ -370,14 +368,12 @@ njs_parser_assignment_expression(njs_vm_ return NJS_TOKEN_ILLEGAL; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = operation; - node->scope = parser->scope; node->left = parser->node; token = njs_parser_token(parser); @@ -419,22 +415,19 @@ njs_parser_conditional_expression(njs_vm return token; } - cond = njs_parser_node_alloc(vm); + cond = njs_parser_node_new(vm, parser, NJS_TOKEN_CONDITIONAL); if (nxt_slow_path(cond == NULL)) { return NJS_TOKEN_ERROR; } - cond->token = NJS_TOKEN_CONDITIONAL; - cond->scope = parser->scope; cond->left = parser->node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_BRANCHING); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } cond->right = node; - node->token = NJS_TOKEN_BRANCHING; token = njs_parser_assignment_expression(vm, parser, token); if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { @@ -497,14 +490,12 @@ njs_parser_binary_expression(njs_vm_t *v found: - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = op->operation; - node->scope = parser->scope; node->left = parser->node; node->left->dest = node; @@ -538,14 +529,12 @@ njs_parser_exponential_expression(njs_vm if (token == NJS_TOKEN_EXPONENTIATION) { - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = njs_vmcode_exponentiation; - node->scope = parser->scope; node->left = parser->node; node->left->dest = node; @@ -673,14 +662,12 @@ njs_parser_unary_expression(njs_vm_t *vm node->u.reference.type = NJS_TYPEOF; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = operation; - node->scope = parser->scope; node->left = parser->node; node->left->dest = node; parser->node = node; @@ -727,14 +714,12 @@ njs_parser_inc_dec_expression(njs_vm_t * return NJS_TOKEN_ILLEGAL; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = operation; - node->scope = parser->scope; node->left = parser->node; parser->node = node; @@ -783,14 +768,12 @@ njs_parser_post_inc_dec_expression(njs_v return NJS_TOKEN_ILLEGAL; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, token); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = token; node->u.operation = operation; - node->scope = parser->scope; node->left = parser->node; parser->node = node; @@ -837,13 +820,11 @@ njs_parser_call_expression(njs_vm_t *vm, break; case NJS_TOKEN_PROPERTY: - func = njs_parser_node_alloc(vm); + func = njs_parser_node_new(vm, parser, NJS_TOKEN_METHOD_CALL); if (nxt_slow_path(func == NULL)) { return NJS_TOKEN_ERROR; } - func->token = NJS_TOKEN_METHOD_CALL; - func->scope = parser->scope; func->left = node; break; @@ -863,13 +844,11 @@ njs_parser_call_expression(njs_vm_t *vm, * NJS_TOKEN_REGEXP_CONSTRUCTOR, * NJS_TOKEN_EVAL. */ - func = njs_parser_node_alloc(vm); + func = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION_CALL); if (nxt_slow_path(func == NULL)) { return NJS_TOKEN_ERROR; } - func->token = NJS_TOKEN_FUNCTION_CALL; - func->scope = parser->scope; func->left = node; break; @@ -930,13 +909,11 @@ njs_parser_new_expression(njs_vm_t *vm, break; case NJS_TOKEN_PROPERTY: - func = njs_parser_node_alloc(vm); + func = njs_parser_node_new(vm, parser, NJS_TOKEN_METHOD_CALL); if (nxt_slow_path(func == NULL)) { return NJS_TOKEN_ERROR; } - func->token = NJS_TOKEN_METHOD_CALL; - func->scope = parser->scope; func->left = node; break; @@ -956,13 +933,11 @@ njs_parser_new_expression(njs_vm_t *vm, * NJS_TOKEN_REGEXP_CONSTRUCTOR, * NJS_TOKEN_EVAL. */ - func = njs_parser_node_alloc(vm); + func = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION_CALL); if (nxt_slow_path(func == NULL)) { return NJS_TOKEN_ERROR; } - func->token = NJS_TOKEN_FUNCTION_CALL; - func->scope = parser->scope; func->left = node; break; @@ -999,14 +974,12 @@ njs_parser_property_expression(njs_vm_t return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_PROPERTY); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_PROPERTY; node->u.operation = njs_vmcode_property_get; - node->scope = parser->scope; node->left = parser->node; if (token == NJS_TOKEN_DOT) { @@ -1047,13 +1020,11 @@ njs_parser_property_name(njs_vm_t *vm, n nxt_int_t ret; njs_parser_node_t *node; - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_STRING); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_STRING; - ret = njs_parser_string_create(vm, &node->u.value); if (nxt_slow_path(ret != NXT_OK)) { return NJS_TOKEN_ERROR; @@ -1107,12 +1078,11 @@ njs_parser_arguments(njs_vm_t *vm, njs_p return token; } - node = njs_parser_node_alloc(vm); + node = njs_parser_node_new(vm, parser, NJS_TOKEN_ARGUMENT); if (nxt_slow_path(node == NULL)) { return NJS_TOKEN_ERROR; } - node->token = NJS_TOKEN_ARGUMENT; node->index = index; index += sizeof(njs_value_t); From ru at nginx.com Thu Jan 31 15:33:42 2019 From: ru at nginx.com (Ruslan Ermilov) Date: Thu, 31 Jan 2019 15:33:42 +0000 Subject: [nginx] Use %s for errors returned from configuration parsing handlers. Message-ID: details: https://hg.nginx.org/nginx/rev/d864ee67b5ae branches: changeset: 7451:d864ee67b5ae user: Ruslan Ermilov date: Tue Dec 25 15:26:58 2018 +0300 description: Use %s for errors returned from configuration parsing handlers. diffstat: src/core/ngx_conf_file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diffs (12 lines): diff -r 2d9ab7717e23 -r d864ee67b5ae src/core/ngx_conf_file.c --- a/src/core/ngx_conf_file.c Wed Jan 30 19:28:27 2019 +0300 +++ b/src/core/ngx_conf_file.c Tue Dec 25 15:26:58 2018 +0300 @@ -310,7 +310,7 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t goto failed; } - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, rv); + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", rv); goto failed; } From arut at nginx.com Thu Jan 31 15:56:58 2019 From: arut at nginx.com (Roman Arutyunyan) Date: Thu, 31 Jan 2019 15:56:58 +0000 Subject: [nginx] Modules compatibility: down flag in ngx_peer_connection_t. Message-ID: details: https://hg.nginx.org/nginx/rev/570d8c626eea branches: changeset: 7452:570d8c626eea user: Roman Arutyunyan date: Thu Jan 31 17:25:03 2019 +0300 description: Modules compatibility: down flag in ngx_peer_connection_t. diffstat: src/event/ngx_event_connect.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diffs (11 lines): diff -r d864ee67b5ae -r 570d8c626eea src/event/ngx_event_connect.h --- a/src/event/ngx_event_connect.h Tue Dec 25 15:26:58 2018 +0300 +++ b/src/event/ngx_event_connect.h Thu Jan 31 17:25:03 2019 +0300 @@ -63,6 +63,7 @@ struct ngx_peer_connection_s { unsigned cached:1; unsigned transparent:1; unsigned so_keepalive:1; + unsigned down:1; /* ngx_connection_log_error_e */ unsigned log_error:2; From mdounin at mdounin.ru Thu Jan 31 18:26:38 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 31 Jan 2019 18:26:38 +0000 Subject: [nginx] SSL: explicitly zero out session ticket keys. Message-ID: details: https://hg.nginx.org/nginx/rev/873150addfeb branches: changeset: 7453:873150addfeb user: Ruslan Ermilov date: Thu Jan 31 19:28:07 2019 +0300 description: SSL: explicitly zero out session ticket keys. diffstat: src/event/ngx_event_openssl.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diffs (69 lines): diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -68,6 +68,7 @@ static void ngx_ssl_session_rbtree_inser static int ngx_ssl_session_ticket_key_callback(ngx_ssl_conn_t *ssl_conn, unsigned char *name, unsigned char *iv, EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc); +static void ngx_ssl_session_ticket_keys_cleanup(void *data); #endif #ifndef X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT @@ -3455,6 +3456,7 @@ ngx_ssl_session_ticket_keys(ngx_conf_t * ngx_uint_t i; ngx_array_t *keys; ngx_file_info_t fi; + ngx_pool_cleanup_t *cln; ngx_ssl_session_ticket_key_t *key; if (paths == NULL) { @@ -3467,6 +3469,14 @@ ngx_ssl_session_ticket_keys(ngx_conf_t * return NGX_ERROR; } + cln = ngx_pool_cleanup_add(cf->pool, 0); + if (cln == NULL) { + return NGX_ERROR; + } + + cln->handler = ngx_ssl_session_ticket_keys_cleanup; + cln->data = keys; + path = paths->elts; for (i = 0; i < paths->nelts; i++) { @@ -3538,6 +3548,8 @@ ngx_ssl_session_ticket_keys(ngx_conf_t * ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, ngx_close_file_n " \"%V\" failed", &file.name); } + + ngx_explicit_memzero(&buf, 80); } if (SSL_CTX_set_ex_data(ssl->ctx, ngx_ssl_session_ticket_keys_index, keys) @@ -3568,6 +3580,8 @@ failed: ngx_close_file_n " \"%V\" failed", &file.name); } + ngx_explicit_memzero(&buf, 80); + return NGX_ERROR; } @@ -3696,6 +3710,16 @@ ngx_ssl_session_ticket_key_callback(ngx_ } } + +static void +ngx_ssl_session_ticket_keys_cleanup(void *data) +{ + ngx_array_t *keys = data; + + ngx_explicit_memzero(keys->elts, + keys->nelts * sizeof(ngx_ssl_session_ticket_key_t)); +} + #else ngx_int_t From mdounin at mdounin.ru Thu Jan 31 18:26:40 2019 From: mdounin at mdounin.ru (Maxim Dounin) Date: Thu, 31 Jan 2019 18:26:40 +0000 Subject: [nginx] SSL: separate checks for errors in ngx_ssl_read_password_file(). Message-ID: details: https://hg.nginx.org/nginx/rev/e72c8a8a8b10 branches: changeset: 7454:e72c8a8a8b10 user: Maxim Dounin date: Thu Jan 31 19:36:51 2019 +0300 description: SSL: separate checks for errors in ngx_ssl_read_password_file(). Checking multiple errors at once is a bad practice, as in general it is not guaranteed that an object can be used after the error. In this particular case, checking errors after multiple allocations can result in excessive errors being logged when there is no memory available. diffstat: src/event/ngx_event_openssl.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diffs (20 lines): diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -947,10 +947,13 @@ ngx_ssl_read_password_file(ngx_conf_t *c return NULL; } + passwords = ngx_array_create(cf->temp_pool, 4, sizeof(ngx_str_t)); + if (passwords == NULL) { + return NULL; + } + cln = ngx_pool_cleanup_add(cf->temp_pool, 0); - passwords = ngx_array_create(cf->temp_pool, 4, sizeof(ngx_str_t)); - - if (cln == NULL || passwords == NULL) { + if (cln == NULL) { return NULL; } From teward at thomas-ward.net Thu Jan 31 21:34:58 2019 From: teward at thomas-ward.net (Thomas Ward) Date: Thu, 31 Jan 2019 16:34:58 -0500 Subject: GeoIP dependency on GeoIP Legacy databases? In-Reply-To: <154896928899.7316.14645247001036849529.reportbug@noether.olasd.eu> References: <154896928899.7316.14645247001036849529.reportbug@noether.olasd.eu> Message-ID: <21a2e216-60b4-9dc3-ee72-9c362e766b0d@thomas-ward.net> A bug report originated on Debian [1] about the GeoIP module that's shipped with NGINX's source code. It makes note that the GeoIP database in Legacy format is not available, deprecated in 2018 and discontinued as of 2019.? This means that non-paying customers can't get the database files.? [2] Does this impact the geoip module shipped with NGINX as the Legacy databases are no longer available and discontinued?? If so, does NGINX have a timeline to replace this or provide alternate mechanisms? Thomas [1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=921034 [2]: https://support.maxmind.com/geolite-legacy-discontinuation-notice/ -------------- next part -------------- An HTML attachment was scrubbed... URL: