Skip to content

Commit

Permalink
Indicate stream exhaustion on close message
Browse files Browse the repository at this point in the history
Once we receive a close message we should not continue polling the
stream for more data. With this change we immediately indicate
exhaustion to higher layers instead.
  • Loading branch information
d-e-s-o committed Jan 6, 2024
1 parent 37e8e7f commit 9536f5b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,11 @@ where
// registered that we received a message above.
},
WebSocketMessage::Close(_) => {
// We just ignore close messages. From our perspective
// they serve no purpose, because the stream already has a
// notion of "exhausted" with `Poll::Ready(None)`. The
// only value-add they provide is the optional close
// frame, but we don't intend to use it or expose it to
// clients.
// Once we received a close message from the remote, we
// can safely stop anything we've been doing. We do not
// expose those to higher layers and instead just indicate
// stream exhaustion.
break Poll::Ready(None)
},
WebSocketMessage::Frame(_) => {
// We should never receive such a value while reading
Expand Down

0 comments on commit 9536f5b

Please sign in to comment.