HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected by the lock (cmccabe)
(cherry picked from commit 8099de259f
)
This commit is contained in:
parent
e5e9cf219a
commit
c97134d054
|
@ -15,6 +15,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
HADOOP-10404. Some accesses to DomainSocketWatcher#closed are not protected
|
||||||
|
by the lock (cmccabe)
|
||||||
|
|
||||||
Release 2.6.0 - UNRELEASED
|
Release 2.6.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -101,6 +101,7 @@ public final class DomainSocketWatcher implements Closeable {
|
||||||
*/
|
*/
|
||||||
private class NotificationHandler implements Handler {
|
private class NotificationHandler implements Handler {
|
||||||
public boolean handle(DomainSocket sock) {
|
public boolean handle(DomainSocket sock) {
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
LOG.trace(this + ": NotificationHandler: doing a read on " +
|
LOG.trace(this + ": NotificationHandler: doing a read on " +
|
||||||
|
@ -124,6 +125,8 @@ public final class DomainSocketWatcher implements Closeable {
|
||||||
}
|
}
|
||||||
closed = true;
|
closed = true;
|
||||||
return true;
|
return true;
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,12 +349,15 @@ public final class DomainSocketWatcher implements Closeable {
|
||||||
* Wake up the DomainSocketWatcher thread.
|
* Wake up the DomainSocketWatcher thread.
|
||||||
*/
|
*/
|
||||||
private void kick() {
|
private void kick() {
|
||||||
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
notificationSockets[0].getOutputStream().write(0);
|
notificationSockets[0].getOutputStream().write(0);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
LOG.error(this + ": error writing to notificationSockets[0]", e);
|
LOG.error(this + ": error writing to notificationSockets[0]", e);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue