Skip to content
Open
2 changes: 1 addition & 1 deletion .github/workflows/go-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
id: coverages
run: echo "files=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_OUTPUT
- name: Upload coverage to Codecov
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
uses: codecov/codecov-action@v4
with:
files: ${{ steps.coverages.outputs.files }}
env_vars: OS=${{ matrix.os }}, GO=${{ steps.go.outputs.version }}
Expand Down
18 changes: 10 additions & 8 deletions core/routing/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type QueryEvent struct {

type routingQueryKey struct{}
type eventChannel struct {
mu sync.Mutex
mu sync.RWMutex
ctx context.Context
ch chan<- *QueryEvent
}
Expand All @@ -59,20 +59,22 @@ type eventChannel struct {
func (e *eventChannel) waitThenClose() {
<-e.ctx.Done()
e.mu.Lock()
close(e.ch)
// 1. Signals that we're done.
// 2. Frees memory (in case we end up hanging on to this for a while).
e.ch = nil
if e.ch != nil {
close(e.ch)
// 1. Signals that we're done.
// 2. Frees memory (in case we end up hanging on to this for a while).
e.ch = nil
}
e.mu.Unlock()
}

// send sends an event on the event channel, aborting if either the passed or
// the internal context expire.
func (e *eventChannel) send(ctx context.Context, ev *QueryEvent) {
e.mu.Lock()
e.mu.RLock()
// Closed.
if e.ch == nil {
e.mu.Unlock()
e.mu.RUnlock()
return
}
// in case the passed context is unrelated, wait on both.
Expand All @@ -81,7 +83,7 @@ func (e *eventChannel) send(ctx context.Context, ev *QueryEvent) {
case <-e.ctx.Done():
case <-ctx.Done():
}
e.mu.Unlock()
e.mu.RUnlock()
}

// RegisterForQueryEvents registers a query event channel with the given
Expand Down
4 changes: 3 additions & 1 deletion p2p/host/autorelay/relay_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ func (rf *relayFinder) background(ctx context.Context) {
workTimer := rf.conf.clock.InstantTimer(rf.runScheduledWork(ctx, now, scheduledWork, peerSourceRateLimiter))
defer workTimer.Stop()

go rf.cleanupDisconnectedPeers(ctx)
rf.refCount.Go(func() {
rf.cleanupDisconnectedPeers(ctx)
})

// update addrs on starting the relay finder.
rf.updateAddrs()
Expand Down
1 change: 1 addition & 0 deletions p2p/metricshelper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ func PutStringSlice(s *[]string) {
if c := cap(*s); c < capacity {
panic(fmt.Sprintf("expected a string slice with capacity 8 or greater, got %d", c))
}
clear(*s)
stringPool.Put(s)
}
Loading