HADOOP-11780. Prevent IPC reader thread death. Contributed by Daryn Sharp.
This commit is contained in:
parent
9b0fd01d2e
commit
e19b37ead2
|
@ -110,6 +110,7 @@ import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
|
|||
import org.apache.hadoop.security.token.SecretManager;
|
||||
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
||||
import org.apache.hadoop.security.token.TokenIdentifier;
|
||||
import org.apache.hadoop.util.ExitUtil;
|
||||
import org.apache.hadoop.util.ProtoUtil;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.util.Time;
|
||||
|
@ -956,10 +957,16 @@ public abstract class Server {
|
|||
while (iter.hasNext()) {
|
||||
key = iter.next();
|
||||
iter.remove();
|
||||
if (key.isValid()) {
|
||||
try {
|
||||
if (key.isReadable()) {
|
||||
doRead(key);
|
||||
}
|
||||
} catch (CancelledKeyException cke) {
|
||||
// something else closed the connection, ex. responder or
|
||||
// the listener doing an idle scan. ignore it and let them
|
||||
// clean up.
|
||||
LOG.info(Thread.currentThread().getName() +
|
||||
": connection aborted from " + key.attachment());
|
||||
}
|
||||
key = null;
|
||||
}
|
||||
|
@ -969,6 +976,9 @@ public abstract class Server {
|
|||
}
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Error in Reader", ex);
|
||||
} catch (Throwable re) {
|
||||
LOG.fatal("Bug in read selector!", re);
|
||||
ExitUtil.terminate(1, "Bug in read selector!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1187,8 +1197,17 @@ public abstract class Server {
|
|||
SelectionKey key = iter.next();
|
||||
iter.remove();
|
||||
try {
|
||||
if (key.isValid() && key.isWritable()) {
|
||||
doAsyncWrite(key);
|
||||
if (key.isWritable()) {
|
||||
doAsyncWrite(key);
|
||||
}
|
||||
} catch (CancelledKeyException cke) {
|
||||
// something else closed the connection, ex. reader or the
|
||||
// listener doing an idle scan. ignore it and let them clean
|
||||
// up
|
||||
RpcCall call = (RpcCall)key.attachment();
|
||||
if (call != null) {
|
||||
LOG.info(Thread.currentThread().getName() +
|
||||
": connection aborted from " + call.connection);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.info(Thread.currentThread().getName() + ": doAsyncWrite threw exception " + e);
|
||||
|
|
Loading…
Reference in New Issue