Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.

Delay sendLocalReply till after the call to prevent rentrant calls.#432

Merged
PiotrSikora merged 2 commits intoenvoyproxy:masterfrom
jplevyak:send-local-reply
Feb 26, 2020
Merged

Delay sendLocalReply till after the call to prevent rentrant calls.#432
PiotrSikora merged 2 commits intoenvoyproxy:masterfrom
jplevyak:send-local-reply

Conversation

@jplevyak
Copy link
Copy Markdown
Contributor

Signed-off-by: John Plevyak jplevyak@gmail.com

Signed-off-by: John Plevyak <jplevyak@gmail.com>
@jplevyak jplevyak removed the request for review from lizan February 25, 2020 23:06
DeferAfterCallActions actions(this);
if (!wasm_->on_configure_) {
return true;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those could be moved to after the check if the callback actually exist, right? Otherwise, we're wasting cycles.

(Same in most other places)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but it was more obviously correct, but Done.

return true;
}

void addAfterVmCallAction(std::function<void()> f) { after_vm_call_actions_.push_back(f); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're both adding at and removing from the back of the queue, which makes this LIFO. I think it should be FIFO instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

while (!after_vm_call_actions_.empty()) {
after_vm_call_actions_.back()();
after_vm_call_actions_.pop_back();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets recursive and the deferred functions are called indefinitely before this code has a chance to remove them from the queue. I'm not sure why, to be honest.

One way to work around this is to make the call only after removing the function from the queue, i.e.

auto f = after_vm_call_actions_.back();
after_vm_call_actions_.pop_back();
f();

but that probably only works if the is only one deferred call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

It should be fine in the loop so long as the function to be called is removed first as you suggest.

Signed-off-by: John Plevyak <jplevyak@gmail.com>
Copy link
Copy Markdown
Contributor

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@PiotrSikora PiotrSikora merged commit 7d648e4 into envoyproxy:master Feb 26, 2020
@jplevyak jplevyak deleted the send-local-reply branch February 26, 2020 01:39
PiotrSikora added a commit to PiotrSikora/envoy-wasm that referenced this pull request Aug 2, 2020
This was previously fixed in envoyproxy#432, but got somehow lost.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
PiotrSikora added a commit to PiotrSikora/envoy-wasm that referenced this pull request Aug 2, 2020
This was previously fixed in envoyproxy#432, but got somehow lost.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
PiotrSikora added a commit to PiotrSikora/envoy that referenced this pull request Aug 2, 2020
This was previously fixed in envoyproxy/envoy-wasm#432, but got somehow lost.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
istio-testing pushed a commit to istio/envoy that referenced this pull request Aug 4, 2020
* Defer sendLocalReply() to prevent reentrant calls.

This was previously fixed in envoyproxy/envoy-wasm#432, but got somehow lost.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

* review: add John's comment.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants