Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 877bf88

Browse files
committed
Fix NetFlow mutex issue
1 parent 4e2a3f7 commit 877bf88

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

utils/netflow.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (s *StateNetFlow) DecodeFlow(msg interface{}) error {
6868
samplerAddress = samplerAddress.To4()
6969
}
7070

71-
s.templateslock.RLock()
71+
s.templateslock.Lock()
7272
templates, ok := s.templates[key]
7373
if !ok {
7474
templates = &TemplateSystem{
@@ -77,14 +77,14 @@ func (s *StateNetFlow) DecodeFlow(msg interface{}) error {
7777
}
7878
s.templates[key] = templates
7979
}
80-
s.templateslock.RUnlock()
81-
s.samplinglock.RLock()
80+
s.templateslock.Unlock()
81+
s.samplinglock.Lock()
8282
sampling, ok := s.sampling[key]
8383
if !ok {
8484
sampling = producer.CreateSamplingSystem()
8585
s.sampling[key] = sampling
8686
}
87-
s.samplinglock.RUnlock()
87+
s.samplinglock.Unlock()
8888

8989
ts := uint64(time.Now().UTC().Unix())
9090
if pkt.SetTime {

0 commit comments

Comments
 (0)