Files
docker-cli/components/engine/daemon
Tom Booth 5355683d26 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>
Upstream-commit: a69a59ffc7e3d028a72d1195c2c1535f447eaa84
Component: engine
2016-10-28 10:53:38 +01:00
..
2016-09-07 11:05:58 -07:00
2016-09-16 12:27:13 -04:00
2016-09-07 11:05:58 -07:00
2016-10-25 06:43:54 +00:00
2016-09-16 12:27:13 -04:00
2016-10-22 08:53:57 +08:00
2016-07-21 20:04:47 -07:00
2016-10-20 13:24:23 -07:00
2016-09-16 12:27:13 -04:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-10-06 17:12:17 -07:00
2016-09-07 11:05:58 -07:00
2016-10-24 15:20:01 -07:00
2016-10-20 17:06:11 +02:00
2016-06-27 10:23:37 -07:00
2016-06-27 10:23:37 -07:00
2016-09-07 11:05:58 -07:00
2016-10-06 22:48:53 -03:00
2016-10-06 22:48:53 -03:00
2016-09-07 11:05:58 -07:00
2016-09-13 09:55:35 -04:00
2016-10-25 06:43:54 +00:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-09-01 11:53:07 +02:00
2016-09-16 11:56:15 -07:00
2016-09-16 11:56:15 -07:00
2016-09-21 12:36:52 +02:00
2016-09-16 11:56:15 -07:00
2016-09-16 11:56:15 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00