[njs] Fixed njs_vm_handle_events().
Alexander Borisov
alexander.borisov at nginx.com
Thu Dec 26 12:32:29 UTC 2019
details: https://hg.nginx.org/njs/rev/025ce39e20b1
branches:
changeset: 1292:025ce39e20b1
user: Alexander Borisov <alexander.borisov at 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;
}
More information about the nginx-devel
mailing list