costin 02/05/23 21:26:00
Modified: jk/native2/common jk_env.c jk_shm.c
jk/native2/include jk_env.h
Log:
Moved the common code in jk_env. Many components need an aprPool, and assuming
that jk_pool wraps an aprPool is not the cleanest solution.
Revision Changes Path
1.28 +29 -2 jakarta-tomcat-connectors/jk/native2/common/jk_env.c
Index: jk_env.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_env.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- jk_env.c 23 May 2002 14:54:07 -0000 1.27
+++ jk_env.c 24 May 2002 04:26:00 -0000 1.28
@@ -55,10 +55,12 @@
* *
* ========================================================================= */
+#include "jk_global.h"
#include "jk_env.h"
#include "jk_objCache.h"
jk_env_t *jk_env_globalEnv;
+void *jkGlobalAprPool;
/* Private methods
*/
@@ -70,6 +72,29 @@
/* -------------------- Env management -------------------- */
+static void JK_METHOD *jk2_env_getAprPool( jk_env_t *env ) {
+#ifdef HAS_APR
+ /* We don't want to have to recreate the scoreboard after
+ * restarts, so we'll create a global pool and never clean it.
+ */
+ if( jkGlobalAprPool==NULL ) {
+ int rc;
+
+ /* Make sure apr is initialized */
+ apr_initialize();
+ rc = apr_pool_create(( apr_pool_t **)&jkGlobalAprPool, NULL);
+ if (rc != APR_SUCCESS || jkGlobalAprPool==NULL ) {
+ env->l->jkLog(env, env->l, JK_LOG_ERROR,
+ "Unable to create global apr pool\n");
+ return NULL;
+ }
+ }
+ return jkGlobalAprPool;
+#else
+ return NULL;
+#endif
+}
+
/** Public method, creates/get the global env
*/
jk_env_t* JK_METHOD jk2_env_getEnv( char *id, jk_pool_t *pool ) {
@@ -109,7 +134,8 @@
env->releaseEnv= parentEnv->releaseEnv;
env->jkClearException=parentEnv->jkClearException;
env->jkException=parentEnv->jkException;
-
+ env->getAprPool=parentEnv->getAprPool;
+
env->_registry=parentEnv->_registry;
env->_objects=parentEnv->_objects;
env->l=parentEnv->l;
@@ -393,7 +419,7 @@
"env.registerFactory(): NullPointerException\n");
return;
}
- env->_registry->put( env, env->_registry, type, fact, NULL );
+ env->_registry->put( env, env->_registry, (char *)type, (void *)fact, NULL );
}
/* -------------------- Exceptions -------------------- */
@@ -457,6 +483,7 @@
env->debug = 0;
env->jkClearException=jk_env_jkClearException;
env->jkException=jk_env_jkException;
+ env->getAprPool=jk2_env_getAprPool;
env->id=0;
1.19 +11 -14 jakarta-tomcat-connectors/jk/native2/common/jk_shm.c
Index: jk_shm.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_shm.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- jk_shm.c 19 May 2002 17:37:08 -0000 1.18
+++ jk_shm.c 24 May 2002 04:26:00 -0000 1.19
@@ -81,7 +81,6 @@
#include "apr_file_io.h"
#include "apr_file_info.h"
#include "apr_general.h"
-static apr_pool_t *globalShmPool;
#elif defined(HAVE_MMAP) && !defined(WIN32)
@@ -117,20 +116,13 @@
apr_file_t *file;
apr_finfo_t finfo;
apr_mmap_t *aprMmap;
+ apr_pool_t *globalShmPool;
+
+ globalShmPool= (apr_pool_t *)env->getAprPool( env );
+
+ if( globalShmPool==NULL )
+ return JK_FALSE;
- /* We don't want to have to recreate the scoreboard after
- * restarts, so we'll create a global pool and never clean it.
- */
- if( globalShmPool==NULL ) {
- /* Make sure apr is initialized */
- apr_initialize();
- rc = apr_pool_create(&globalShmPool, NULL);
- if (rc != APR_SUCCESS || globalShmPool==NULL ) {
- env->l->jkLog(env, env->l, JK_LOG_ERROR,
- "Unable to create global pool for jk_shm\n");
- return rc;
- }
- }
/* First make sure the file exists and is big enough
*/
@@ -331,6 +323,11 @@
if( shm->size == 0 ) {
shm->size = shm->slotSize * shm->slotMaxCount;
+ }
+
+ if( shm->mbean->debug > 0 ) {
+ env->l->jkLog(env, env->l, JK_LOG_INFO, "shm.init(): file=%s size=%d\n",
+ shm->fname, shm->size);
}
if( shm->size <= 0 ) {
1.16 +5 -2 jakarta-tomcat-connectors/jk/native2/include/jk_env.h
Index: jk_env.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_env.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- jk_env.h 8 May 2002 23:47:27 -0000 1.15
+++ jk_env.h 24 May 2002 04:26:00 -0000 1.16
@@ -218,7 +218,10 @@
*/
void (JK_METHOD *registerFactory)( jk_env_t *env, const char *type,
jk_env_objectFactory_t factory);
-
+
+ /** If APR is used, return a global pool
+ */
+ void *(JK_METHOD *getAprPool)(jk_env_t *env );
/* private */
struct jk_map *_registry;
@@ -231,7 +234,7 @@
void JK_METHOD jk2_registry_init(jk_env_t *env);
-
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>