From 137d13c1fde3e2b4d7184ce57222b61f16738257 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 1 Mar 2018 16:48:11 -0500 Subject: Bug 531883 - Deadlock in Docker when connection closes - in DockerConnection, move the setState() call in close() outside of the clientLock - in setState(), protect the setting of the global containers and images lists using the containerLock and imageLock respectively - this will avoid notification from occuring within a clientLock Change-Id: Ia5e942b15ba8b5db95d1ac1596c135273cb999fb Reviewed-on: https://git.eclipse.org/r/118463 Tested-by: Hudson CI Reviewed-by: Jeff Johnston --- .../linuxtools/internal/docker/core/DockerConnection.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java index e98ad4d8b3..142eee7660 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java @@ -318,9 +318,13 @@ public class DockerConnection switch (state) { case UNKNOWN: case CLOSED: - this.images = Collections.emptyList(); - this.containers = Collections.emptyList(); - this.containersById = new HashMap<>(); + synchronized (imageLock) { + this.images = Collections.emptyList(); + } + synchronized (containerLock) { + this.containers = Collections.emptyList(); + this.containersById = new HashMap<>(); + } notifyContainerListeners(this.containers); notifyImageListeners(this.images); break; @@ -372,8 +376,8 @@ public class DockerConnection this.client.close(); this.client = null; } - setState(EnumDockerConnectionState.CLOSED); } + setState(EnumDockerConnectionState.CLOSED); } @Override -- cgit v1.2.3