fix closing conn

This commit is contained in:
Ethan Buchman
2017-04-11 12:42:11 -04:00
parent ebd3929c0d
commit 8067cdb5f2
2 changed files with 10 additions and 6 deletions

View File

@ -41,7 +41,12 @@ func newPeer(addr *NetAddress, reactorsByCh map[byte]Reactor, chDescs []*Channel
}
// outbound = true
return newPeerFromExistingConn(conn, true, reactorsByCh, chDescs, onPeerError, config, privKey)
peer, err := newPeerFromExistingConn(conn, true, reactorsByCh, chDescs, onPeerError, config, privKey)
if err != nil {
conn.Close()
return nil, err
}
return peer, nil
}
func newPeerFromExistingConn(conn net.Conn, outbound bool, reactorsByCh map[byte]Reactor, chDescs []*ChannelDescriptor, onPeerError func(*Peer, interface{}), config cfg.Config, privKey crypto.PrivKeyEd25519) (*Peer, error) {