You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/06/01 10:15:16 UTC
[tcl-rivet] 04/05: add RivetCache_Destroy,
more efficient cache regeneration by clearing the interpreter pool,
instead of destroying to recreate it
This is an automated email from the ASF dual-hosted git repository.
mxmanghi pushed a commit to branch quattuor
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
commit 5fd624fd549d4d77f31a3d067bd4c8522e142b2b
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 12:00:06 2019 +0200
add RivetCache_Destroy, more efficient cache regeneration by clearing the interpreter pool, instead of destroying to recreate it
---
src/mod_rivet_ng/mod_rivet_cache.c | 56 ++++++++++++++++++++++++--------------
src/mod_rivet_ng/mod_rivet_cache.h | 3 +-
2 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/src/mod_rivet_ng/mod_rivet_cache.c b/src/mod_rivet_ng/mod_rivet_cache.c
index 721c8d9..732e31e 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.c
+++ b/src/mod_rivet_ng/mod_rivet_cache.c
@@ -51,17 +51,45 @@ extern mod_rivet_globals* module_globals;
*
*/
-void RivetCache_Create (apr_pool_t *p, rivet_thread_interp* interp_obj)
+void RivetCache_Create (rivet_thread_interp* interp_obj)
{
- interp_obj->objCacheList =
- apr_pcalloc(p,(signed)((interp_obj->cache_size)*sizeof(char *)));
- interp_obj->objCache =
- apr_pcalloc(p,sizeof(Tcl_HashTable));
+ interp_obj->objCacheList = apr_pcalloc(interp_obj->pool,(signed)((interp_obj->cache_size)*sizeof(char *)));
+ interp_obj->objCache = apr_pcalloc(interp_obj->pool,sizeof(Tcl_HashTable));
Tcl_InitHashTable(interp_obj->objCache,TCL_STRING_KEYS);
}
/*
+ * -- RivetCache_Destroy
+ *
+ *
+ */
+
+void RivetCache_Destroy (rivet_thread_private* private,rivet_thread_interp* rivet_interp)
+{
+ int ct;
+ Tcl_HashEntry *delEntry;
+
+ /* Clean out the list. */
+ ct = rivet_interp->cache_free;
+ while (ct < rivet_interp->cache_size) {
+ /* Free the corresponding hash entry. */
+ delEntry = Tcl_FindHashEntry(rivet_interp->objCache,
+ rivet_interp->objCacheList[ct]);
+
+ if (delEntry != NULL) {
+ Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
+ Tcl_DeleteHashEntry(delEntry);
+ rivet_interp->objCacheList[ct] = NULL;
+ }
+
+ ct++;
+ }
+ apr_pool_destroy(rivet_interp->pool);
+}
+
+
+/*
* -- RivetCache_Cleanup
*
* Cache clean-up. This function is called when a user configuration
@@ -99,23 +127,11 @@ void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rive
ct++;
}
- apr_pool_destroy(rivet_interp->pool);
+ apr_pool_clear(rivet_interp->pool);
- /* let's recreate the cache list */
+ rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool,(signed)(rivet_interp->cache_size*sizeof(char *)));
+ rivet_interp->cache_free = rivet_interp->cache_size;
- if (apr_pool_create(&rivet_interp->pool, private->pool) != APR_SUCCESS)
- {
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server,
- MODNAME ": could not recreate cache private pool. Cache disabled");
- rivet_interp->cache_free = rivet_interp->cache_size = 0;
- }
- else
- {
- rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool,
- (signed)(rivet_interp->cache_size*sizeof(char *)));
- rivet_interp->cache_free = rivet_interp->cache_size;
- }
-
}
/*
diff --git a/src/mod_rivet_ng/mod_rivet_cache.h b/src/mod_rivet_ng/mod_rivet_cache.h
index 2f54827..4e830d4 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.h
+++ b/src/mod_rivet_ng/mod_rivet_cache.h
@@ -21,7 +21,8 @@
#ifndef __mod_rivet_cache_h__
#define __mod_rivet_cache_h__
-EXTERN void RivetCache_Create (apr_pool_t *p, rivet_thread_interp* interp_obj);
+EXTERN void RivetCache_Create (rivet_thread_interp* interp_obj);
+EXTERN void RivetCache_Destroy (rivet_thread_private* private,rivet_thread_interp* rivet_interp);
EXTERN void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rivet_interp);
EXTERN char* RivetCache_MakeKey (apr_pool_t* pool, char* filename,
time_t ctime,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org