You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/02/09 14:09:15 UTC
(tomcat) branch 10.1.x updated: Revert most of the changes for Native library stability
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new b2fbf15e35 Revert most of the changes for Native library stability
b2fbf15e35 is described below
commit b2fbf15e3572ff5ffd16d68346d129e09fd11e9a
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 590f1b19d9..78a0bfd39e 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 5bf884b393..03eb1d9bb9 100644
--- a/test/org/apache/tomcat/util/net/TesterSupport.java
+++ b/test/org/apache/tomcat/util/net/TesterSupport.java
@@ -105,7 +105,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 118a42eba2..01a21ef39a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,10 +160,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org