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 2021/03/11 21:33:26 UTC
[tcl-rivet] branch quattuor updated: fixed bug in rivetInspect:
SingleThreadExit handling was not complete
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
The following commit(s) were added to refs/heads/quattuor by this push:
new b833d97 fixed bug in rivetInspect: SingleThreadExit handling was not complete
b833d97 is described below
commit b833d9722e29900ff76f3bc4eabf23349a114506
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Thu Mar 11 22:33:11 2021 +0100
fixed bug in rivetInspect: SingleThreadExit handling was not complete
---
ChangeLog | 4 +++
src/mod_rivet_ng/mod_rivet_common.c | 30 +++--------------------
src/mod_rivet_ng/mod_rivet_common.h | 2 +-
src/mod_rivet_ng/rivetInspect.c | 2 ++
src/mod_rivet_ng/rivet_lazy_mpm.c | 42 ++++++++++++++++++++++++++------
src/mod_rivet_ng/worker_prefork_common.c | 2 +-
6 files changed, 46 insertions(+), 36 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bbaa408..862d991 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-03-11 Massimo Manghi <mx...@apache.org>
+ * src/mod_rivet_ng/rivetInspect.c: add SingleThreadExit introspection
+ * src7mod_rivet_ng/rivet_lazy_mpm.c: fixed lazy bridge that did not build anymore
+
2020-10-01 Massimo Manghi <mx...@apache.org>
* src/mod_rivet_ng/rivet_prefork_mpm.c: Fixed trivial bug in checking the
rivet cache size
diff --git a/src/mod_rivet_ng/mod_rivet_common.c b/src/mod_rivet_ng/mod_rivet_common.c
index 6bf2de2..64d05b6 100644
--- a/src/mod_rivet_ng/mod_rivet_common.c
+++ b/src/mod_rivet_ng/mod_rivet_common.c
@@ -491,11 +491,10 @@ Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel)
* Arguments:
*
* - apr_pool_t* pPool: parent thread memory pool
- * - bool create_req_obj: the field req (ApacheTcl_Req *) has to be allocate
- * a thread private data structure created during server
- * initialization doesn't need to process any HTTP request
- * That mean the fork based bridge need to allocate it
- * themselves
+ * - bool create_req_obj: the field req (ApacheTcl_Req *) has to be allocated.
+ * Thread private data structures created during server
+ * initialization don't need to process any HTTP request
+ * Prefork based bridges need to allocate it themselves
*
* Returned value:
*
@@ -546,27 +545,6 @@ rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* tPool,bool create_req
}
/*
- * -- Rivet_ExecutionThreadInit
- *
- * We keep here the basic initilization each execution thread should undergo
- *
- * - create the thread private data
- * - create a Tcl channel
- * - set up the Panic procedure
- */
-/*
-rivet_thread_private* Rivet_ExecutionThreadInit (void)
-{
- rivet_thread_private* private = Rivet_CreatePrivateData();
- ap_assert(private != NULL);
- private->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
- Rivet_SetupTclPanicProc();
-
- return private;
-}
-*/
-
-/*
*-----------------------------------------------------------------------------
*
* -- Rivet_SetupTclPanicProc
diff --git a/src/mod_rivet_ng/mod_rivet_common.h b/src/mod_rivet_ng/mod_rivet_common.h
index dc698bb..057d20a 100644
--- a/src/mod_rivet_ng/mod_rivet_common.h
+++ b/src/mod_rivet_ng/mod_rivet_common.h
@@ -35,7 +35,7 @@ EXTERN void Rivet_InitServerVariables (Tcl_Interp *interp, apr_p
EXTERN void Rivet_Panic TCL_VARARGS_DEF (CONST char *, arg1);
EXTERN Tcl_Channel* Rivet_CreateRivetChannel (apr_pool_t* pPool, apr_threadkey_t* rivet_thread_key);
EXTERN rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* pool, bool create_request_obj);
-EXTERN rivet_thread_private* Rivet_ExecutionThreadInit (void);
+// EXTERN rivet_thread_private* Rivet_ExecutionThreadInit (void);
EXTERN rivet_thread_private* Rivet_SetupTclPanicProc (void);
EXTERN void Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel);
EXTERN int Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes);
diff --git a/src/mod_rivet_ng/rivetInspect.c b/src/mod_rivet_ng/rivetInspect.c
index 92d454c..2561bc0 100644
--- a/src/mod_rivet_ng/rivetInspect.c
+++ b/src/mod_rivet_ng/rivetInspect.c
@@ -84,6 +84,7 @@ enum confIndices {
request_handler,
export_rivet_ns,
import_rivet_ns,
+ single_thread_exit,
conf_index_terminator
};
@@ -148,6 +149,7 @@ Rivet_ReadConfParameter ( Tcl_Interp* interp,
case honor_header_only_requests: int_value = Tcl_NewIntObj(rsc->honor_header_only_reqs); break;
case export_rivet_ns: int_value = Tcl_NewIntObj(rsc->export_rivet_ns); break;
case import_rivet_ns: int_value = Tcl_NewIntObj(rsc->import_rivet_ns); break;
+ case single_thread_exit: int_value = Tcl_NewIntObj(module_globals->single_thread_exit); break;
default: return NULL;
}
diff --git a/src/mod_rivet_ng/rivet_lazy_mpm.c b/src/mod_rivet_ng/rivet_lazy_mpm.c
index 5145c45..c295833 100644
--- a/src/mod_rivet_ng/rivet_lazy_mpm.c
+++ b/src/mod_rivet_ng/rivet_lazy_mpm.c
@@ -95,6 +95,31 @@ enum {
#define MOD_RIVET_QUEUE_SIZE 100
+/*
+ * -- Rivet_ExecutionThreadInit
+ *
+ * We keep here the basic initilization each execution thread should undergo
+ *
+ * - create the thread private data
+ * - set up the Panic procedure
+ */
+
+static rivet_thread_private* Rivet_ExecutionThreadInit (apr_thread_t *thd)
+{
+ rivet_thread_private* private;
+ apr_pool_t* tPool;
+
+ apr_thread_mutex_lock(module_globals->mpm->mutex);
+ ap_assert (apr_pool_create(&tPool,apr_thread_pool_get(thd)) == APR_SUCCESS);
+ apr_thread_mutex_unlock(module_globals->mpm->mutex);
+
+ private = Rivet_CreatePrivateData(tPool,true);
+ ap_assert(private != NULL);
+ Rivet_SetupTclPanicProc();
+
+ return private;
+}
+
static void Lazy_RunConfScript (rivet_thread_private* private,lazy_tcl_worker* w,int init)
{
Tcl_Obj* tcl_conf_script;
@@ -155,7 +180,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
/* Rivet_ExecutionThreadInit creates and returns the thread private data. */
- private = Rivet_ExecutionThreadInit();
+ private = Rivet_ExecutionThreadInit(thd);
/* A bridge creates and stores in private->ext its own thread private
* data. The lazy bridge is no exception. We just need a flag controlling
@@ -309,8 +334,9 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server)
module_globals->mpm = apr_pcalloc(pool,sizeof(mpm_bridge_status));
- /* This mutex is only used to consistently carry out these
- * two tasks
+ /* This mutex is only used to consistently carry out modifications
+ * on the module_globals structure that may result in inconsitent
+ * status due to concurrent access.
*
* - set the exit status of a child process (hopefully will be
* unnecessary when Tcl is able again of calling
@@ -318,6 +344,7 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server)
* - control the server_shutdown flag. Actually this is
* not entirely needed because once set this flag
* is never reset to 0
+ * - create thread specific pools of memory
*
*/
@@ -343,8 +370,7 @@ void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server)
rivet_server_conf* rsc = RIVET_SERVER_CONF(s->module_config);
vh = rsc->idx;
- rv = apr_thread_mutex_create(&module_globals->mpm->vhosts[vh].mutex,
- APR_THREAD_MUTEX_UNNESTED,pool);
+ rv = apr_thread_mutex_create(&module_globals->mpm->vhosts[vh].mutex,APR_THREAD_MUTEX_UNNESTED,pool);
ap_assert(rv == APR_SUCCESS);
array = apr_array_make(pool,0,sizeof(void*));
ap_assert(array != NULL);
@@ -431,9 +457,9 @@ int LazyBridge_Request (request_rec* r,rivet_req_ctype ctype)
*
*/
-rivet_thread_interp* LazyBridge_Interp (rivet_thread_private* private,
- rivet_server_conf* conf,
- rivet_thread_interp* interp)
+rivet_thread_interp* LazyBridge_Interp (rivet_thread_private* private,
+ rivet_server_conf* conf,
+ rivet_thread_interp* interp)
{
if (interp != NULL) { private->ext->interp = interp; }
diff --git a/src/mod_rivet_ng/worker_prefork_common.c b/src/mod_rivet_ng/worker_prefork_common.c
index 2dea7c4..2f1ee3f 100644
--- a/src/mod_rivet_ng/worker_prefork_common.c
+++ b/src/mod_rivet_ng/worker_prefork_common.c
@@ -41,7 +41,7 @@ extern DLLIMPORT module rivet_module;
/* -- Rivet_SetupInterps
*
- * The server_rec chain is walked through and server configurations is read to
+ * The server_rec chain is walked through and server configurations are read to
* set up the thread private configuration and interpreters database
*
* Arguments:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org