HADOOP-6572. Makes sure that SASL encryption and push to responder queue for the RPC response happens atomically. Contributed by Kan Zhang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@911748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2010-02-19 09:04:47 +00:00
parent a417a8faea
commit d099c1c78a
2 changed files with 18 additions and 10 deletions

View File

@ -217,6 +217,9 @@ Trunk (unreleased changes)
HADOOP-6558. Return null in HarFileSystem.getFileChecksum(..) since no HADOOP-6558. Return null in HarFileSystem.getFileChecksum(..) since no
checksum algorithm is implemented. (szetszwo) checksum algorithm is implemented. (szetszwo)
HADOOP-6572. Makes sure that SASL encryption and push to responder
queue for the RPC response happens atomically. (Kan Zhang via ddas)
Release 0.21.0 - Unreleased Release 0.21.0 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1198,17 +1198,22 @@ public abstract class Server {
error = StringUtils.stringifyException(e); error = StringUtils.stringifyException(e);
} }
CurCall.set(null); CurCall.set(null);
setupResponse(buf, call, synchronized (call.connection.responseQueue) {
(error == null) ? Status.SUCCESS : Status.ERROR, // setupResponse() needs to be sync'ed together with
value, errorClass, error); // responder.doResponse() since setupResponse may use
// Discard the large buf and reset it back to // SASL to encrypt response data and SASL enforces
// smaller size to freeup heap // its own message ordering.
if (buf.size() > MAX_RESP_BUF_SIZE) { setupResponse(buf, call, (error == null) ? Status.SUCCESS
LOG.warn("Large response size " + buf.size() + " for call " + : Status.ERROR, value, errorClass, error);
call.toString()); // Discard the large buf and reset it back to
buf = new ByteArrayOutputStream(INITIAL_RESP_BUF_SIZE); // smaller size to freeup heap
if (buf.size() > MAX_RESP_BUF_SIZE) {
LOG.warn("Large response size " + buf.size() + " for call "
+ call.toString());
buf = new ByteArrayOutputStream(INITIAL_RESP_BUF_SIZE);
}
responder.doRespond(call);
} }
responder.doRespond(call);
} catch (InterruptedException e) { } catch (InterruptedException e) {
if (running) { // unexpected -- log it if (running) { // unexpected -- log it
LOG.info(getName() + " caught: " + LOG.info(getName() + " caught: " +