wisp_mux v1.1.1: fix continue packets and flow control

This commit is contained in:
Toshit Chawda 2024-02-08 09:43:21 -08:00
parent 9ebb24b088
commit 8b2a8a3eb3
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
4 changed files with 43 additions and 27 deletions

View file

@ -53,7 +53,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStreamRead<W> {
match self.rx.next().await? {
MuxEvent::Send(bytes) => {
if self.role == crate::Role::Server && self.stream_type == crate::StreamType::Tcp {
let old_val = self.flow_control.fetch_add(1, Ordering::SeqCst);
let old_val = self.flow_control.fetch_add(1, Ordering::AcqRel);
self.tx
.write_frame(
crate::Packet::new_continue(self.stream_id, old_val + 1).into(),
@ -115,8 +115,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStreamWrite<W> {
self.flow_control.store(
self.flow_control
.load(Ordering::Acquire)
.checked_add(1)
.unwrap_or(0),
.saturating_sub(1),
Ordering::Release,
);
}