From 123e75ac641721de9c19a652c9b1450b60bc7ef9 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Fri, 14 Jul 2023 15:17:35 -0400 Subject: [Bugfix] Accessing channel without protection I was accessing a lock-protected channel without holding the lock. That definitely seems to defeat the purpose of having the lock in the first place. Signed-off-by: Will Hawkins --- rpm/rpm.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'rpm') diff --git a/rpm/rpm.go b/rpm/rpm.go index 95e6192..d1c07a5 100644 --- a/rpm/rpm.go +++ b/rpm/rpm.go @@ -150,10 +150,14 @@ func ResponsivenessProber[BucketType utilities.Number]( currentBucketId := bucketGenerator.Generate() - dataPoints <- series.SeriesMessage[ResponsivenessProbeResult, BucketType]{ - Type: series.SeriesMessageReserve, Bucket: currentBucketId, - Measure: utilities.None[ResponsivenessProbeResult](), + dataPointsLock.Lock() + if dataPoints != nil { + dataPoints <- series.SeriesMessage[ResponsivenessProbeResult, BucketType]{ + Type: series.SeriesMessageReserve, Bucket: currentBucketId, + Measure: utilities.None[ResponsivenessProbeResult](), + } } + dataPointsLock.Unlock() // The presence of a custom TLSClientConfig in a *generic* `transport` // means that go will default to HTTP/1.1 and cowardly avoid HTTP/2: -- cgit v1.2.3