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( OpCtl::Reserved(i) => Err(Error::Protocol(
format!("Unknown control frame type {}", i).into(), format!("Unknown control frame type {}", i).into(),
)), )),
OpCtl::Ping | OpCtl::Pong if !self.state.is_active() => { OpCtl::Ping | OpCtl::Pong if !self.state.can_read() => {
// No ping processing while closing.
Ok(None) Ok(None)
} }
OpCtl::Ping => { OpCtl::Ping => {
let data = frame.into_data(); 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())); self.pong = Some(Frame::pong(data.clone()));
}
Ok(Some(Message::Ping(data))) Ok(Some(Message::Ping(data)))
} }
OpCtl::Pong => Ok(Some(Message::Pong(frame.into_data()))), OpCtl::Pong => Ok(Some(Message::Pong(frame.into_data()))),

Loading…
Cancel
Save