Close a connection is sending fails.
This commit is contained in:
parent
abfa95cddb
commit
7fd53a3b16
|
@ -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 connection 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…
Reference in New Issue