Skip to content

Commit

Permalink
wasm: defer continue processing to avoid reentrant calls.
Browse files Browse the repository at this point in the history
Fixes proxy-wasm/proxy-wasm-rust-sdk#43.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora committed Oct 30, 2020
1 parent 0b450f4 commit 33f6d8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/extensions/common/wasm/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1490,12 +1490,14 @@ WasmResult Context::continueStream(WasmStreamType stream_type) {
switch (stream_type) {
case WasmStreamType::Request:
if (decoder_callbacks_) {
decoder_callbacks_->continueDecoding();
// We are in a reentrant call, so defer.
wasm()->addAfterVmCallAction([this] { decoder_callbacks_->continueDecoding(); });
}
break;
case WasmStreamType::Response:
if (encoder_callbacks_) {
encoder_callbacks_->continueEncoding();
// We are in a reentrant call, so defer.
wasm()->addAfterVmCallAction([this] { encoder_callbacks_->continueEncoding(); });
}
break;
default:
Expand Down

0 comments on commit 33f6d8d

Please sign in to comment.