You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2017/05/15 13:56:37 UTC
svn commit: r1795207 - in /tcl/rivet/trunk: ChangeLog
src/mod_rivet_ng/rivet_prefork_mpm.c src/mod_rivet_ng/worker_prefork_common.c
Author: mxmanghi
Date: Mon May 15 13:56:37 2017
New Revision: 1795207
URL: http://svn.apache.org/viewvc?rev=1795207&view=rev
Log:
* src/mod_rivet_ng/rivet_prefork_mpm.c: server root
interpreter needs to re-seed the random number generator
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/src/mod_rivet_ng/rivet_prefork_mpm.c
tcl/rivet/trunk/src/mod_rivet_ng/worker_prefork_common.c
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1795207&r1=1795206&r2=1795207&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Mon May 15 13:56:37 2017
@@ -1,3 +1,7 @@
+2017-05-15 Massimo Manghi <mx...@apache.org>
+ * src/mod_rivet_ng/rivet_prefork_mpm.c: server root
+ interpreter needs to re-seed the random number generator
+
2017-05-11 Massimo Manghi <mx...@apache.org>
* rivet/init.tcl.in: apply Damon's patch concerning
some tests and error handling. Removed call to the
Modified: tcl/rivet/trunk/src/mod_rivet_ng/rivet_prefork_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/rivet_prefork_mpm.c?rev=1795207&r1=1795206&r2=1795207&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/rivet_prefork_mpm.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/rivet_prefork_mpm.c Mon May 15 13:56:37 2017
@@ -129,10 +129,29 @@ int Prefork_MPM_Request (request_rec* r,
rivet_thread_interp* MPM_MasterInterp(server_rec* server)
{
rivet_thread_private* private;
+ int tcl_status;
RIVET_PRIVATE_DATA_NOT_NULL (rivet_thread_key, private);
module_globals->server_interp->channel = private->channel;
+
+ /*
+ * We are returning the interpreter inherited from
+ * the parent process. The fork preserves the internal status
+ * of the process, math engine status included. This fact implies
+ * the random number generator has the same seed and every
+ * child process for which SeparateVirtualInterps would generate
+ * the same random number sequence. We therefore reseed the RNG
+ * calling a Tcl script fragment
+ */
+
+ tcl_status = Tcl_Eval (module_globals->server_interp->interp,"expr {srand([clock clicks] + [pid])}");
+ if (tcl_status != TCL_OK)
+ {
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server,
+ MODNAME ": Tcl interpreter random number generation reseeding failed");
+
+ }
return module_globals->server_interp;
}
Modified: tcl/rivet/trunk/src/mod_rivet_ng/worker_prefork_common.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/worker_prefork_common.c?rev=1795207&r1=1795206&r2=1795207&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/worker_prefork_common.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/worker_prefork_common.c Mon May 15 13:56:37 2017
@@ -49,7 +49,7 @@ Rivet_DuplicateVHostInterp(apr_pool_t* p
interp_obj->cache_free = source_obj->cache_free;
interp_obj->cache_size = source_obj->cache_size;
- /* TODO: decouple cache by creating a new cache object */
+ /* An intepreter must have its own cache */
if (interp_obj->cache_size) {
RivetCache_Create(pool,interp_obj);
@@ -98,12 +98,7 @@ rivet_thread_private* Rivet_VirtualHosts
root_interp = MPM_MasterInterp(module_globals->server);
- /* we must assume the module was able to create the root interprter otherwise
- * it's just a null module. I try to have also this case to develop experimental
- * bridges without the Tcl stuff
- */
-
- //if (root_interp == NULL) return private;
+ /* we must assume the module was able to create the root interprter */
ap_assert (root_interp != NULL);
@@ -170,7 +165,7 @@ rivet_thread_private* Rivet_VirtualHosts
}
else
{
- rivet_interp = Rivet_DuplicateVHostInterp(private->pool,root_interp);
+ rivet_interp = Rivet_DuplicateVHostInterp(private->pool,root_interp);
}
}
@@ -187,8 +182,9 @@ rivet_thread_private* Rivet_VirtualHosts
Rivet_PerInterpInit(rivet_interp, private, s, private->pool);
}
- /* TODO: check if it's absolutely necessary to lock the pool_mutex in order
- * to allocate from the module global pool
+ /* It seems that allocating from a shared APR memory pool is not thread safe,
+ * but it's not very well documented actually. I any case we protect this
+ * memory allcation with a mutex
*/
/* this stuff must be allocated from the module global pool which
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org