You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be unrelated but it does seems that http_streams shouldn't be mutually borrowed and having 2 inflight http requests creates 2 different httpContext and may produce a scenario where the http_streams is borrowed twice.
If that is the case using interior mutability might save us here.
We'd be able to do:
if let Some(http_stream) = self.http_streams.get(&context_id).borrow_mut() {...}
To do this I guess using Rc<RefCell<dyn HttpContext>> should work but this also implies changing the function defs New[...]Context to return something like RefCell<dyn HttpContext> which is an api breaking change.
Considering I'm not super knowledgeable in Rust I wanted to get an opinion before working on a PR.
Are these observations correct?
Is there a simpler way to do this to avoid breaking the api (I'm thinking some rust way to convert a Box to a RefCell which seems odd)?
If not I'll try to fix this.
The text was updated successfully, but these errors were encountered:
Btw for my own rust education was the workaround correct if this were an issue on this side (switching to interior mutability with Rc<RefCell<>>)?
Unfortunately not. The code was already using RefCell<T> which has runtime borrow-checking. Rc can add reference counting, but it cannot change the behavior of runtime borrow-checking with reentrant calls.
I have very simple function that does:
I'm using a docker image for envoy:
istio/proxyv2:1.5.0
it embeds envoy:73f240a29bece92a8882a36893ccce07b4a54664/1.13.1-dev/Clean/RELEASE/BoringSSL
.When I run this envoy panics with:
panicked at 'already borrowed: BorrowMutError', proxy-wasm-0.1.3/src/dispatcher.rs:326:54
Full Stacktrace:
The service on the other side does get the request and returns a successful status with a body.
Looking at the code:
This might be unrelated but it does seems that
http_streams
shouldn't be mutually borrowed and having 2 inflight http requests creates 2 different httpContext and may produce a scenario where thehttp_streams
is borrowed twice.If that is the case using interior mutability might save us here.
We'd be able to do:
if let Some(http_stream) = self.http_streams.get(&context_id).borrow_mut() {...}
To do this I guess using
Rc<RefCell<dyn HttpContext>>
should work but this also implies changing the function defsNew[...]Context
to return something likeRefCell<dyn HttpContext>
which is an api breaking change.Considering I'm not super knowledgeable in Rust I wanted to get an opinion before working on a PR.
If not I'll try to fix this.
The text was updated successfully, but these errors were encountered: