Welcome! Log In Create A New Profile

Advanced

[njs] Fixed njs_vm_handle_events().

Alexander Borisov
December 26, 2019 07:34AM
details: https://hg.nginx.org/njs/rev/025ce39e20b1
branches:
changeset: 1292:025ce39e20b1
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Thu Dec 26 15:31:54 2019 +0300
description:
Fixed njs_vm_handle_events().

Fixed typo introduced in 61bf7a31e685. Event loop is expected to process two
queues: posted events and promise events according to the spec. The "do while"
loop was introduced to handle possible promise events which may appear as
a result of posted events processing. The loop termination condition should
check for emptyness of promise events queue, because posted events can only be
created outside the loop (externally).

diffstat:

src/njs_vm.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)

diffs (52 lines):

diff -r 5fbc49bc5a7e -r 025ce39e20b1 src/njs_vm.c
--- a/src/njs_vm.c Thu Dec 26 14:53:52 2019 +0300
+++ b/src/njs_vm.c Thu Dec 26 15:31:54 2019 +0300
@@ -493,16 +493,17 @@ njs_vm_handle_events(njs_vm_t *vm)
{
njs_int_t ret;
njs_event_t *ev;
- njs_queue_t *events;
+ njs_queue_t *promise_events, *posted_events;
njs_queue_link_t *link;

+ promise_events = &vm->promise_events;
+ posted_events = &vm->posted_events;
+
do {
- events = &vm->promise_events;
+ for ( ;; ) {
+ link = njs_queue_first(promise_events);

- for ( ;; ) {
- link = njs_queue_first(events);
-
- if (link == njs_queue_tail(events)) {
+ if (link == njs_queue_tail(promise_events)) {
break;
}

@@ -516,12 +517,10 @@ njs_vm_handle_events(njs_vm_t *vm)
}
}

- events = &vm->posted_events;
+ for ( ;; ) {
+ link = njs_queue_first(posted_events);

- for ( ;; ) {
- link = njs_queue_first(events);
-
- if (link == njs_queue_tail(events)) {
+ if (link == njs_queue_tail(posted_events)) {
break;
}

@@ -542,7 +541,7 @@ njs_vm_handle_events(njs_vm_t *vm)
}
}

- } while (!njs_queue_is_empty(events));
+ } while (!njs_queue_is_empty(promise_events));

return njs_posted_events(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] Fixed njs_vm_handle_events().

Alexander Borisov 110 December 26, 2019 07:34AM



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

Online Users

Guests: 74
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