Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.

close all UDP connections when the reuse is closed #216

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Changes from all commits
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
14 changes: 13 additions & 1 deletion reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,19 @@ func newReuse() *reuse {
}

func (r *reuse) gc() {
defer close(r.gcStopChan)
defer func() {
r.mutex.Lock()
for _, conn := range r.global {
conn.Close()
}
for _, conns := range r.unicast {
for _, conn := range conns {
conn.Close()
}
}
r.mutex.Unlock()
close(r.gcStopChan)
}()
ticker := time.NewTicker(garbageCollectInterval)
defer ticker.Stop()

Expand Down