You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2007/03/31 09:34:02 UTC
svn commit: r524383 - in /tomcat/connectors/trunk/jni/native:
os/win32/system.c src/jnilib.c
Author: mturk
Date: Sat Mar 31 00:34:01 2007
New Revision: 524383
URL: http://svn.apache.org/viewvc?view=rev&rev=524383
Log:
Never call apr_terminate from DLL main, because it will crash the JVM. Call apr_terminate in Library.terminate instead.
Modified:
tomcat/connectors/trunk/jni/native/os/win32/system.c
tomcat/connectors/trunk/jni/native/src/jnilib.c
Modified: tomcat/connectors/trunk/jni/native/os/win32/system.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/os/win32/system.c?view=diff&rev=524383&r1=524382&r2=524383
==============================================================================
--- tomcat/connectors/trunk/jni/native/os/win32/system.c (original)
+++ tomcat/connectors/trunk/jni/native/os/win32/system.c Sat Mar 31 00:34:01 2007
@@ -111,8 +111,6 @@
* or FreeLibrary.
*/
case DLL_PROCESS_DETACH:
- /* Make sure the library is always terminated */
- apr_terminate();
if (h_kernel)
FreeLibrary(h_kernel);
if (h_ntdll)
Modified: tomcat/connectors/trunk/jni/native/src/jnilib.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/src/jnilib.c?view=diff&rev=524383&r1=524382&r2=524383
==============================================================================
--- tomcat/connectors/trunk/jni/native/src/jnilib.c (original)
+++ tomcat/connectors/trunk/jni/native/src/jnilib.c Sat Mar 31 00:34:01 2007
@@ -93,7 +93,6 @@
#else
tcn_parent_pid = getppid();
#endif
- apr_initialize();
return JNI_VERSION_1_4;
}
@@ -109,10 +108,12 @@
if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2)) {
return;
}
- TCN_UNLOAD_CLASS(env, jString_class);
- TCN_UNLOAD_CLASS(env, jFinfo_class);
- TCN_UNLOAD_CLASS(env, jAinfo_class);
- apr_terminate();
+ if (tcn_global_pool) {
+ TCN_UNLOAD_CLASS(env, jString_class);
+ TCN_UNLOAD_CLASS(env, jFinfo_class);
+ TCN_UNLOAD_CLASS(env, jAinfo_class);
+ apr_terminate();
+ }
}
jstring tcn_new_stringn(JNIEnv *env, const char *str, size_t l)
@@ -221,6 +222,7 @@
UNREFERENCED_STDARGS;
if (!tcn_global_pool) {
+ apr_initialize();
if (apr_pool_create(&tcn_global_pool, NULL) != APR_SUCCESS) {
return JNI_FALSE;
}
@@ -233,18 +235,20 @@
{
UNREFERENCED_STDARGS;
- if (tcn_global_pool) {
+ if (tcn_global_pool) {
+ apr_pool_t *p = tcn_global_pool;
+ tcn_global_pool = NULL;
#ifdef TCN_DO_STATISTICS
fprintf(stderr, "APR Statistical data ....\n");
#endif
- apr_pool_destroy(tcn_global_pool);
- tcn_global_pool = NULL;
+ apr_pool_destroy(p);
#ifdef TCN_DO_STATISTICS
sp_poll_dump_statistics();
sp_network_dump_statistics();
ssl_network_dump_statistics();
fprintf(stderr, "APR Terminated\n");
#endif
+ apr_terminate();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org