This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 587389580e Revert most of the changes for Native library stability 587389580e is described below commit 587389580eefeefe4c1a0f1aa676fcd051d27e8c Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Feb 9 14:06:57 2024 +0000 Revert most of the changes for Native library stability Further investigation indicates these changes were not necessary --- .../apache/catalina/core/AprLifecycleListener.java | 3 +-- java/org/apache/tomcat/jni/Library.java | 23 +--------------------- .../tomcat/util/net/openssl/OpenSSLContext.java | 19 ++++++++---------- test/org/apache/tomcat/util/net/TesterSupport.java | 1 - webapps/docs/changelog.xml | 4 ---- 5 files changed, 10 insertions(+), 40 deletions(-) diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java b/java/org/apache/catalina/core/AprLifecycleListener.java index 8fea80148e..f1621ff7e7 100644 --- a/java/org/apache/catalina/core/AprLifecycleListener.java +++ b/java/org/apache/catalina/core/AprLifecycleListener.java @@ -169,11 +169,10 @@ public class AprLifecycleListener implements LifecycleListener { } private static void terminateAPR() { - Library.terminatePrepare(); AprStatus.setAprInitialized(false); AprStatus.setAprAvailable(false); fipsModeActive = false; - sslInitialized = false; // Well we cleaned the pool in terminate. + sslInitialized = false; // terminate() will clean the pool Library.terminate(); } diff --git a/java/org/apache/tomcat/jni/Library.java b/java/org/apache/tomcat/jni/Library.java index 908a9a8b56..a7686c0935 100644 --- a/java/org/apache/tomcat/jni/Library.java +++ b/java/org/apache/tomcat/jni/Library.java @@ -29,8 +29,6 @@ public final class Library { */ private static Library _instance = null; - private static volatile boolean initialized = false; - private Library() throws Exception { boolean loaded = false; StringBuilder err = new StringBuilder(); @@ -103,22 +101,9 @@ public final class Library { * Create Tomcat Native's global APR pool. This has to be the first call to TCN library. */ private static native boolean initialize(); - /** - * Signal that Tomcat Native is about to be shutdown. - * <p> - * The main purpose of this flag is to allow instances that manage their own APR root pools to determine if those - * pools need to be explicitly cleaned up or if they will be / have been cleaned up by the call to - * {@link #terminate()}. The code needs to avoid multiple attempts to clean up these pools else the Native code may - * crash. - */ - public static void terminatePrepare() { - initialized = false; - } /** * Destroys Tomcat Native's global APR pool. This has to be the last call to TCN library. This will destroy any APR * root pools that have not been explicitly destroyed. - * <p> - * Callers of this method should call {@link #terminatePrepare()} before calling this method. */ public static native void terminate(); /* Internal function for loading APR Features */ @@ -177,12 +162,6 @@ public final class Library { aprVersionString() + ")"); } } - initialized = initialize(); - return initialized; - } - - - public static boolean isInitialized() { - return initialized; + return initialize(); } } diff --git a/java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java b/java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java index 12dc41455b..f1d7b092ec 100644 --- a/java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java +++ b/java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java @@ -46,7 +46,6 @@ import javax.net.ssl.X509TrustManager; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.jni.CertificateVerifier; -import org.apache.tomcat.jni.Library; import org.apache.tomcat.jni.Pool; import org.apache.tomcat.jni.SSL; import org.apache.tomcat.jni.SSLConf; @@ -649,16 +648,14 @@ public class OpenSSLContext implements org.apache.tomcat.util.net.SSLContext { @Override public void run() { - if (Library.isInitialized()) { - if (ctx != 0) { - SSLContext.free(ctx); - } - if (cctx != 0) { - SSLConf.free(cctx); - } - if (aprPool != 0) { - Pool.destroy(aprPool); - } + if (ctx != 0) { + SSLContext.free(ctx); + } + if (cctx != 0) { + SSLConf.free(cctx); + } + if (aprPool != 0) { + Pool.destroy(aprPool); } } } diff --git a/test/org/apache/tomcat/util/net/TesterSupport.java b/test/org/apache/tomcat/util/net/TesterSupport.java index a9b32fdc50..5d56e49989 100644 --- a/test/org/apache/tomcat/util/net/TesterSupport.java +++ b/test/org/apache/tomcat/util/net/TesterSupport.java @@ -108,7 +108,6 @@ public final class TesterSupport { Library.initialize(null); available = true; version = SSL.version(); - Library.terminatePrepare(); Library.terminate(); } catch (Exception | LibraryNotFoundError ex) { err = ex.getMessage(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 5f742e45f5..61c67f700d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -171,10 +171,6 @@ configured on <code>SSLHostConfigCertificate</code> instances. Based on pull request <pr>673</pr> provided by Hakan Altındağ. (markt) </fix> - <fix> - Improve the Tomcat Native shutdown process to reduce the likelihood of a - JVM crash during Tomcat shutdown. (markt) - </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org