This is an automated email from the ASF dual-hosted git repository. mxmanghi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
The following commit(s) were added to refs/heads/master by this push: new 9f060cd * doc/xml/lazybridge.xml: update examples with latest modifications done to the lazy bridge 9f060cd is described below commit 9f060cd5995db14a1a0099b01e9eb2fab625db18 Author: Massimo Manghi <massimo.man...@gmail.com> AuthorDate: Fri Nov 5 11:52:47 2021 +0100 * doc/xml/lazybridge.xml: update examples with latest modifications done to the lazy bridge --- ChangeLog | 7 +++-- doc/xml/lazybridge.xml | 79 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b61886..c6a96ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2021-11-05 Massimo Manghi <mxman...@apache.org> + * doc/xml/lazybridge.xml: update examples with latest modifications done to the lazy bridge + 2021-11-04 Massimo Manghi <mxman...@apache.org> * doc/xml/installation.xml: documenting new configure switch --enable-rivet-debug-build @@ -7,11 +10,11 @@ * tests/env.test: cleaning up http tokens resources 2021-11-01 Massimo Manghi <mxman...@apache.org> - * src/mod_rivet_ng/Tclwebapache.c: expanded comments to newly + * src/mod_rivet_ng/TclWebapache.c: expanded comments to newly introduced functions 2021-10-25 Massimo Manghi <mxman...@apache.org> - * src/mod_rivet_ng/Tclwebapache.c: extended comments + * src/mod_rivet_ng/TclWebapache.c: extended comments * src/rivet.h: new macro MINSTRLEN 2021-10-20 Massimo Manghi <mxman...@apache.org> diff --git a/doc/xml/lazybridge.xml b/doc/xml/lazybridge.xml index 9b88f65..6e18c04 100644 --- a/doc/xml/lazybridge.xml +++ b/doc/xml/lazybridge.xml @@ -46,12 +46,12 @@ </para> <programlisting>RIVET_MPM_BRIDGE { - NULL, - Lazy_MPM_ChildInit, - Lazy_MPM_Request, - Lazy_MPM_Finalize, - Lazy_MPM_ExitHandler, - Lazy_MPM_Interp + LazyBridge_ServerInit, + LazyBridge_ChildInit, + LazyBridge_Request, + LazyBridge_Finalize, + LazyBridge_ExitHandler, + LazyBridge_Interp };</programlisting> <para> @@ -62,10 +62,9 @@ The lazy bridge keeps an array of virtual host descriptor pointers each of them referencing an instance of the following structure. </para> - <programlisting>/* virtual host descriptor */ + <programlisting>/* virtual host thread queue descriptor */ typedef struct vhost_iface { - int idle_threads_cnt; /* idle threads for the virtual hosts */ int threads_count; /* total number of running and idle threads */ apr_thread_mutex_t* mutex; /* mutex protecting 'array' */ apr_array_header_t* array; /* LIFO array of lazy_tcl_worker pointers */ @@ -84,6 +83,22 @@ typedef struct mpm_bridge_status { int server_shutdown; /* the child process is shutting down */ vhost* vhosts; /* array of vhost descriptors */ } mpm_bridge_status;</programlisting> + + <para> + The lazy bridge also extends the thread private data structure with the + data concerning the Tcl intepreter, its configuration and + </para> + + <programlisting>/* lazy bridge thread private data extension */ + +typedef struct mpm_bridge_specific { + rivet_thread_interp* interp; /* thread Tcl interpreter object */ + int keep_going; /* thread loop controlling variable */ + /* the request_rec and TclWebRequest * + * are copied here to be passed to a * + * channel */ +} mpm_bridge_specific;</programlisting> + <para> By design the bridge must create exactly one instance of <command>mpm_bridge_status</command> and store its pointer in <command>module_globals->mpm</command>. @@ -93,14 +108,14 @@ typedef struct mpm_bridge_status { function </para> <programlisting>/* - * -- Lazy_MPM_ChildInit + * -- LazyBridge_ChildInit * * child process initialization. This function prepares the process * data structures for virtual hosts and threads management * */ -void Lazy_MPM_ChildInit (apr_pool_t* pool, server_rec* server) +void LazyBridge_ChildInit (apr_pool_t* pool, server_rec* server) { apr_status_t rv; server_rec* s; @@ -138,19 +153,18 @@ void Lazy_MPM_ChildInit (apr_pool_t* pool, server_rec* server) for (s = root_server; s != NULL; s = s->next) { - int vh; + int idx; apr_array_header_t* array; rivet_server_conf* rsc = RIVET_SERVER_CONF(s->module_config); - vh = rsc->idx; - rv = apr_thread_mutex_create(&module_globals->mpm->vhosts[vh].mutex, + idx = rsc->idx; + rv = apr_thread_mutex_create(&module_globals->mpm->vhosts[idx].mutex, APR_THREAD_MUTEX_UNNESTED,pool); ap_assert(rv == APR_SUCCESS); array = apr_array_make(pool,0,sizeof(void*)); ap_assert(array != NULL); - module_globals->mpm->vhosts[vh].array = array; - module_globals->mpm->vhosts[vh].idle_threads_cnt = 0; - module_globals->mpm->vhosts[vh].threads_count = 0; + module_globals->mpm->vhosts[idx].array = array; + module_globals->mpm->vhosts[idx].threads_count = 0; } module_globals->mpm->server_shutdown = 0; }</programlisting> @@ -219,8 +233,7 @@ typedef struct lazy_tcl_worker { request_rec* r; int ctype; int ap_sts; - int nreqs; - rivet_server_conf* conf; /* rivet_server_conf* record */ + rivet_server_conf* conf; /* rivet_server_conf* record */ } lazy_tcl_worker;</programlisting> <para> The server field is assigned with the virtual host server record. Whereas the <command>conf</command> @@ -321,7 +334,7 @@ int Lazy_MPM_Request (request_rec* r,rivet_req_ctype ctype) * The lazy bridge worker thread. This thread prepares its control data and * will serve requests addressed to a given virtual host. Virtual host server * data are stored in the lazy_tcl_worker structure stored in the generic - * pointer argument 'data' + * pointer argument 'data' * */ @@ -346,11 +359,12 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific)); private->ext->keep_going = 1; - private->ext->interp = Rivet_NewVHostInterp(private->pool,w->server); + //private->ext->interp = Rivet_NewVHostInterp(private->pool,w->server); + RIVET_POKE_INTERP(private,rsc,Rivet_NewVHostInterp(private->pool,rsc->default_cache_size)); private->ext->interp->channel = private->channel; /* The worker thread can respond to a single request at a time therefore - * must handle and register its own Rivet channel */ + must handle and register its own Rivet channel */ Tcl_RegisterChannel(private->ext->interp->interp,*private->channel); @@ -365,22 +379,29 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) Rivet_PerInterpInit(private->ext->interp,private,w->server,private->pool); /* The child initialization is fired. Beware of the terminologic - * trap: we inherited from prefork only modules the term 'child' - * meaning 'child process'. In this case the child init actually + * trap: we inherited from fork capable systems the term 'child' + * meaning 'child process'. In this case the child init actually * is a worker thread initialization, because in a threaded module * this is the agent playing the same role a child process plays * with the prefork bridge */ Lazy_RunConfScript(private,w,child_init); + idx = w->conf->idx; + + /* After the thread has run the configuration script we + increment the threads counter */ + + apr_thread_mutex_lock(module_globals->mpm->vhosts[idx].mutex); + (module_globals->mpm->vhosts[idx].threads_count)++; + apr_thread_mutex_unlock(module_globals->mpm->vhosts[idx].mutex); + /* The thread is now set up to serve request within the the * do...while loop controlled by private->keep_going */ - idx = w->conf->idx; apr_thread_mutex_lock(w->mutex); do { - module_globals->mpm->vhosts[idx].idle_threads_cnt++; while ((w->status != init) && (w->status != thread_exit)) { apr_thread_cond_wait(w->condition,w->mutex); } @@ -390,16 +411,16 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) } w->status = processing; - module_globals->mpm->vhosts[idx].idle_threads_cnt--; /* Content generation */ private->req_cnt++; private->ctype = w->ctype; + private->r = w->r; - w->ap_sts = Rivet_SendContent(private,w->r); + w->ap_sts = Rivet_SendContent(private); - if (module_globals->mpm->server_shutdown) continue; + // if (module_globals->mpm->server_shutdown) continue; w->status = done; apr_thread_cond_signal(w->condition); @@ -416,8 +437,8 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data) } while (private->ext->keep_going); apr_thread_mutex_unlock(w->mutex); - ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,w->server,"processor thread orderly exit"); Lazy_RunConfScript(private,w,child_exit); + ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,w->server,"processor thread orderly exit"); apr_thread_mutex_lock(module_globals->mpm->vhosts[idx].mutex); (module_globals->mpm->vhosts[idx].threads_count)--; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@tcl.apache.org For additional commands, e-mail: commits-h...@tcl.apache.org