Skip to content

Commit c5658d3

Browse files
authored
invoke on_context_create_ for all root contexts with a same VM ID (#64)
Signed-off-by: mathetake <takeshi@tetrate.io>
1 parent 6a75b62 commit c5658d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/context.cc

+16-1
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,24 @@ bool ContextBase::onStart(std::shared_ptr<PluginBase> plugin) {
331331
}
332332

333333
bool ContextBase::onConfigure(std::shared_ptr<PluginBase> plugin) {
334-
if (isFailed() || !wasm_->on_configure_) {
334+
if (isFailed()) {
335335
return true;
336336
}
337+
338+
// on_context_create is yet to be executed for all the root contexts except the first one
339+
if (!in_vm_context_created_ && wasm_->on_context_create_) {
340+
DeferAfterCallActions actions(this);
341+
wasm_->on_context_create_(this, id_, 0);
342+
}
343+
344+
// NB: If no on_context_create function is registered the in-VM SDK is responsible for
345+
// managing any required in-VM state.
346+
in_vm_context_created_ = true;
347+
348+
if (!wasm_->on_configure_) {
349+
return true;
350+
}
351+
337352
DeferAfterCallActions actions(this);
338353
plugin_ = plugin;
339354
auto result =

0 commit comments

Comments
 (0)