From 2fca1d5368f6888e3b83fc6d3c8409a1e2388aa6 Mon Sep 17 00:00:00 2001 From: Mark Dascher Date: Wed, 2 Aug 2017 14:37:57 -0500 Subject: [PATCH] New go-tail, to fix goroutine leaks --- .../papertrail/go-tail/follower/follower.go | 15 +++++++++------ vendor/vendor.json | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/vendor/github.com/papertrail/go-tail/follower/follower.go b/vendor/github.com/papertrail/go-tail/follower/follower.go index 1eb0705..a73297d 100644 --- a/vendor/github.com/papertrail/go-tail/follower/follower.go +++ b/vendor/github.com/papertrail/go-tail/follower/follower.go @@ -62,6 +62,7 @@ func New(filename string, config Config) (*Follower, error) { filename: filename, lines: make(chan Line), config: config, + closeCh: make(chan struct{}), } err := t.reopen() @@ -98,7 +99,7 @@ func (t *Follower) follow() error { var ( eventChan = make(chan fsnotify.Event) - errChan = make(chan error) + errChan = make(chan error, 1) ) t.watcher, err = fsnotify.NewWatcher() @@ -289,9 +290,6 @@ func (t *Follower) sendLine(l []byte, d int) { } func (t *Follower) watchFileEvents(eventChan chan fsnotify.Event, errChan chan error) { - defer close(eventChan) - defer close(errChan) - for { select { case evt, ok := <-t.watcher.Events: @@ -308,11 +306,16 @@ func (t *Follower) watchFileEvents(eventChan chan fsnotify.Event, errChan chan e } default: - eventChan <- evt + select { + case eventChan <- evt: + case err := <-t.watcher.Errors: + errChan <- err + return + } } // die on a file watching error - case err, _ := <-t.watcher.Errors: + case err := <-t.watcher.Errors: errChan <- err return } diff --git a/vendor/vendor.json b/vendor/vendor.json index 2b5f902..546dd57 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -108,10 +108,10 @@ "revision": "b30dcbfa86e3a1eaa4e6622de2ce57be2c138c10" }, { - "checksumSHA1": "rWc9yrqpLqyvgeyOxQhO0sDPT98=", + "checksumSHA1": "yVIJdaWkoUJbEhvujesED4rqAnE=", "path": "github.com/papertrail/go-tail/follower", - "revision": "e2752ede6edd8ce2a834603866f118eed9da0d4b", - "revisionTime": "2017-02-10T22:15:38Z" + "revision": "1b77c8dfcc6baca12dedfab119135396782b68a1", + "revisionTime": "2017-08-01T20:12:34Z" }, { "checksumSHA1": "8Y05Pz7onrQPcVWW6JStSsYRh6E=",