close: fix autobahn regression
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
This commit is contained in:
parent
dd300f8bd7
commit
06308b1b3f
|
@ -283,9 +283,11 @@ impl WebSocketContext {
|
|||
// response, unless it already received a Close frame. It SHOULD
|
||||
// respond with Pong frame as soon as is practical. (RFC 6455)
|
||||
if let Some(pong) = self.pong.take() {
|
||||
trace!("Sending pong reply");
|
||||
self.send_one_frame(stream, pong)?;
|
||||
}
|
||||
// If we have any unsent frames, send them.
|
||||
trace!("Frames still in queue: {}", self.send_queue.len());
|
||||
while let Some(data) = self.send_queue.pop_front() {
|
||||
self.send_one_frame(stream, data)?;
|
||||
}
|
||||
|
@ -301,6 +303,7 @@ impl WebSocketContext {
|
|||
// maximum segment lifetimes (2MSL), while there is no corresponding
|
||||
// server impact as a TIME_WAIT connection is immediately reopened upon
|
||||
// a new SYN with a higher seq number). (RFC 6455)
|
||||
self.state = WebSocketState::Terminated;
|
||||
Err(Error::ConnectionClosed)
|
||||
} else {
|
||||
Ok(())
|
||||
|
@ -519,6 +522,7 @@ impl WebSocketContext {
|
|||
}
|
||||
}
|
||||
|
||||
trace!("Sending frame: {:?}", frame);
|
||||
let res = self.frame.write_frame(stream, frame);
|
||||
// An expected "Connection reset by peer" is not fatal
|
||||
match res {
|
||||
|
@ -563,8 +567,6 @@ impl WebSocketState {
|
|||
/// Check if the state is active, return error if not.
|
||||
fn check_active(&self) -> Result<()> {
|
||||
match self {
|
||||
WebSocketState::ClosedByPeer | WebSocketState::CloseAcknowledged
|
||||
=> Err(Error::ConnectionClosed),
|
||||
WebSocketState::Terminated
|
||||
=> Err(Error::AlreadyClosed),
|
||||
_ => Ok(()),
|
||||
|
|
Loading…
Reference in New Issue