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) { ...@@ -80,7 +80,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
txWg.Done() txWg.Done()
}() }()
// rx handshake word // rx handshake word
go func() { go func() {
var b [4]byte var b [4]byte
...@@ -100,9 +99,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) { ...@@ -100,9 +99,9 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
connClosed := false connClosed := false
defer func() { defer func() {
// make sure our version is always sent on the wire, if possible, // 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() txWg.Wait()
// don't forget to close conn if returning with error + add handshake err context // 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) { ...@@ -114,7 +113,6 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
} }
}() }()
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
select { select {
case <-ctx.Done(): case <-ctx.Done():
...@@ -184,10 +182,11 @@ type LinkListener interface { ...@@ -184,10 +182,11 @@ type LinkListener interface {
Accept() (*NodeLink, error) Accept() (*NodeLink, error)
} }
// linkListener implements LinkListener.
type linkListener struct { type linkListener struct {
l net.Listener l net.Listener
acceptq chan linkAccepted acceptq chan linkAccepted
closed chan struct {} closed chan struct{}
} }
type linkAccepted struct { type linkAccepted struct {
...@@ -252,7 +251,7 @@ func (l *linkListener) accept1(ctx context.Context, conn net.Conn, err error) (* ...@@ -252,7 +251,7 @@ func (l *linkListener) accept1(ctx context.Context, conn net.Conn, err error) (*
} }
func (l *linkListener) Accept() (*NodeLink, error) { func (l *linkListener) Accept() (*NodeLink, error) {
select{ select {
case <-l.closed: case <-l.closed:
// we know raw listener is already closed - return proper error about it // we know raw listener is already closed - return proper error about it
_, err := l.l.Accept() _, 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