From 74c1d83d3f2275fd4baceb47347374976486ac65 Mon Sep 17 00:00:00 2001 From: mathetake Date: Mon, 5 Oct 2020 16:46:17 +0900 Subject: [PATCH 1/2] invoke on_context_create_ for multiple root contexts Signed-off-by: mathetake --- src/context.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/context.cc b/src/context.cc index 4b31f607..fc686a2a 100644 --- a/src/context.cc +++ b/src/context.cc @@ -331,9 +331,15 @@ bool ContextBase::onStart(std::shared_ptr plugin) { } bool ContextBase::onConfigure(std::shared_ptr plugin) { + if (!in_vm_context_created_ && wasm_->on_context_create_) { + wasm_->on_context_create_(this, id_, 0); + in_vm_context_created_ = true; + } + if (isFailed() || !wasm_->on_configure_) { return true; } + DeferAfterCallActions actions(this); plugin_ = plugin; auto result = From bada27abf9f4b7be55e65a5140f421339a4b7ef4 Mon Sep 17 00:00:00 2001 From: mathetake Date: Fri, 16 Oct 2020 14:53:58 +0900 Subject: [PATCH 2/2] review: check vm failure first Signed-off-by: mathetake --- src/context.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/context.cc b/src/context.cc index fc686a2a..c1929e14 100644 --- a/src/context.cc +++ b/src/context.cc @@ -331,12 +331,21 @@ bool ContextBase::onStart(std::shared_ptr plugin) { } bool ContextBase::onConfigure(std::shared_ptr plugin) { + if (isFailed()) { + return true; + } + + // on_context_create is yet to be executed for all the root contexts except the first one if (!in_vm_context_created_ && wasm_->on_context_create_) { + DeferAfterCallActions actions(this); wasm_->on_context_create_(this, id_, 0); - in_vm_context_created_ = true; } - if (isFailed() || !wasm_->on_configure_) { + // NB: If no on_context_create function is registered the in-VM SDK is responsible for + // managing any required in-VM state. + in_vm_context_created_ = true; + + if (!wasm_->on_configure_) { return true; }