forked from quic-go/quic-go
Merge pull request #1445 from lucas-clemente/fix-1444
fix race condition when adding packet handlers to the multiplexer
This commit is contained in:
@@ -56,6 +56,7 @@ func getClientMultiplexer() multiplexer {
|
||||
func (m *clientMultiplexer) AddConn(c net.PacketConn, connIDLen int) (packetHandlerManager, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
p, ok := m.conns[c]
|
||||
if !ok {
|
||||
manager := m.newPacketHandlerManager()
|
||||
@@ -72,6 +73,9 @@ func (m *clientMultiplexer) AddConn(c net.PacketConn, connIDLen int) (packetHand
|
||||
}
|
||||
|
||||
func (m *clientMultiplexer) AddHandler(c net.PacketConn, connID protocol.ConnectionID, handler packetHandler) error {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
p, ok := m.conns[c]
|
||||
if !ok {
|
||||
return errors.New("unknown packet conn %s")
|
||||
|
||||
Reference in New Issue
Block a user