|
@@ -11,6 +11,7 @@ import (
|
|
"errors"
|
|
"errors"
|
|
"sort"
|
|
"sort"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/docker/docker/pkg/jsonlog"
|
|
"github.com/docker/docker/pkg/jsonlog"
|
|
@@ -83,6 +84,7 @@ type LogWatcher struct {
|
|
Msg chan *Message
|
|
Msg chan *Message
|
|
// For sending error messages that occur while while reading logs.
|
|
// For sending error messages that occur while while reading logs.
|
|
Err chan error
|
|
Err chan error
|
|
|
|
+ closeOnce sync.Once
|
|
closeNotifier chan struct{}
|
|
closeNotifier chan struct{}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -98,11 +100,9 @@ func NewLogWatcher() *LogWatcher {
|
|
// Close notifies the underlying log reader to stop.
|
|
// Close notifies the underlying log reader to stop.
|
|
func (w *LogWatcher) Close() {
|
|
func (w *LogWatcher) Close() {
|
|
// only close if not already closed
|
|
// only close if not already closed
|
|
- select {
|
|
|
|
- case <-w.closeNotifier:
|
|
|
|
- default:
|
|
|
|
|
|
+ w.closeOnce.Do(func() {
|
|
close(w.closeNotifier)
|
|
close(w.closeNotifier)
|
|
- }
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
// WatchClose returns a channel receiver that receives notification
|
|
// WatchClose returns a channel receiver that receives notification
|