Skip to content

Commit

Permalink
wg-webclient: disconnect inner websocket before connecting it. This f…
Browse files Browse the repository at this point in the history
…ixes a double borrow when reconnecting causing a crash on safari. fix #118
  • Loading branch information
ffreddow committed Oct 24, 2024
1 parent 46639ce commit 5f2fcb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wg-webclient/src/wg_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl WgClient {
* Creates a new Websocket object and connection that gets stored internally.
*/
fn start_inner_ws(&mut self, cb: js_sys::Function) {
self.disconnect_inner_ws();
let mut stream = TcpStream::new(self.iface.clone());
let port = js_sys::Math::random() * 1000.0;
let port = port as u16;
Expand Down Expand Up @@ -616,7 +617,6 @@ impl WgClient {
}

pub fn disconnect_inner_ws(&mut self) {
log::debug!("disconnecting inner ws");
let mut sock_ref = self.websocket.borrow_mut();
if let Some(socket) = &*sock_ref {
socket.disconnect();
Expand Down

0 comments on commit 5f2fcb7

Please sign in to comment.