Commit 036e98c7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a3dc8357
......@@ -80,7 +80,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
txWg.Done()
}()
// rx handshake word
go func() {
var b [4]byte
......@@ -100,9 +99,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
connClosed := false
defer func() {
// make sure our version is always sent on the wire, if possible,
// so that peer does not see just closed connection when on rx we see version mismatch
// so that peer does not see just closed connection when on rx we see version mismatch.
//
// NOTE if cancelled tx goroutine will wake up without delay
// NOTE if cancelled tx goroutine will wake up without delay.
txWg.Wait()
// don't forget to close conn if returning with error + add handshake err context
......@@ -114,7 +113,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
}
}()
for i := 0; i < 2; i++ {
select {
case <-ctx.Done():
......@@ -184,10 +182,11 @@ type LinkListener interface {
Accept() (*NodeLink, error)
}
// linkListener implements LinkListener.
type linkListener struct {
l net.Listener
acceptq chan linkAccepted
closed chan struct {}
closed chan struct{}
}
type linkAccepted struct {
......@@ -252,7 +251,7 @@ func (l *linkListener) accept1(ctx context.Context, conn net.Conn, err error) (*
}
func (l *linkListener) Accept() (*NodeLink, error) {
select{
select {
case <-l.closed:
// we know raw listener is already closed - return proper error about it
_, err := l.l.Accept()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment