Skip to content

Commit 5f2fcb7

Browse files
committed
wg-webclient: disconnect inner websocket before connecting it. This fixes a double borrow when reconnecting causing a crash on safari. fix #118
1 parent 46639ce commit 5f2fcb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

wg-webclient/src/wg_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ impl WgClient {
248248
* Creates a new Websocket object and connection that gets stored internally.
249249
*/
250250
fn start_inner_ws(&mut self, cb: js_sys::Function) {
251+
self.disconnect_inner_ws();
251252
let mut stream = TcpStream::new(self.iface.clone());
252253
let port = js_sys::Math::random() * 1000.0;
253254
let port = port as u16;
@@ -616,7 +617,6 @@ impl WgClient {
616617
}
617618

618619
pub fn disconnect_inner_ws(&mut self) {
619-
log::debug!("disconnecting inner ws");
620620
let mut sock_ref = self.websocket.borrow_mut();
621621
if let Some(socket) = &*sock_ref {
622622
socket.disconnect();

0 commit comments

Comments
 (0)