瀏覽代碼

commit 9c3478b489569053636ebc2a7132d4af9ad17056
Author: Devaraj Das <ddas@yahoo-inc.com>
Date: Fri Feb 19 23:55:25 2010 -0800

HADOOP:6572 from https://issues.apache.org/jira/secure/attachment/12436421/6572-bp20.patch

+++ b/YAHOO-CHANGES.txt
+ HADOOP-6572. Makes sure that SASL encryption and push to responder queue for the
+ RPC response happens atomically. (Kan Zhang via ddas)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077184 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 年之前
父節點
當前提交
5a568531bc
共有 1 個文件被更改,包括 13 次插入7 次删除
  1. 13 7
      src/core/org/apache/hadoop/ipc/Server.java

+ 13 - 7
src/core/org/apache/hadoop/ipc/Server.java

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