Comments (1)
Maybe this will help someone out there but I ended up reading from the stream to check for interruptions
without blocking if nothing is waiting. This allowed me to check if the stream is closed - for my use case,
adding a protocol message for interrupting the RPC stream that the server-side can read.
async fn check_stream(&mut self) -> Result<(), RpcServerError> {
let check = futures::future::poll_fn(|cx| match Pin::new(&mut self.framed).poll_next(cx) {
Poll::Ready(Some(Ok(_))) => Poll::Ready(Some(RpcServerError::UnexpectedIncomingMessage)),
Poll::Ready(Some(Err(err))) => Poll::Ready(Some(RpcServerError::from(err))),
Poll::Ready(None) => Poll::Ready(Some(RpcServerError::StreamClosedByRemote)),
Poll::Pending => Poll::Ready(None),
})
.await;
match check {
Some(err) => Err(err),
None => Ok(()),
}
}
from rust-yamux.
Related Issues (20)
- Waiting on new channel and channel read in the same task HOT 2
- GC Bug HOT 12
- add chunking in poll_write? HOT 1
- Use type state pattern HOT 4
- Simple client/server example blocks forever HOT 8
- Consider yielding early if we have filled buffers to some degree
- Track the accept backlog and add an upper limit HOT 3
- Re-write interface to buffer streams internally HOT 1
- Remove `futures::Stream` impl from `Stream`
- Remove `ControlledConnection` and everything around it
- Consider increasing `receive_window` default HOT 7
- Dropped `Stream`s are never removed until connection closes? HOT 1
- Refactor `stream::Shared` to use internal mutability
- Doc for v0.12.0 is outdated HOT 2
- refactor: replace `Chunks` with `BytesMut` HOT 2
- chore: remove `WindowUpdateMode::OnReceive` HOT 1
- What is the idiomatic way to create multiple streams? HOT 2
- `poll_new_outbound` without sending data results in no `inbound` stream HOT 2
- Is there any problem with my code and why it doesn't work HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-yamux.