Don't swallow ping/pong while waiting for close acknowledgement

pull/75/head
Naja Melan 5 years ago
parent fc41b598ce
commit 9379ebe47d
  1. 6
      src/protocol/mod.rs

@ -383,13 +383,15 @@ impl WebSocketContext {
OpCtl::Reserved(i) => Err(Error::Protocol(
format!("Unknown control frame type {}", i).into(),
)),
OpCtl::Ping | OpCtl::Pong if !self.state.is_active() => {
// No ping processing while closing.
OpCtl::Ping | OpCtl::Pong if !self.state.can_read() => {
Ok(None)
}
OpCtl::Ping => {
let data = frame.into_data();
// No ping processing after we sent a close frame.
if self.state.is_active() {
self.pong = Some(Frame::pong(data.clone()));
}
Ok(Some(Message::Ping(data)))
}
OpCtl::Pong => Ok(Some(Message::Pong(frame.into_data()))),

Loading…
Cancel
Save