changeset 13280:6e07aec955f6

8141651: Deadlock in sun.security.ssl.SSLSocketImpl Reviewed-by: weijun
author xuelei
date Wed, 09 Dec 2015 10:36:33 +0000
parents e6c3d2856593
children 8418f5ee381d
files src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Dec 08 13:48:22 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Wed Dec 09 10:36:33 2015 +0000
@@ -766,17 +766,27 @@
         // records, so this also increases robustness.
         //
         if (length > 0) {
+            IOException ioe = null;
+            byte description = 0;    // 0: never used, make the compiler happy
             writeLock.lock();
             try {
                 outputRecord.deliver(source, offset, length);
             } catch (SSLHandshakeException she) {
                 // may be record sequence number overflow
-                fatal(Alerts.alert_handshake_failure, she);
+                description = Alerts.alert_handshake_failure;
+                ioe = she;
             } catch (IOException e) {
-                fatal(Alerts.alert_unexpected_message, e);
+                description = Alerts.alert_unexpected_message;
+                ioe = e;
             } finally {
                 writeLock.unlock();
             }
+
+            // Be care of deadlock. Please don't place the call to fatal()
+            // into the writeLock locked block.
+            if (ioe != null) {
+                fatal(description, ioe);
+            }
         }
 
         /*