Repository: hadoop
Updated Branches:
  refs/heads/branch-2.6 522b6505f -> 204148f0d


HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected by 
the lock (cmccabe)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/204148f0
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/204148f0
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/204148f0

Branch: refs/heads/branch-2.6
Commit: 204148f0d4373cbda617a0013704ac1b98afee6c
Parents: 522b650
Author: Colin Patrick Mccabe <[email protected]>
Authored: Mon Oct 6 14:40:41 2014 -0700
Committer: Colin Patrick Mccabe <[email protected]>
Committed: Wed Oct 8 13:58:28 2014 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt    |  3 +++
 .../hadoop/net/unix/DomainSocketWatcher.java       | 17 ++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/204148f0/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt 
b/hadoop-common-project/hadoop-common/CHANGES.txt
index f313aef..c63051e 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -447,6 +447,9 @@ Release 2.6.0 - UNRELEASED
     HADOOP-11169. Fix DelegationTokenAuthenticatedURL to pass the connection
     Configurator to the authenticator. (Arun Suresh via wang)
 
+    HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected
+    by lock (cmccabe)
+
     BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
   
       HADOOP-10734. Implement high-performance secure random number sources.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/204148f0/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java
----------------------------------------------------------------------
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 8348aeb..95ef30d 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) {
+      assert(lock.isHeldByCurrentThread());
       try {
         if (LOG.isTraceEnabled()) {
           LOG.trace(this + ": NotificationHandler: doing a read on " +
@@ -346,6 +347,7 @@ public final class DomainSocketWatcher implements Closeable 
{
    * Wake up the DomainSocketWatcher thread.
    */
   private void kick() {
+    assert(lock.isHeldByCurrentThread());
     try {
       notificationSockets[0].getOutputStream().write(0);
     } catch (IOException e) {
@@ -461,12 +463,17 @@ public final class DomainSocketWatcher implements 
Closeable {
       } catch (IOException e) {
         LOG.error(toString() + " terminating on IOException", e);
       } finally {
-        kick(); // allow the handler for notificationSockets[0] to read a byte
-        for (Entry entry : entries.values()) {
-          sendCallback("close", entries, fdSet, entry.getDomainSocket().fd);
+        lock.lock();
+        try {
+          kick(); // allow the handler for notificationSockets[0] to read a 
byte
+          for (Entry entry : entries.values()) {
+            sendCallback("close", entries, fdSet, entry.getDomainSocket().fd);
+          }
+          entries.clear();
+          fdSet.close();
+        } finally {
+          lock.unlock();
         }
-        entries.clear();
-        fdSet.close();
       }
     }
   });

Reply via email to