remove unnecessary locking

Fixes #2717
This commit is contained in:
Egon Elbre
2020-09-22 14:53:57 +03:00
parent 27448c1fa5
commit 60bec77f0a

View File

@@ -7,7 +7,6 @@ import (
"fmt" "fmt"
"net" "net"
"strings" "strings"
"sync"
"github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/internal/utils" "github.com/lucas-clemente/quic-go/internal/utils"
@@ -15,8 +14,6 @@ import (
) )
type client struct { type client struct {
mutex sync.Mutex
conn sendConn conn sendConn
// If the client is created with DialAddr, we create a packet conn. // If the client is created with DialAddr, we create a packet conn.
// If it is started with Dial, we take a packet conn as a parameter. // If it is started with Dial, we take a packet conn as a parameter.
@@ -252,7 +249,6 @@ func (c *client) dial(ctx context.Context) error {
c.tracer.StartedConnection(c.conn.LocalAddr(), c.conn.RemoteAddr(), c.version, c.srcConnID, c.destConnID) c.tracer.StartedConnection(c.conn.LocalAddr(), c.conn.RemoteAddr(), c.version, c.srcConnID, c.destConnID)
} }
c.mutex.Lock()
c.session = newClientSession( c.session = newClientSession(
c.conn, c.conn,
c.packetHandlers, c.packetHandlers,
@@ -268,7 +264,6 @@ func (c *client) dial(ctx context.Context) error {
c.logger, c.logger,
c.version, c.version,
) )
c.mutex.Unlock()
c.packetHandlers.Add(c.srcConnID, c.session) c.packetHandlers.Add(c.srcConnID, c.session)
errorChan := make(chan error, 1) errorChan := make(chan error, 1)