Welcome! Log In Create A New Profile

Advanced

[njs] Modules: fixed promise events handling.

Alexander Borisov
November 26, 2020 01:46PM
details: https://hg.nginx.org/njs/rev/fac7e5dc8009
branches:
changeset: 1575:fac7e5dc8009
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Thu Nov 26 21:43:17 2020 +0300
description:
Modules: fixed promise events handling.

Previously, promise chain might not be invoked at all in some cases.
Specifically, this happened in HTTP module if promise chain did not start
with a r.subrequest() invocation.

The fix is to always process all pending promise events after the main module
function.

This closes #359 issue on GitHub.

diffstat:

nginx/ngx_js.c | 6 +-----
src/njs_vm.c | 2 +-
2 files changed, 2 insertions(+), 6 deletions(-)

diffs (28 lines):

diff -r a141a29417dc -r fac7e5dc8009 nginx/ngx_js.c
--- a/nginx/ngx_js.c Thu Nov 26 11:36:03 2020 +0000
+++ b/nginx/ngx_js.c Thu Nov 26 21:43:17 2020 +0300
@@ -79,11 +79,7 @@ ngx_js_call(njs_vm_t *vm, ngx_str_t *fna
return NGX_ERROR;
}

- if (njs_vm_pending(vm)) {
- return NGX_AGAIN;
- }
-
- return NGX_OK;
+ return njs_vm_run(vm);
}


diff -r a141a29417dc -r fac7e5dc8009 src/njs_vm.c
--- a/src/njs_vm.c Thu Nov 26 11:36:03 2020 +0000
+++ b/src/njs_vm.c Thu Nov 26 21:43:17 2020 +0300
@@ -578,7 +578,7 @@ njs_vm_handle_events(njs_vm_t *vm)

} while (!njs_queue_is_empty(promise_events));

- return njs_posted_events(vm) ? NJS_AGAIN : NJS_OK;
+ return njs_vm_pending(vm) ? NJS_AGAIN : NJS_OK;
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Modules: fixed promise events handling.

Alexander Borisov 112 November 26, 2020 01:46PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 49
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready