Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions daemon/logger/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ func NewCopier(srcs map[string]io.Reader, dst Logger) *Copier {
// Run starts logs copying
func (c *Copier) Run() {
for src, w := range c.srcs {
c.copyJobs.Add(1)
go c.copySrc(src, w)
}
}

func (c *Copier) copySrc(name string, src io.Reader) {
defer c.copyJobs.Done()

bufSize := defaultBufSize
if sizedLogger, ok := c.dst.(SizedLogger); ok {
Expand Down Expand Up @@ -126,9 +124,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
msg.Timestamp = partialTS
}

if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
c.dst.Log(msg)
}
p += q + 1
}
Expand Down Expand Up @@ -158,9 +154,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
ordinal++
hasMorePartial = true

if logErr := c.dst.Log(msg); logErr != nil {
logDriverError(c.dst.Name(), string(msg.Line), logErr)
}
c.dst.Log(msg)
p = 0
n = 0
}
Expand All @@ -175,6 +169,7 @@ func (c *Copier) copySrc(name string, src io.Reader) {
}
}
}
c.copyJobs.Done()
}

// Wait waits until all copying is done
Expand All @@ -184,7 +179,5 @@ func (c *Copier) Wait() {

// Close closes the copier
func (c *Copier) Close() {
c.closeOnce.Do(func() {
close(c.closed)
})
close(c.closed)
}