Skip to content

Commit

Permalink
Merge pull request moby#31263 from nalind/journal-doublefree
Browse files Browse the repository at this point in the history
Synchronize the cursor returned by followJournal
  • Loading branch information
LK4D4 committed Feb 23, 2017
2 parents 1948cc5 + d57c330 commit b3e7f70
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions daemon/logger/journald/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
s.readers.readers[logWatcher] = logWatcher
s.readers.mu.Unlock()

newCursor := make(chan *C.char)

go func() {
for {
// Keep copying journal data out until we're notified to stop
Expand Down Expand Up @@ -276,6 +278,7 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
delete(s.readers.readers, logWatcher)
s.readers.mu.Unlock()
close(logWatcher.Msg)
newCursor <- cursor
}()

// Wait until we're told to stop.
Expand All @@ -285,6 +288,8 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
C.close(pfd[1])
}

cursor = <-newCursor

return cursor
}

Expand Down

0 comments on commit b3e7f70

Please sign in to comment.