Skip to content

Commit 901cda3

Browse files
author
Łukasz Kostka
committed
Fix race coondition
When SIGINT/SIGTERM is received before calling wg.Add(1), wg.Wait() causes a race coondition.
1 parent aa756bb commit 901cda3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func setupFlows(flows []*FlowCfg) (receivers []receiver) {
142142
out := make(chan logEvent)
143143
format, _ := template.New("").Parse(flow.CloudwatchFormat)
144144
go convertEvents(in, out, parserFunctions[flow.SyslogFormat], format)
145+
wg.Add(1)
145146
go recToDst(out, flow)
146147
}
147148
return
@@ -175,7 +176,6 @@ func convertEvents(in <-chan string, out chan<- logEvent, parsefn syslogParser,
175176

176177
// Buffer received events and send them to cloudwatch.
177178
func recToDst(in <-chan logEvent, cfg *FlowCfg) {
178-
wg.Add(1)
179179
defer wg.Done()
180180
stream_vars := getStreamVars()
181181
stream_name := stream_vars.render(cfg.Stream)

0 commit comments

Comments
 (0)