aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-09-01 12:15:50 +0200
committerAlex Auvolat <alex@adnab.me>2022-09-01 12:15:50 +0200
commitcd203f5708907c2bf172a3c5b7c5b40e2557b2f4 (patch)
tree8b3eb284106d0f6b5af1ad4ad447c8004ff4c6f5 /src/server.rs
parent745c78618479c4177647e4d7fed97d5fd2d00d4f (diff)
downloadnetapp-cd203f5708907c2bf172a3c5b7c5b40e2557b2f4.tar.gz
netapp-cd203f5708907c2bf172a3c5b7c5b40e2557b2f4.zip
Add OrderTag to Req and Resp, refactor errors
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/server.rs b/src/server.rs
index 57062d8..c23c9e4 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -53,7 +53,7 @@ pub(crate) struct ServerConn {
netapp: Arc<NetApp>,
- resp_send: ArcSwapOption<mpsc::UnboundedSender<(RequestID, RequestPriority, ByteStream)>>,
+ resp_send: ArcSwapOption<mpsc::UnboundedSender<SendStream>>,
}
impl ServerConn {
@@ -177,26 +177,16 @@ impl RecvLoop for ServerConn {
tokio::spawn(async move {
debug!("server: recv_handler got {}", id);
- let (prio, resp_enc) = match ReqEnc::decode(stream).await {
- Ok(req_enc) => {
- let prio = req_enc.prio;
- let resp = self2.recv_handler_aux(req_enc).await;
-
- (
- prio,
- match resp {
- Ok(resp_enc) => resp_enc,
- Err(e) => RespEnc::from_err(e),
- },
- )
- }
- Err(e) => (PRIO_NORMAL, RespEnc::from_err(e)),
+ let (prio, resp_enc_result) = match ReqEnc::decode(stream).await {
+ Ok(req_enc) => (req_enc.prio, self2.recv_handler_aux(req_enc).await),
+ Err(e) => (PRIO_HIGH, Err(e)),
};
debug!("server: sending response to {}", id);
+ let (resp_stream, resp_order) = RespEnc::encode(resp_enc_result);
resp_send
- .send((id, prio, resp_enc.encode()))
+ .send((id, prio, resp_stream))
.log_err("ServerConn recv_handler send resp bytes");
Ok::<_, Error>(())
});