瀏覽代碼

commit 141fe63b4f81032ad6966b1dfe96da71aa7cc50d
Author: Devaraj Das <ddas@yahoo-inc.com>
Date: Sun Sep 19 23:39:14 2010 -0700

. Makes the reloginFromKeytab synchronized on the UGI. Contributed by Owen O'Malley.

+++ b/YAHOO-CHANGES.txt
+ . Makes the reloginFromKeytab synchronized on the UGI
+ class. (Owen O'Malley via ddas)
+


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

Owen O'Malley 14 年之前
父節點
當前提交
2b0cba4f8f
共有 1 個文件被更改,包括 16 次插入14 次删除
  1. 16 14
      src/core/org/apache/hadoop/security/UserGroupInformation.java

+ 16 - 14
src/core/org/apache/hadoop/security/UserGroupInformation.java

@@ -691,20 +691,22 @@ public class UserGroupInformation {
     long start = 0;
     try {
       LOG.info("Initiating logout for " + getUserName());
-      //clear up the kerberos state. But the tokens are not cleared! As per 
-      //the Java kerberos login module code, only the kerberos credentials
-      //are cleared
-      login.logout();
-      //login and also update the subject field of this instance to 
-      //have the new credentials (pass it to the LoginContext constructor)
-      login = 
-        new LoginContext(HadoopConfiguration.KEYTAB_KERBEROS_CONFIG_NAME, 
-            getSubject());
-      LOG.info("Initiating re-login for " + keytabPrincipal);
-      start = System.currentTimeMillis();
-      login.login();
-      metrics.addLoginSuccess(System.currentTimeMillis() - start);
-      setLogin(login);
+      synchronized (UserGroupInformation.class) {
+        //clear up the kerberos state. But the tokens are not cleared! As per 
+        //the Java kerberos login module code, only the kerberos credentials
+        //are cleared
+        login.logout();
+        //login and also update the subject field of this instance to 
+        //have the new credentials (pass it to the LoginContext constructor)
+        login = 
+          new LoginContext(HadoopConfiguration.KEYTAB_KERBEROS_CONFIG_NAME, 
+                           getSubject());
+        LOG.info("Initiating re-login for " + keytabPrincipal);
+        start = System.currentTimeMillis();
+        login.login();
+        metrics.addLoginSuccess(System.currentTimeMillis() - start);
+        setLogin(login);
+      }
     } catch (LoginException le) {
       if (start > 0) {
         metrics.addLoginFailure(System.currentTimeMillis() - start);