Skip to content

Pass PluginHandle to stream contexts. #167

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 6 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 10 additions & 8 deletions include/proxy-wasm/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace proxy_wasm {
#include "proxy_wasm_common.h"
#include "proxy_wasm_enums.h"

class PluginHandleBase;
class WasmBase;
class WasmVm;

Expand Down Expand Up @@ -142,8 +143,8 @@ class ContextBase : public RootInterface,
ContextBase(); // Testing.
ContextBase(WasmBase *wasm); // Vm Context.
ContextBase(WasmBase *wasm, std::shared_ptr<PluginBase> plugin); // Root Context.
ContextBase(WasmBase *wasm, uint32_t parent_context_id,
std::shared_ptr<PluginBase> plugin); // Stream context.
ContextBase(WasmBase *wasm, uint32_t parent_context_id, std::shared_ptr<PluginBase> plugin,
std::shared_ptr<PluginHandleBase> plugin_handle); // Stream context.
virtual ~ContextBase();

WasmBase *wasm() const { return wasm_; }
Expand Down Expand Up @@ -394,12 +395,13 @@ class ContextBase : public RootInterface,

WasmBase *wasm_{nullptr};
uint32_t id_{0};
uint32_t parent_context_id_{0}; // 0 for roots and the general context.
ContextBase *parent_context_{nullptr}; // set in all contexts.
std::string root_id_; // set only in root context.
std::string root_log_prefix_; // set only in root context.
std::shared_ptr<PluginBase> plugin_; // set in root and stream contexts.
std::shared_ptr<PluginBase> temp_plugin_; // Remove once ABI v0.1.0 is gone.
uint32_t parent_context_id_{0}; // 0 for roots and the general context.
ContextBase *parent_context_{nullptr}; // set in all contexts.
std::string root_id_; // set only in root context.
std::string root_log_prefix_; // set only in root context.
std::shared_ptr<PluginBase> plugin_; // set in root and stream contexts.
std::shared_ptr<PluginHandleBase> plugin_handle_; // set only in stream context.
std::shared_ptr<PluginBase> temp_plugin_; // Remove once ABI v0.1.0 is gone.
bool in_vm_context_created_ = false;
bool destroyed_ = false;
bool stream_failed_ = false; // Set true after failStream is called in case of VM failure.
Expand Down
5 changes: 3 additions & 2 deletions src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ ContextBase::ContextBase(WasmBase *wasm, std::shared_ptr<PluginBase> plugin)

// NB: wasm can be nullptr if it failed to be created successfully.
ContextBase::ContextBase(WasmBase *wasm, uint32_t parent_context_id,
std::shared_ptr<PluginBase> plugin)
std::shared_ptr<PluginBase> plugin,
std::shared_ptr<PluginHandleBase> plugin_handle)
: wasm_(wasm), id_(wasm ? wasm->allocContextId() : 0), parent_context_id_(parent_context_id),
plugin_(plugin) {
plugin_(plugin), plugin_handle_(plugin_handle) {
if (wasm_) {
wasm_->contexts_[id_] = this;
parent_context_ = wasm_->contexts_[parent_context_id_];
Expand Down