moby--moby/daemon/logger
Tom Booth a69a59ffc7 Decouple removing the fileWatcher from reading
Fixes #27779

Currently `followLogs` can get into a deadlock if we receive an inotify
IN_MODIFY event while we are trying to close the `fileWatcher`. This is
due to the fact that closing the `fileWatcher` happens in the same block
as consumes events from the `fileWatcher`. We are trying to run
`fileWatcher.Close`, which is waiting for an IN_IGNORE event to come in
over inotify to confirm the watch was been removed. But, because an
IN_MODIFY event has appeared after `Close` was entered but before the
IN_IGNORE, the broadcast never comes. The IN_MODIFY cannot be consumed
as the events channel is unbuffered and the only `select` that reads
from it is busy waiting for the IN_IGNORE event.

In order to try and fix this race condition I've moved the removal of
the `fileWatcher` out to a separate go block that waits for a signal to
close, removes the watcher and then signals to the previous selects on
the close signal.

This has introduced a `fileWatcher.Remove` in the final case, but if we
try and remove a watcher that does not exist it will just return an
error saying so. We are not doing any checking on the return of `Remove`
so this shouldn't cause any side-effects.

Signed-off-by: Tom Booth <tombooth@gmail.com>
2016-10-28 10:53:38 +01:00
..
awslogs awslogs: Record log line insert order for sorting 2016-08-03 10:04:20 -07:00
etwlogs fix typos 2016-06-02 17:17:22 +08:00
fluentd Standardize default logging tag value 2016-06-04 12:38:12 +02:00
gcplogs Added optional flags to init gcp logger metadata 2016-07-13 13:56:18 +01:00
gelf Standardize default logging tag value 2016-06-04 12:38:12 +02:00
journald Sanitize docker labels when used as journald field names 2016-08-05 15:20:47 -07:00
jsonfilelog Decouple removing the fileWatcher from reading 2016-10-28 10:53:38 +01:00
logentries added logentries driver 2016-10-06 22:48:53 -03:00
loggerutils Standardize default logging tag value 2016-06-04 12:38:12 +02:00
splunk Splunk Logging Driver performance improvements 2016-09-12 09:00:16 -07:00
syslog Merge pull request #25736 from mwieczorek/25689-enable-syslog-driver-on-windows 2016-08-29 17:46:12 -04:00
context.go all: replace loop with single append 2016-10-13 13:31:52 -07:00
copier.go Merge pull request #22982 from nalind/log-newlines 2016-07-28 16:41:01 -07:00
copier_test.go Add a benchmark for logger.Copier 2016-06-09 09:47:13 -04:00
factory.go inherit the daemon log options when creating containers 2016-05-02 23:04:04 +08:00
logger.go Merge pull request #22982 from nalind/log-newlines 2016-07-28 16:41:01 -07:00