From 8099de259fb91a29674bf17cb1382c038b707a90 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Mon, 6 Oct 2014 14:40:41 -0700 Subject: [PATCH] HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected by the lock (cmccabe) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/net/unix/DomainSocketWatcher.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 21f4d0881f8..2d27e7ccfbe 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -354,6 +354,9 @@ Release 2.7.0 - UNRELEASED BUG FIXES + HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected + by the lock (cmccabe) + Release 2.6.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java index 8348aeb7dcf..6215e58cafd 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java @@ -101,6 +101,7 @@ public final class DomainSocketWatcher implements Closeable { */ private class NotificationHandler implements Handler { public boolean handle(DomainSocket sock) { + lock.lock(); try { if (LOG.isTraceEnabled()) { LOG.trace(this + ": NotificationHandler: doing a read on " + @@ -124,6 +125,8 @@ public final class DomainSocketWatcher implements Closeable { } closed = true; return true; + } finally { + lock.unlock(); } } } @@ -346,12 +349,15 @@ public final class DomainSocketWatcher implements Closeable { * Wake up the DomainSocketWatcher thread. */ private void kick() { + lock.lock(); try { notificationSockets[0].getOutputStream().write(0); } catch (IOException e) { if (!closed) { LOG.error(this + ": error writing to notificationSockets[0]", e); } + } finally { + lock.unlock(); } }