changeset 10673:90a6fc10a158

8059588: deadlock in java/io/PrintStream when verbose java.security.debug flags are set Reviewed-by: mullan
author coffeys
date Fri, 27 Mar 2015 19:13:47 +0000
parents ae448eca6b54
children 8584626b5570
files src/share/classes/sun/security/pkcs11/SessionManager.java
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/pkcs11/SessionManager.java	Wed Apr 01 13:21:10 2015 -0700
+++ b/src/share/classes/sun/security/pkcs11/SessionManager.java	Fri Mar 27 19:13:47 2015 +0000
@@ -90,6 +90,7 @@
 
     // maximum number of active sessions during this invocation, for debugging
     private int maxActiveSessions;
+    private Object maxActiveSessionsLock;
 
     // flags to use in the C_OpenSession() call
     private final long openSessionFlags;
@@ -113,6 +114,9 @@
         this.token = token;
         this.objSessions = new Pool(this);
         this.opSessions = new Pool(this);
+        if (debug != null) {
+            maxActiveSessionsLock = new Object();
+        }
     }
 
     // returns whether only a fairly low number of sessions are
@@ -212,7 +216,7 @@
         Session session = new Session(token, id);
         activeSessions.incrementAndGet();
         if (debug != null) {
-            synchronized(this) {
+            synchronized(maxActiveSessionsLock) {
                 if (activeSessions.get() > maxActiveSessions) {
                     maxActiveSessions = activeSessions.get();
                     if (maxActiveSessions % 10 == 0) {