forked from quic-go/quic-go
avoid lock contention when accepting new connections (#4313)
* avoid lock contention when accepting new connections The server used to hold the packet handler map's lock while creating the connection struct for a newly accepted connection. This was intended to make sure that no two connections with the same Destination Connection ID could be created. This is a corner case: it can only happen if two Initial packets with the same Destination Connection ID are received at the same time. If the second one is received after the first one has already been processed, it would be routed to the first connection. We don't need to optimized for this corner case. It's ok to create a new connection in that case, and immediately close it if this collision is detected. * only pass 0-RTT to the connection if it was actually accepted
This commit is contained in:
@@ -59,18 +59,12 @@ var _ = Describe("Packet Handler Map", func() {
|
||||
|
||||
It("adds newly to-be-constructed handlers", func() {
|
||||
m := newPacketHandlerMap(nil, nil, utils.DefaultLogger)
|
||||
var called bool
|
||||
connID1 := protocol.ParseConnectionID([]byte{1, 2, 3, 4})
|
||||
connID2 := protocol.ParseConnectionID([]byte{4, 3, 2, 1})
|
||||
Expect(m.AddWithConnID(connID1, connID2, func() (packetHandler, bool) {
|
||||
called = true
|
||||
return NewMockPacketHandler(mockCtrl), true
|
||||
})).To(BeTrue())
|
||||
Expect(called).To(BeTrue())
|
||||
Expect(m.AddWithConnID(connID1, protocol.ParseConnectionID([]byte{1, 2, 3}), func() (packetHandler, bool) {
|
||||
Fail("didn't expect the constructor to be executed")
|
||||
return nil, false
|
||||
})).To(BeFalse())
|
||||
h := NewMockPacketHandler(mockCtrl)
|
||||
Expect(m.AddWithConnID(connID1, connID2, h)).To(BeTrue())
|
||||
// collision of the destination connection ID, this handler should not be added
|
||||
Expect(m.AddWithConnID(connID1, protocol.ParseConnectionID([]byte{1, 2, 3}), nil)).To(BeFalse())
|
||||
})
|
||||
|
||||
It("adds, gets and removes reset tokens", func() {
|
||||
|
||||
Reference in New Issue
Block a user