mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
use a single Go routine to send copies of CONNECTION_CLOSE packets
This commit is contained in:
parent
c3ab9c4ea9
commit
b659414495
9 changed files with 102 additions and 145 deletions
|
@ -37,12 +37,6 @@ func areConnsRunning() bool {
|
|||
return strings.Contains(b.String(), "quic-go.(*connection).run")
|
||||
}
|
||||
|
||||
func areClosedConnsRunning() bool {
|
||||
var b bytes.Buffer
|
||||
pprof.Lookup("goroutine").WriteTo(&b, 1)
|
||||
return strings.Contains(b.String(), "quic-go.(*closedLocalConn).run")
|
||||
}
|
||||
|
||||
var _ = Describe("Connection", func() {
|
||||
var (
|
||||
conn *connection
|
||||
|
@ -72,14 +66,11 @@ var _ = Describe("Connection", func() {
|
|||
}
|
||||
|
||||
expectReplaceWithClosed := func() {
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, s packetHandler) {
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, _ protocol.Perspective, _ []byte) {
|
||||
Expect(connIDs).To(ContainElement(srcConnID))
|
||||
if len(connIDs) > 1 {
|
||||
Expect(connIDs).To(ContainElement(clientDestConnID))
|
||||
}
|
||||
Expect(s).To(BeAssignableToTypeOf(&closedLocalConn{}))
|
||||
s.shutdown()
|
||||
Eventually(areClosedConnsRunning).Should(BeFalse())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -333,9 +324,8 @@ var _ = Describe("Connection", func() {
|
|||
ErrorMessage: "foobar",
|
||||
}
|
||||
streamManager.EXPECT().CloseWithError(expectedErr)
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, s packetHandler) {
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, _ protocol.Perspective, _ []byte) {
|
||||
Expect(connIDs).To(ConsistOf(clientDestConnID, srcConnID))
|
||||
Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{}))
|
||||
})
|
||||
cryptoSetup.EXPECT().Close()
|
||||
gomock.InOrder(
|
||||
|
@ -362,9 +352,8 @@ var _ = Describe("Connection", func() {
|
|||
ErrorMessage: "foobar",
|
||||
}
|
||||
streamManager.EXPECT().CloseWithError(testErr)
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, s packetHandler) {
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(connIDs []protocol.ConnectionID, _ protocol.Perspective, _ []byte) {
|
||||
Expect(connIDs).To(ConsistOf(clientDestConnID, srcConnID))
|
||||
Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{}))
|
||||
})
|
||||
cryptoSetup.EXPECT().Close()
|
||||
gomock.InOrder(
|
||||
|
@ -564,7 +553,7 @@ var _ = Describe("Connection", func() {
|
|||
runConn()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).AnyTimes()
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||
buf := &bytes.Buffer{}
|
||||
hdr := &wire.ExtendedHeader{
|
||||
Header: wire.Header{DestConnectionID: srcConnID},
|
||||
|
@ -2432,10 +2421,7 @@ var _ = Describe("Client Connection", func() {
|
|||
}
|
||||
|
||||
expectReplaceWithClosed := func() {
|
||||
connRunner.EXPECT().ReplaceWithClosed([]protocol.ConnectionID{srcConnID}, gomock.Any()).Do(func(_ []protocol.ConnectionID, s packetHandler) {
|
||||
s.shutdown()
|
||||
Eventually(areClosedConnsRunning).Should(BeFalse())
|
||||
})
|
||||
connRunner.EXPECT().ReplaceWithClosed([]protocol.ConnectionID{srcConnID}, gomock.Any(), gomock.Any())
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
|
@ -2766,10 +2752,7 @@ var _ = Describe("Client Connection", func() {
|
|||
|
||||
expectClose := func(applicationClose bool) {
|
||||
if !closed {
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ []protocol.ConnectionID, s packetHandler) {
|
||||
Expect(s).To(BeAssignableToTypeOf(&closedLocalConn{}))
|
||||
s.shutdown()
|
||||
})
|
||||
connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
if applicationClose {
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue