Skip to content

Fix getRootContext(). #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/proxy-wasm/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ class WasmBase : public std::enable_shared_from_this<WasmBase> {
std::string_view vm_key() const { return vm_key_; }
WasmVm *wasm_vm() const { return wasm_vm_.get(); }
ContextBase *vm_context() const { return vm_context_.get(); }
ContextBase *getRootContext(std::string_view root_id) {
return root_contexts_[std::string(root_id)].get();
}
ContextBase *getRootContext(std::string_view root_id);
ContextBase *getOrCreateRootContext(const std::shared_ptr<PluginBase> &plugin);
ContextBase *getContext(uint32_t id) {
auto it = contexts_.find(id);
Expand Down
8 changes: 8 additions & 0 deletions src/wasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ bool WasmBase::initialize(const std::string &code, bool allow_precompiled) {
return !isFailed();
}

ContextBase *WasmBase::getRootContext(std::string_view root_id) {
auto it = root_contexts_.find(std::string(root_id));
if (it == root_contexts_.end()) {
return nullptr;
}
return it->second.get();
}

ContextBase *WasmBase::getOrCreateRootContext(const std::shared_ptr<PluginBase> &plugin) {
auto root_context = getRootContext(plugin->root_id_);
if (!root_context) {
Expand Down