Merge pull request 'Close a connection if sending fails.' (#438) from send into master
continuous-integration/drone/push Build is pending Details

Reviewed-on: #438
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
parseScope
Sarah Jamie Lewis 2 years ago
commit 3fbf88d34b

@ -153,7 +153,21 @@ func (pa *PeerApp) SendMessage(message model2.PeerMessage) error {
}
if err == nil {
return pa.connection.Send(serialized)
err = pa.connection.Send(serialized)
// at this point we have tried to send a message to a peer only to find that something went wrong.
// we don't know *what* went wrong - the most likely explanation is the peer went offline in the time between
// sending the message and it arriving in the engine to be sent. Other explanations include problems with Tor,
// a dropped wifi connection.
// Regardless, we error out this message and close this peer app assuming it cannot be used again.
// We expect that cwtch will eventually recreate this connection and the app.
if err != nil {
// close any associated sockets
pa.connection.Close()
// tell cwtch this connection is no longer valid
pa.OnClose(err.Error())
}
return err
}
return err
}

Loading…
Cancel
Save