Skip to content

Commit

Permalink
review: fix getRootContext().
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora committed Oct 26, 2020
1 parent 3373d67 commit 19601ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions include/proxy-wasm/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ class WasmBase : public std::enable_shared_from_this<WasmBase> {
WasmVm *wasm_vm() const { return wasm_vm_.get(); }
ContextBase *vm_context() const { return vm_context_.get(); }
ContextBase *createAndSaveRootContext(const std::shared_ptr<PluginBase> &plugin);
ContextBase *getRootContext(std::string_view plugin_key) {
return root_contexts_[std::string(plugin_key)].get();
}
ContextBase *getRootContext(std::string_view plugin_key);
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 @@ -321,6 +321,14 @@ ContextBase *WasmBase::createAndSaveRootContext(const std::shared_ptr<PluginBase
return root_context;
}

ContextBase *WasmBase::getRootContext(std::string_view plugin_key) {
auto it = root_contexts_.find(std::string(plugin_key));
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->key());
if (!root_context) {
Expand Down

0 comments on commit 19601ee

Please sign in to comment.