Skip to content

Commit

Permalink
invoke on_context_create_ for all root contexts with a same VM ID (#64)
Browse files Browse the repository at this point in the history
Signed-off-by: mathetake <takeshi@tetrate.io>
  • Loading branch information
mathetake authored Oct 16, 2020
1 parent 6a75b62 commit c5658d3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,24 @@ bool ContextBase::onStart(std::shared_ptr<PluginBase> plugin) {
}

bool ContextBase::onConfigure(std::shared_ptr<PluginBase> plugin) {
if (isFailed() || !wasm_->on_configure_) {
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);
}

// 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;
}

DeferAfterCallActions actions(this);
plugin_ = plugin;
auto result =
Expand Down

0 comments on commit c5658d3

Please sign in to comment.