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

This commit is contained in:
Colin Patrick Mccabe 2014-10-06 14:40:41 -07:00
parent 3affad9ebd
commit 8099de259f
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -101,6 +101,7 @@ public interface Handler {
*/
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 boolean handle(DomainSocket sock) {
}
closed = true;
return true;
} finally {
lock.unlock();
}
}
}
@ -346,12 +349,15 @@ public void remove(DomainSocket sock) {
* 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();
}
}