Skip to content

Commit

Permalink
command/agent/sink/sink.go: This fix solves the problem where when mu…
Browse files Browse the repository at this point in the history
…ltiple file sinks are specified in the agent HCL file, there is unexpected behavior (#5610)
  • Loading branch information
dbellinghoven authored and briankassouf committed Nov 1, 2018
1 parent 6c83e14 commit f99afb9
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions command/agent/sink/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,30 @@ func (ss *SinkServer) Run(ctx context.Context, incoming chan string, sinks []*Si

*latestToken = token

for _, s := range sinks {
sinkFunc := func(currSink *SinkConfig, currToken string) func() error {
return func() error {
if currToken != *latestToken {
return nil
}
var err error
sinkFunc := func(currSink *SinkConfig, currToken string) func() error {
return func() error {
if currToken != *latestToken {
return nil
}
var err error

if currSink.WrapTTL != 0 {
if currToken, err = s.wrapToken(ss.client, currSink.WrapTTL, currToken); err != nil {
return err
}
if currSink.WrapTTL != 0 {
if currToken, err = currSink.wrapToken(ss.client, currSink.WrapTTL, currToken); err != nil {
return err
}
}

if s.DHType != "" {
if currToken, err = s.encryptToken(currToken); err != nil {
return err
}
if currSink.DHType != "" {
if currToken, err = currSink.encryptToken(currToken); err != nil {
return err
}

return currSink.WriteToken(currToken)
}

return currSink.WriteToken(currToken)
}
}

for _, s := range sinks {
atomic.AddInt32(ss.remaining, 1)
sinkCh <- sinkFunc(s, token)
}
Expand Down

0 comments on commit f99afb9

Please sign in to comment.