forked from lx/netapp
Small optimization
This commit is contained in:
parent
50627c2060
commit
b9df442f03
2 changed files with 8 additions and 1 deletions
|
@ -52,7 +52,10 @@ where
|
||||||
T: EndpointHandler<M>,
|
T: EndpointHandler<M>,
|
||||||
M: Message + 'static,
|
M: Message + 'static,
|
||||||
{
|
{
|
||||||
async fn handle(self: &Arc<Self>, m: Req<M>, from: NodeID) -> Resp<M> {
|
async fn handle(self: &Arc<Self>, mut m: Req<M>, from: NodeID) -> Resp<M> {
|
||||||
|
// Immediately drop stream to avoid backpressure if a stream was sent
|
||||||
|
// (this will make all data sent to the stream be ignored immediately)
|
||||||
|
drop(m.take_stream());
|
||||||
Resp::new(EndpointHandler::handle(self, m.msg(), from).await)
|
Resp::new(EndpointHandler::handle(self, m.msg(), from).await)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,10 @@ impl<M: Message> Req<M> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_stream(&mut self) -> Option<ByteStream> {
|
||||||
|
std::mem::replace(&mut self.body, BodyData::None).into_stream()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn into_enc(
|
pub(crate) fn into_enc(
|
||||||
self,
|
self,
|
||||||
prio: RequestPriority,
|
prio: RequestPriority,
|
||||||
|
|
Loading…
Reference in a new issue