Add dial parallel for outbound dialer

This commit is contained in:
世界
2022-07-08 12:58:43 +08:00
parent d45007b501
commit 3699a57847
17 changed files with 253 additions and 39 deletions

View File

@@ -77,10 +77,9 @@ func (t *TCPTransport) offer() (*dnsConnection, error) {
func (t *TCPTransport) newConnection(conn *dnsConnection) {
defer close(conn.done)
defer conn.Close()
ctx, cancel := context.WithCancel(t.ctx)
err := task.Any(t.ctx, func() error {
err := task.Any(t.ctx, func(ctx context.Context) error {
return t.loopIn(conn)
}, func() error {
}, func(ctx context.Context) error {
select {
case <-ctx.Done():
return nil
@@ -88,7 +87,6 @@ func (t *TCPTransport) newConnection(conn *dnsConnection) {
return os.ErrClosed
}
})
cancel()
conn.err = err
if err != nil {
t.logger.Debug("connection closed: ", err)