mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Don't panic when dealing with disconnected websockets.
This commit is contained in:
parent
5a55ae1b13
commit
ba83f0ffa6
7 changed files with 17 additions and 30 deletions
|
@ -268,21 +268,31 @@ pub fn init(
|
||||||
let dom_action = message.to().expect("Ws dom_action message to deserialize");
|
let dom_action = message.to().expect("Ws dom_action message to deserialize");
|
||||||
match dom_action {
|
match dom_action {
|
||||||
WebSocketDomAction::SendMessage(MessageData::Text(data)) => {
|
WebSocketDomAction::SendMessage(MessageData::Text(data)) => {
|
||||||
ws_sender.send(Message::text(data)).unwrap();
|
if let Err(e) = ws_sender.send(Message::text(data)) {
|
||||||
|
warn!("Error sending websocket message: {:?}", e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
WebSocketDomAction::SendMessage(MessageData::Binary(data)) => {
|
WebSocketDomAction::SendMessage(MessageData::Binary(data)) => {
|
||||||
ws_sender.send(Message::binary(data)).unwrap();
|
if let Err(e) = ws_sender.send(Message::binary(data)) {
|
||||||
|
warn!("Error sending websocket message: {:?}", e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
WebSocketDomAction::Close(code, reason) => {
|
WebSocketDomAction::Close(code, reason) => {
|
||||||
if !initiated_close.fetch_or(true, Ordering::SeqCst) {
|
if !initiated_close.fetch_or(true, Ordering::SeqCst) {
|
||||||
match code {
|
match code {
|
||||||
Some(code) => ws_sender
|
Some(code) => {
|
||||||
.close_with_reason(
|
if let Err(e) = ws_sender.close_with_reason(
|
||||||
code.into(),
|
code.into(),
|
||||||
reason.unwrap_or("".to_owned()),
|
reason.unwrap_or("".to_owned()),
|
||||||
)
|
) {
|
||||||
.unwrap(),
|
warn!("Error closing websocket: {:?}", e);
|
||||||
None => ws_sender.close(CloseCode::Status).unwrap(),
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
if let Err(e) = ws_sender.close(CloseCode::Status) {
|
||||||
|
warn!("Error closing websocket: {:?}", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[009.html?wss]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[009.html]
|
|
||||||
expected: TIMEOUT
|
|
|
@ -1,5 +0,0 @@
|
||||||
[022.html]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[022.html?wss]
|
|
||||||
expected: TIMEOUT
|
|
|
@ -4,4 +4,3 @@
|
||||||
|
|
||||||
[005.html?wss]
|
[005.html?wss]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[003-sets-origin.worker.html]
|
|
||||||
expected: CRASH
|
|
|
@ -1,5 +0,0 @@
|
||||||
[003.html?wss]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[003.html]
|
|
||||||
expected: TIMEOUT
|
|
|
@ -1,5 +0,0 @@
|
||||||
[005.html?wss]
|
|
||||||
expected: TIMEOUT
|
|
||||||
|
|
||||||
[005.html]
|
|
||||||
expected: TIMEOUT
|
|
Loading…
Add table
Add a link
Reference in a new issue