Skip to content

Commit

Permalink
Clear stop_iteration_ flag non-status-returning callbacks.
Browse files Browse the repository at this point in the history
Signed-off-by: mathetake <takeshi@tetrate.io>
  • Loading branch information
mathetake committed Nov 10, 2020
1 parent 376ffaf commit ea7268f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,15 @@ FilterStatus ContextBase::onUpstreamData(uint32_t data_length, bool end_of_strea

void ContextBase::onDownstreamConnectionClose(CloseType close_type) {
if (!isFailed() && wasm_->on_downstream_connection_close_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_downstream_connection_close_(this, id_, static_cast<uint32_t>(close_type));
}
}

void ContextBase::onUpstreamConnectionClose(CloseType close_type) {
if (!isFailed() && wasm_->on_upstream_connection_close_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_upstream_connection_close_(this, id_, static_cast<uint32_t>(close_type));
}
Expand Down Expand Up @@ -549,12 +551,14 @@ void ContextBase::onHttpCallResponse(uint32_t token, uint32_t headers, uint32_t
if (isFailed() || !wasm_->on_http_call_response_) {
return;
}
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_http_call_response_(this, id_, token, headers, body_size, trailers);
}

void ContextBase::onQueueReady(uint32_t token) {
if (!isFailed() && wasm_->on_queue_ready_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_queue_ready_(this, id_, token);
}
Expand All @@ -564,6 +568,7 @@ void ContextBase::onGrpcReceiveInitialMetadata(uint32_t token, uint32_t elements
if (isFailed() || !wasm_->on_grpc_receive_initial_metadata_) {
return;
}
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_grpc_receive_initial_metadata_(this, id_, token, elements);
}
Expand All @@ -572,6 +577,7 @@ void ContextBase::onGrpcReceiveTrailingMetadata(uint32_t token, uint32_t trailer
if (isFailed() || !wasm_->on_grpc_receive_trailing_metadata_) {
return;
}
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_grpc_receive_trailing_metadata_(this, id_, token, trailers);
}
Expand All @@ -580,6 +586,7 @@ void ContextBase::onGrpcReceive(uint32_t token, uint32_t response_size) {
if (isFailed() || !wasm_->on_grpc_receive_) {
return;
}
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_grpc_receive_(this, id_, token, response_size);
}
Expand All @@ -588,12 +595,14 @@ void ContextBase::onGrpcClose(uint32_t token, uint32_t status_code) {
if (isFailed() || !wasm_->on_grpc_close_) {
return;
}
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_grpc_close_(this, id_, token, status_code);
}

bool ContextBase::onDone() {
if (!isFailed() && wasm_->on_done_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
return wasm_->on_done_(this, id_).u64_ != 0;
}
Expand All @@ -602,13 +611,15 @@ bool ContextBase::onDone() {

void ContextBase::onLog() {
if (!isFailed() && wasm_->on_log_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_log_(this, id_);
}
}

void ContextBase::onDelete() {
if (in_vm_context_created_ && !isFailed() && wasm_->on_delete_) {
wasm_->addAfterVmCallAction([this]() { this->stop_iteration_ = false; });
DeferAfterCallActions actions(this);
wasm_->on_delete_(this, id_);
}
Expand Down

0 comments on commit ea7268f

Please sign in to comment.