|
@@ -112,6 +112,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.ReflectionUtils;
|
|
|
import org.apache.hadoop.util.StringUtils;
|
|
@@ -632,10 +633,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;
|
|
|
}
|
|
@@ -645,6 +652,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!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -859,8 +869,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
|
|
|
+ Call call = (Call)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);
|