]> git.kaiwu.me - njs.git/commitdiff
Modules: fixed promise events handling.
authorAlexander Borisov <alexander.borisov@nginx.com>
Thu, 26 Nov 2020 18:43:17 +0000 (21:43 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Thu, 26 Nov 2020 18:43:17 +0000 (21:43 +0300)
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.

nginx/ngx_js.c
src/njs_vm.c

index 976f3b766894a5f41b7b70b634fb1473693d3697..56b2bdd48053a32b97762e819765319f0860bca3 100644 (file)
@@ -79,11 +79,7 @@ ngx_js_call(njs_vm_t *vm, ngx_str_t *fname, njs_opaque_value_t *value,
         return NGX_ERROR;
     }
 
-    if (njs_vm_pending(vm)) {
-        return NGX_AGAIN;
-    }
-
-    return NGX_OK;
+    return njs_vm_run(vm);
 }
 
 
index 565872773180b0e99ad8b5e7cdc9df94ba3f4adb..2aa8461b9dfa672361db21b6e3b0067a927d9e1f 100644 (file)
@@ -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;
 }