refactor: LocalConnection.CheckFatal be gone!

use Shutdown instead, which is in the Connection interface, thus
further reducing dependency on LocalConnection.
This commit is contained in:
Matthias Radestock committed 2015-01-21 21:23:59 +00:00
1 parent 9a27299562
commit 99525ebf85
5 files changed
+16 -23

No files matched your search

+6 -6
View File
@@ -192,21 +192,21 @@ func (peer *LocalPeer) handleAddConnection(conn *LocalConnection) {
dupConnLocal := dupConn.(*LocalConnection)
switch conn.BreakTie(dupConnLocal) {
case TieBreakWon:
dupConnLocal.CheckFatal(dupErr)
dupConn.Shutdown(dupErr)
peer.handleDeleteConnection(dupConnLocal)
case TieBreakLost:
conn.CheckFatal(dupErr)
conn.Shutdown(dupErr)
return
case TieBreakTied:
// oh good grief. Sod it, just kill both of them.
conn.CheckFatal(dupErr)
dupConnLocal.CheckFatal(dupErr)
conn.Shutdown(dupErr)
dupConn.Shutdown(dupErr)
peer.handleDeleteConnection(dupConnLocal)
return
}
}
if err := peer.checkConnectionLimit(); err != nil {
conn.CheckFatal(err)
conn.Shutdown(err)
return
}
peer.addConnection(conn)
@@ -239,7 +239,7 @@ func (peer *LocalPeer) handleConnectionEstablished(conn *LocalConnection) {
log.Fatal("Peer informed of active connection where peer is not the source of connection")
}
if dupConn, found := peer.connections[conn.Remote().Name]; !found || conn != dupConn {
conn.CheckFatal(fmt.Errorf("Cannot set unknown connection active"))
conn.Shutdown(fmt.Errorf("Cannot set unknown connection active"))
return
}
peer.connectionEstablished(conn)