You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GitBox <gi...@apache.org> on 2020/02/19 10:15:26 UTC

[GitHub] [tomcat] rmaucher commented on a change in pull request #246: OpenSSLEngine improvements to guard against multiple shutdown() calls triggered by construction exception and finalize() later

rmaucher commented on a change in pull request #246: OpenSSLEngine improvements to guard against multiple shutdown() calls triggered by construction exception and finalize() later
URL: https://github.com/apache/tomcat/pull/246#discussion_r381181675
 
 

 ##########
 File path: java/org/apache/tomcat/util/net/openssl/OpenSSLEngine.java
 ##########
 @@ -219,10 +218,14 @@ public String getNegotiatedProtocol() {
      * Destroys this engine.
      */
     public synchronized void shutdown() {
-        if (!destroyed) {
-            destroyed = true;
-            SSL.freeBIO(networkBIO);
-            SSL.freeSSL(ssl);
+        // Guard against multiple shutdown() calls triggered by construction exception and finalize() later
+        if (destroyed.compareAndSet(false, true)) {
+            if (networkBIO != 0) {
+                SSL.freeBIO(networkBIO);
+            }
+            if (ssl != 0) {
+                SSL.freeSSL(ssl);
+            }
 
 Review comment:
   That's the best part of the change since it could take care of mysterious errors.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org