Closed dkropachev closed 4 months ago
@sylwiaszunejko do we need another maintainer reviewing it? If so, please get someone to review and merge.
Also, please make sure we have tests to detect such an issue (looks like we don't).
@avelanarius Could you look at it to make sure it LGTM?
@dkropachev I was wondering how to write a test for this, but I am not sure. I was trying to use the issue reproducer, but without fmt.Println("Routine:", routine, "Try:", try)
the issue stopped reproducing and with it or with analogues logging statement there was a error like that: testing.go:1465: race detected during execution of test
. Do you have any ideas how to minimize reproducer or how to test this change some other way?
@dkropachev I was wondering how to write a test for this, but I am not sure. I was trying to use the issue reproducer, but without
fmt.Println("Routine:", routine, "Try:", try)
the issue stopped reproducing and with it or with analogues logging statement there was a error like that:testing.go:1465: race detected during execution of test
. Do you have any ideas how to minimize reproducer or how to test this change some other way?
There is no good way of doing it. We could have an interface with something like :
DialContext(ctx context.Context, network, addr string) (net.Conn, error)
DialContextWithPort(ctx context.Context, network, addr string, sport uint16) (net.Conn, error)
And then mock it on test, but realy, this test won't acheve anything. To me better just not test it at all
@roydahan FYI
net.Dialer
makes golang runtime runbind
ifLocalAddr
is not nil, even if address is":0"
. https://github.com/golang/go/blob/master/src/net/sock_posix.go#L109-L117Calling
bind
, due to it's nature, marks obtained port as non-reusable, which limits number of possible connections/sessions.It is inevitable for
share-aware
connections, since we need to pick the port, but fornone-shard-aware
connections it must be avoided.Closes #179