mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #31263 from nalind/journal-doublefree
Synchronize the cursor returned by followJournal
This commit is contained in:
commit
b3e7f70137
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -285,6 +288,8 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
|
|||
C.close(pfd[1])
|
||||
}
|
||||
|
||||
cursor = <-newCursor
|
||||
|
||||
return cursor
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue