Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: add a Close function to the Tracer #4298

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
close the Tracer when the Transport is closed
  • Loading branch information
marten-seemann committed Feb 3, 2024
commit 89d4ce47453d89c833dff39210f9804a706fd453
6 changes: 5 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ var _ = Describe("Server", func() {
})

AfterEach(func() {
tracer.EXPECT().Close()
tr.Close()
})

Expand Down Expand Up @@ -1429,7 +1430,10 @@ var _ = Describe("Server", func() {
serv.connHandler = phm
})

AfterEach(func() { tr.Close() })
AfterEach(func() {
tracer.EXPECT().Close()
tr.Close()
})

It("passes packets to existing connections", func() {
connID := protocol.ParseConnectionID([]byte{1, 2, 3, 4, 5, 6, 7, 8})
Expand Down
4 changes: 4 additions & 0 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type Transport struct {
MaxHandshakes int

// A Tracer traces events that don't belong to a single QUIC connection.
// Tracer.Close is called when the transport is closed.
Tracer *logging.Tracer

handlerMap packetHandlerManager
Expand Down Expand Up @@ -366,6 +367,9 @@ func (t *Transport) close(e error) {
if t.server != nil {
t.server.close(e, false)
}
if t.Tracer != nil && t.Tracer.Close != nil {
t.Tracer.Close()
}
t.closed = true
}

Expand Down
2 changes: 2 additions & 0 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ var _ = Describe("Transport", func() {
Eventually(dropped).Should(BeClosed())

// shutdown
tracer.EXPECT().Close()
close(packetChan)
tr.Close()
})
Expand Down Expand Up @@ -391,6 +392,7 @@ var _ = Describe("Transport", func() {
Eventually(done).Should(BeClosed())

// shutdown
tracer.EXPECT().Close()
close(packetChan)
tr.Close()
})
Expand Down
Loading