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 2014/09/05 19:20:55 UTC
svn commit: r1622742 - in /tcl/rivet/trunk: ./ src/experimental/
Author: mxmanghi
Date: Fri Sep 5 17:20:54 2014
New Revision: 1622742
URL: http://svn.apache.org/r1622742
Log:
* src/experimental/apache_config.h: removed handling of lines unneeded by this version of mod_rivet
* src/experimental/rivet_worker_mpm.c:
* src/experimental/rivet_aprthread_mpm.c:
* src/experimental/rivet_prefork_mpm.c: moving reference to configurations
scripts into their new location on rivet_thread_private
* src/experimental/mod_rivet.h: running_scripts object defined to store running configurations
script wrapped in Tcl_Obj instances and allow construction of database of Tcl scripts bound
to per-directory configuration. Adding variables for storing running configuration in rivet_thread_private.
Configuration records now store references to pristine char* buffers for scripts
* src/experimental/mod_rivet.c: changed referenced to configured scripts to their new location,
removed redundant calls to Rivet_GetConf. Configuration is now built and stored in thread private data
* src/experimental/rivetInspect.c: code in Rivet_ReadConfParameter adapted to reflect changes
in configuration record definitions
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/src/experimental/apache_config.c
tcl/rivet/trunk/src/experimental/mod_rivet.c
tcl/rivet/trunk/src/experimental/mod_rivet.h
tcl/rivet/trunk/src/experimental/rivetInspect.c
tcl/rivet/trunk/src/experimental/rivet_aprthread_mpm.c
tcl/rivet/trunk/src/experimental/rivet_prefork_mpm.c
tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Fri Sep 5 17:20:54 2014
@@ -1,3 +1,18 @@
+2014-09-05 Massimo Manghi <mx...@apache.org>
+ * src/experimental/apache_config.h: removed handling of lines unneeded by this version of mod_rivet
+ * src/experimental/rivet_worker_mpm.c:
+ * src/experimental/rivet_aprthread_mpm.c:
+ * src/experimental/rivet_prefork_mpm.c: moving reference to configurations
+ scripts into their new location on rivet_thread_private
+ * src/experimental/mod_rivet.h: running_scripts object defined to store running configurations
+ script wrapped in Tcl_Obj instances and allow construction of database of Tcl scripts bound
+ to per-directory configuration. Adding variables for storing running configuration in rivet_thread_private.
+ Configuration records now store references to pristine char* buffers for scripts
+ * src/experimental/mod_rivet.c: changed referenced to configured scripts to their new location,
+ removed redundant calls to Rivet_GetConf. Configuration is now built and stored in thread private data
+ * src/experimental/rivetInspect.c: code in Rivet_ReadConfParameter adapted to reflect changes
+ in configuration record definitions
+
2014-08-31 Massimo Manghi <mx...@apache.org>
* src/experimental/rivet_prefork_mpm.c: removing commented code
* src/experimental/mod_rivet.c: removing unnecessary Tcl mutex declaration
Modified: tcl/rivet/trunk/src/experimental/apache_config.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/apache_config.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/apache_config.c (original)
+++ tcl/rivet/trunk/src/experimental/apache_config.c Fri Sep 5 17:20:54 2014
@@ -37,6 +37,8 @@
#include "apache_config.h"
#include "rivet.h"
+extern mod_rivet_globals* module_globals;
+
/*
* -- Rivet_AssignStringtoConf --
*
@@ -73,6 +75,21 @@ Rivet_AssignStringToConf (Tcl_Obj** objP
return objarg;
}
+static char*
+Rivet_AppendStringToConf (char* p,const char* string,apr_pool_t *pool)
+{
+
+ if (p == NULL)
+ {
+ return apr_pstrdup(pool,string);
+ }
+ else
+ {
+ return apr_pstrcat(pool,p,string,"\n",NULL);
+ }
+
+}
+
/*
* -- Rivet_SetScript --
*
@@ -95,24 +112,24 @@ Rivet_SetScript (apr_pool_t *pool, rivet
{
Tcl_Obj *objarg = NULL;
- if( STREQU( script, "GlobalInitScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_global_init_script),string);
- } else if( STREQU( script, "ChildInitScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_child_init_script),string);
- } else if( STREQU( script, "ChildExitScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_child_exit_script),string);
- } else if( STREQU( script, "BeforeScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_before_script),string);
- } else if( STREQU( script, "AfterScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_after_script),string);
- } else if( STREQU( script, "ErrorScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_error_script),string);
- } else if( STREQU( script, "ServerInitScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_server_init_script),string);
- } else if( STREQU( script, "AbortScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->rivet_abort_script),string);
- } else if( STREQU( script, "AfterEveryScript" ) ) {
- objarg = Rivet_AssignStringToConf(&(rsc->after_every_script),string);
+ if ( STREQU( script, "GlobalInitScript" ) ) {
+ rsc->rivet_global_init_script = Rivet_AppendStringToConf(rsc->rivet_global_init_script,string,pool);
+ } else if ( STREQU( script, "ChildInitScript" ) ) {
+ rsc->rivet_child_init_script = Rivet_AppendStringToConf(rsc->rivet_child_init_script,string,pool);
+ } else if ( STREQU( script, "ChildExitScript" ) ) {
+ rsc->rivet_child_exit_script = Rivet_AppendStringToConf(rsc->rivet_child_exit_script,string,pool);
+ } else if ( STREQU( script, "BeforeScript" ) ) {
+ rsc->rivet_before_script = Rivet_AppendStringToConf(rsc->rivet_before_script,string,pool);
+ } else if ( STREQU( script, "AfterScript" ) ) {
+ rsc->rivet_after_script = Rivet_AppendStringToConf(rsc->rivet_after_script,string,pool);
+ } else if ( STREQU( script, "ErrorScript" ) ) {
+ rsc->rivet_error_script = Rivet_AppendStringToConf(rsc->rivet_error_script,string,pool);
+ } else if ( STREQU( script, "AbortScript" ) ) {
+ rsc->rivet_abort_script = Rivet_AppendStringToConf(rsc->rivet_abort_script,string,pool);
+ } else if ( STREQU( script, "AfterEveryScript" ) ) {
+ rsc->after_every_script = Rivet_AppendStringToConf(rsc->after_every_script,string,pool);
+ } else if ( STREQU( script, "ServerInitScript" ) ) {
+ rsc->rivet_server_init_script = Rivet_AppendStringToConf(rsc->rivet_server_init_script,string,pool);
}
if( !objarg ) return string;
@@ -148,16 +165,22 @@ Rivet_GetConf( request_rec *r )
void *dconf = r->per_dir_config;
rivet_server_conf *newconfig = NULL;
rivet_server_conf *rdc;
-
+
FILEDEBUGINFO;
/* If there is no per dir config, just return the server config */
if (dconf == NULL) {
return rsc;
}
- rdc = RIVET_SERVER_CONF( dconf );
-
- newconfig = RIVET_NEW_CONF( r->pool );
+
+ /* things might become tedious when there are scripts set
+ in a <Directory ...>...</Directory> stanza. Especially
+ since we are calling this function at every single request.
+ We compute the new configuration merging the per-dir conf
+ with the server configuration and then we return it. */
+
+ rdc = RIVET_SERVER_CONF ( dconf );
+ newconfig = RIVET_NEW_CONF ( r->pool );
Rivet_CopyConfig( rsc, newconfig );
Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
@@ -182,22 +205,16 @@ Rivet_CopyConfig( rivet_server_conf *old
{
FILEDEBUGINFO;
- //newrsc->server_interp = oldrsc->server_interp;
+ newrsc->rivet_server_init_script = oldrsc->rivet_server_init_script;
newrsc->rivet_global_init_script = oldrsc->rivet_global_init_script;
newrsc->rivet_before_script = oldrsc->rivet_before_script;
newrsc->rivet_after_script = oldrsc->rivet_after_script;
newrsc->rivet_error_script = oldrsc->rivet_error_script;
newrsc->rivet_abort_script = oldrsc->rivet_abort_script;
newrsc->after_every_script = oldrsc->after_every_script;
-
newrsc->user_scripts_updated = oldrsc->user_scripts_updated;
-
newrsc->rivet_default_error_script = oldrsc->rivet_default_error_script;
-
- /* These are pointers so that they can be passed around... */
newrsc->default_cache_size = oldrsc->default_cache_size;
- //newrsc->cache_size = oldrsc->cache_size;
- //newrsc->cache_free = oldrsc->cache_free;
newrsc->upload_max = oldrsc->upload_max;
newrsc->upload_files_to_var = oldrsc->upload_files_to_var;
newrsc->separate_virtual_interps = oldrsc->separate_virtual_interps;
@@ -208,9 +225,6 @@ Rivet_CopyConfig( rivet_server_conf *old
newrsc->rivet_dir_vars = oldrsc->rivet_dir_vars;
newrsc->rivet_user_vars = oldrsc->rivet_user_vars;
newrsc->idx = oldrsc->idx;
- //newrsc->objCacheList = oldrsc->objCacheList;
- //newrsc->objCache = oldrsc->objCache;
- //newrsc->outchannel = oldrsc->outchannel;
}
/*
@@ -243,6 +257,10 @@ Rivet_MergeDirConfigVars(apr_pool_t *p,
rivet_server_conf *base, rivet_server_conf *add )
{
FILEDEBUGINFO;
+
+ /* TODO: conf assignement should be converted into a macro (already in mod_rivet.h) */
+ // RIVET_CONF_SELECT(new,base,add,rivet_child_init_script)
+
new->rivet_child_init_script = add->rivet_child_init_script ?
add->rivet_child_init_script : base->rivet_child_init_script;
new->rivet_child_exit_script = add->rivet_child_exit_script ?
@@ -262,8 +280,7 @@ Rivet_MergeDirConfigVars(apr_pool_t *p,
new->user_scripts_updated = add->user_scripts_updated ?
add->user_scripts_updated : base->user_scripts_updated;
- new->upload_dir = add->upload_dir ?
- add->upload_dir : base->upload_dir;
+ new->upload_dir = add->upload_dir ? add->upload_dir : base->upload_dir;
/* Merge the tables of dir and user variables. */
if (base->rivet_dir_vars && add->rivet_dir_vars) {
@@ -400,9 +417,6 @@ Rivet_MergeConfig(apr_pool_t *p, void *b
rsc->after_every_script = overrides->after_every_script ?
overrides->after_every_script : base->after_every_script;
- /* cache_size is global, and set up later. */
- /* cache_free is not set up at this point. */
-
rsc->upload_max = overrides->upload_max ?
overrides->upload_max : base->upload_max;
@@ -423,10 +437,6 @@ Rivet_MergeConfig(apr_pool_t *p, void *b
rsc->rivet_user_vars = overrides->rivet_user_vars ?
overrides->rivet_user_vars : base->rivet_user_vars;
- /* objCacheList is set up later. */
- /* objCache is set up later. */
- /* outchannel is set up later. */
-
return rsc;
}
@@ -460,14 +470,7 @@ Rivet_CreateConfig(apr_pool_t *p, server
rsc->user_scripts_updated = 0;
- rsc->rivet_default_error_script = Tcl_NewStringObj("::Rivet::handle_error", -1);
- Tcl_IncrRefCount(rsc->rivet_default_error_script);
-
- /* these are pointers so that they can be passed around... */
- //rsc->cache_size = apr_pcalloc(p, sizeof(int));
- //rsc->cache_free = apr_pcalloc(p, sizeof(int));
- //*(rsc->cache_size) = -1;
- //*(rsc->cache_free) = 0;
+ rsc->rivet_default_error_script = "::Rivet::handle_error";
rsc->default_cache_size = -1;
rsc->upload_max = RIVET_MAX_POST;
@@ -476,9 +479,6 @@ Rivet_CreateConfig(apr_pool_t *p, server
rsc->honor_header_only_reqs = RIVET_HEAD_REQUESTS;
rsc->upload_dir = RIVET_UPLOAD_DIR;
rsc->server_name = NULL;
- //rsc->objCacheList = NULL;
- //rsc->objCache = NULL;
- //rsc->outchannel = NULL;
rsc->rivet_server_vars = (apr_table_t *) apr_table_make ( p, 4 );
rsc->rivet_dir_vars = (apr_table_t *) apr_table_make ( p, 4 );
Modified: tcl/rivet/trunk/src/experimental/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/mod_rivet.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/experimental/mod_rivet.c Fri Sep 5 17:20:54 2014
@@ -71,7 +71,9 @@ void Rivet_PerInterpInit(Tcl_Interp* in
#define ERRORBUF_SZ 256
-//TCL_DECLARE_MUTEX(sendMutex);
+ /* XXX: the pool passed to Rivet_NewVHostInterp must be the private pool of
+ * a rivet_thread_private object
+ */
vhost_interp* Rivet_NewVHostInterp(apr_pool_t* pool)
{
@@ -117,13 +119,17 @@ vhost_interp* Rivet_NewVHostInterp(apr_p
// Initialize cache structures
if (interp_obj->cache_size) {
- interp_obj->objCacheList = apr_pcalloc(interp_obj->pool, (signed)(interp_obj->cache_size*sizeof(char *)));
+ 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);
}
interp_obj->flags = 0;
+ interp_obj->scripts = (running_scripts *) apr_pcalloc(interp_obj->pool,sizeof(running_scripts));
+ interp_obj->per_dir_scripts = apr_hash_make(interp_obj->pool);
+
return interp_obj;
}
@@ -154,17 +160,22 @@ rivet_thread_private* Rivet_VirtualHosts
/* Using the root interpreter we evaluate the global initialization script, if any */
if (root_server_conf->rivet_global_init_script != NULL) {
- if (Tcl_EvalObjEx(root_interp->interp, root_server_conf->rivet_global_init_script, 0) != TCL_OK)
+ Tcl_Obj* global_tcl_script;
+
+ global_tcl_script = Tcl_NewStringObj(root_server_conf->rivet_global_init_script,-1);
+ Tcl_IncrRefCount(global_tcl_script);
+ if (Tcl_EvalObjEx(root_interp->interp, global_tcl_script, 0) != TCL_OK)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server,
MODNAME ": Error running GlobalInitScript '%s': %s",
- Tcl_GetString(root_server_conf->rivet_global_init_script),
+ root_server_conf->rivet_global_init_script,
Tcl_GetVar(root_interp->interp, "errorInfo", 0));
} else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, module_globals->server,
MODNAME ": GlobalInitScript '%s' successful",
- Tcl_GetString(root_server_conf->rivet_global_init_script));
+ root_server_conf->rivet_global_init_script);
}
+ Tcl_DecrRefCount(global_tcl_script);
}
/* then we proceed assigning/creating the interpreters for the
@@ -197,6 +208,14 @@ rivet_thread_private* Rivet_VirtualHosts
Tcl_RegisterChannel(rivet_interp->interp,*private->channel);
}
+ /* these 5 lines initialize the interpreter base running scripts */
+
+ RIVET_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_before_script);
+ RIVET_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_after_script);
+ RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_error_script);
+ RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_abort_script);
+ RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,after_every_script);
+
private->interps[myrsc->idx] = rivet_interp;
/* Basic Rivet packages and libraries are loaded here. Also the interpreter globals
@@ -229,11 +248,13 @@ rivet_thread_private* Rivet_VirtualHosts
{
char* errmsg = MODNAME ": Error in Child init script: %s";
Tcl_Interp* interp = rivet_interp->interp;
+ Tcl_Obj* tcl_child_init = Tcl_NewStringObj(function,-1);
+ Tcl_IncrRefCount(tcl_child_init);
rivet_interp_globals* globals = Tcl_GetAssocData( interp, "rivet", NULL );
Tcl_Preserve (interp);
- /* There is a lot of passing around of pointers to various record
+ /* There is a lot of passing around of pointers among various record
* objects. We should understand if this is all that necessary.
* Here we assign the server_rec pointer to the interpreter which
* is wrong, because without separate interpreters it doens't make
@@ -241,7 +262,7 @@ rivet_thread_private* Rivet_VirtualHosts
*/
globals->srec = s;
- if (Tcl_EvalObjEx(interp,function, 0) != TCL_OK) {
+ if (Tcl_EvalObjEx(interp,tcl_child_init, 0) != TCL_OK) {
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server,
errmsg, Tcl_GetString(function));
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server,
@@ -252,6 +273,7 @@ rivet_thread_private* Rivet_VirtualHosts
Tcl_GetVar(interp, "errorInfo", 0));
}
Tcl_Release (interp);
+ Tcl_DecrRefCount(tcl_child_init);
}
}
return private;
@@ -278,6 +300,7 @@ rivet_thread_private* Rivet_VirtualHosts
*
* resources stored in the array of vhost_interp objects are released
* and interpreters are deleted.
+ *
*/
void Rivet_ProcessorCleanup (void *data)
@@ -346,27 +369,78 @@ Rivet_SendContent(rivet_thread_private *
int ctype;
Tcl_Interp* interp;
rivet_interp_globals* globals = NULL;
- request_rec* r = private->r;
+ request_rec* r = private->r;
+ void* dconf = r->per_dir_config;
+ vhost_interp* interp_obj;
#ifdef USE_APACHE_RSC
- rivet_server_conf *rsc = NULL;
+ //rivet_server_conf *rsc = NULL;
#else
- rivet_server_conf *rdc;
+ //rivet_server_conf *rdc;
#endif
- ctype = Rivet_CheckType(r);
+ ctype = Rivet_CheckType(private->r);
if (ctype == CTYPE_NOT_HANDLED) {
return DECLINED;
}
- //Tcl_MutexLock(&sendMutex);
-
/* Set the global request req to know what we are dealing with in
* case we have to call the PanicProc. */
- module_globals->rivet_panic_request_rec = r;
- rsc = Rivet_GetConf(r);
+ module_globals->rivet_panic_request_rec = private->r;
+
+ // rsc = Rivet_GetConf(r);
+
+ private->running_conf = RIVET_SERVER_CONF (private->r->server->module_config);
+
+ /* the interp index in the private data can not be changed by a config merge */
+
+ interp_obj = private->interps[private->running_conf->idx];
+ if (dconf)
+ {
+ const char* canonical = apr_pstrdup(r->pool,r->filename);
+ const char* rootpath;
+
+ /* Let's check if a scripts object is already stored in the per-dir hash table */
+
+ ap_assert(apr_filepath_root( &rootpath, &canonical, 0, interp_obj->pool) == APR_SUCCESS);
+
+ private->running =
+ (running_scripts *) apr_hash_get (interp_obj->per_dir_scripts,rootpath,strlen(rootpath));
+
+ if (private->running == NULL)
+ {
+ rivet_server_conf* rdc = NULL;
+ rivet_server_conf* newconfig = NULL;
+ running_scripts* scripts =
+ (running_scripts *) apr_pcalloc (interp_obj->pool,sizeof(running_scripts));
+
+ rdc = RIVET_SERVER_CONF(dconf);
+ newconfig = RIVET_NEW_CONF(r->pool);
+
+ Rivet_CopyConfig( private->running_conf, newconfig );
+ Rivet_MergeDirConfigVars( r->pool, newconfig, private->running_conf, rdc );
+ private->running_conf = newconfig;
+
+ RIVET_SCRIPT_INIT (scripts,newconfig,rivet_before_script);
+ RIVET_SCRIPT_INIT (scripts,newconfig,rivet_after_script);
+ RIVET_NULL_SCRIPT_INIT (scripts,newconfig,rivet_error_script);
+ RIVET_NULL_SCRIPT_INIT (scripts,newconfig,rivet_abort_script);
+ RIVET_NULL_SCRIPT_INIT (scripts,newconfig,after_every_script);
+
+ apr_hash_set (interp_obj->per_dir_scripts,rootpath,strlen(rootpath),scripts);
+
+ private->running = scripts;
- interp = private->interps[rsc->idx]->interp;
+ }
+ }
+ else
+ {
+ /* if no <Directory ...> rules applies we use the server configuration */
+
+ private->running = interp_obj->scripts;
+ }
+
+ interp = interp_obj->interp;
globals = Tcl_GetAssocData(interp, "rivet", NULL);
/* everything should merge into a single struct sooner or later */
@@ -455,8 +529,8 @@ Rivet_SendContent(rivet_thread_private *
/* Apache Request stuff */
TclWeb_InitRequest(globals->req, interp, r);
- ApacheRequest_set_post_max(globals->req->apachereq, rsc->upload_max);
- ApacheRequest_set_temp_dir(globals->req->apachereq, rsc->upload_dir);
+ ApacheRequest_set_post_max(globals->req->apachereq, private->running_conf->upload_max);
+ ApacheRequest_set_temp_dir(globals->req->apachereq, private->running_conf->upload_dir);
/* Let's copy the request data into the thread private record */
@@ -467,7 +541,7 @@ Rivet_SendContent(rivet_thread_private *
goto sendcleanup;
}
- if (r->header_only && !rsc->honor_header_only_reqs)
+ if (r->header_only && !private->running_conf->honor_header_only_reqs)
{
TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, globals->req);
TclWeb_PrintHeaders(globals->req);
@@ -573,17 +647,18 @@ sendcleanup:
*/
static int
-Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *tcl_script_obj, request_rec *req)
+Rivet_ExecuteAndCheck(rivet_thread_private *private, Tcl_Obj *tcl_script_obj)
{
- rivet_thread_private* private;
+ vhost_interp* interp_obj;
- ap_assert (apr_threadkey_private_get ((void **)&private,rivet_thread_key) == APR_SUCCESS);
+ //ap_assert (apr_threadkey_private_get ((void **)&private,rivet_thread_key) == APR_SUCCESS);
+ //rivet_server_conf *conf = private->running_conf;
- rivet_server_conf *conf = Rivet_GetConf(req);
- rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+ interp_obj = private->interps[private->running_conf->idx];
+ rivet_interp_globals *globals = Tcl_GetAssocData(interp_obj->interp, "rivet", NULL);
- Tcl_Preserve (interp);
- if ( Tcl_EvalObjEx(interp, tcl_script_obj, 0) == TCL_ERROR ) {
+ Tcl_Preserve (interp_obj->interp);
+ if ( Tcl_EvalObjEx(interp_obj->interp, tcl_script_obj, 0) == TCL_ERROR ) {
Tcl_Obj *errscript;
Tcl_Obj *errorCodeListObj;
Tcl_Obj *errorCodeElementObj;
@@ -593,7 +668,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
* by abort_page.
*/
- errorCodeListObj = Tcl_GetVar2Ex (interp, "errorCode", (char *)NULL, TCL_GLOBAL_ONLY);
+ errorCodeListObj = Tcl_GetVar2Ex (interp_obj->interp, "errorCode", (char *)NULL, TCL_GLOBAL_ONLY);
/* errorCode is guaranteed to be set to NONE, but let's make sure
* anyway rather than causing a SIGSEGV
@@ -603,7 +678,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
/* dig the first element out of the errorCode list and see if it
* says Rivet -- this shouldn't fail either, but let's assert
* success so we don't get a SIGSEGV afterwards */
- ap_assert (Tcl_ListObjIndex (interp, errorCodeListObj, 0, &errorCodeElementObj) == TCL_OK);
+ ap_assert (Tcl_ListObjIndex (interp_obj->interp, errorCodeListObj, 0, &errorCodeElementObj) == TCL_OK);
/* if the error was thrown by Rivet, see if it's abort_page and,
* if so, don't treat it as an error, i.e. don't execute the
@@ -616,16 +691,16 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
/* dig the second element out of the errorCode list, make sure
* it succeeds -- it should always
*/
- ap_assert (Tcl_ListObjIndex (interp, errorCodeListObj, 1, &errorCodeElementObj) == TCL_OK);
+ ap_assert (Tcl_ListObjIndex (interp_obj->interp, errorCodeListObj, 1, &errorCodeElementObj) == TCL_OK);
errorCodeSubString = Tcl_GetString (errorCodeElementObj);
if (strcmp (errorCodeSubString, ABORTPAGE_CODE) == 0)
{
- if (conf->rivet_abort_script)
+ if (private->running->rivet_abort_script)
{
- if (Tcl_EvalObjEx(interp,conf->rivet_abort_script,0) == TCL_ERROR)
+ if (Tcl_EvalObjEx(interp_obj->interp,private->running->rivet_abort_script,0) == TCL_ERROR)
{
- CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
+ CONST84 char *errorinfo = Tcl_GetVar( interp_obj->interp, "errorInfo", 0 );
TclWeb_PrintError("<b>Rivet AbortScript failed!</b>",1,globals->req);
TclWeb_PrintError( errorinfo, 0, globals->req );
}
@@ -634,45 +709,47 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
}
}
- Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( tcl_script_obj, NULL ),TCL_GLOBAL_ONLY );
+ Tcl_SetVar (interp_obj->interp,"errorOutbuf",Tcl_GetStringFromObj(tcl_script_obj, NULL),TCL_GLOBAL_ONLY );
/* If we don't have an error script, use the default error handler. */
- if (conf->rivet_error_script ) {
- errscript = conf->rivet_error_script;
+ if (private->running->rivet_error_script ) {
+ errscript = private->running->rivet_error_script;
} else {
- errscript = conf->rivet_default_error_script;
+ errscript = Tcl_NewStringObj(private->running_conf->rivet_default_error_script,-1);
}
Tcl_IncrRefCount(errscript);
- if (Tcl_EvalObjEx(interp, errscript, 0) == TCL_ERROR) {
- CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
+ if (Tcl_EvalObjEx(interp_obj->interp, errscript, 0) == TCL_ERROR) {
+ CONST84 char *errorinfo = Tcl_GetVar( interp_obj->interp, "errorInfo", 0 );
TclWeb_PrintError("<b>Rivet ErrorScript failed!</b>",1,globals->req);
TclWeb_PrintError( errorinfo, 0, globals->req );
}
/* This shouldn't make the default_error_script go away,
- * because it gets a Tcl_IncrRefCount when it is created. */
+ * because it gets a Tcl_IncrRefCount when it is created.
+ */
Tcl_DecrRefCount(errscript);
}
/* Make sure to flush the output if buffer_add was the only output */
good:
- if (conf->after_every_script) {
- if (Tcl_EvalObjEx(interp,conf->after_every_script,0) == TCL_ERROR)
+ if (private->running->after_every_script) {
+ if (Tcl_EvalObjEx(interp_obj->interp,private->running->after_every_script,0) == TCL_ERROR)
{
- CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
+ CONST84 char *errorinfo = Tcl_GetVar(interp_obj->interp,"errorInfo",0);
TclWeb_PrintError("<b>Rivet AfterEveryScript failed!</b>",1,globals->req);
TclWeb_PrintError( errorinfo, 0, globals->req );
}
}
if (!globals->req->headers_set && (globals->req->charset != NULL)) {
- TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL),globals->req);
+ TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",
+ globals->req->charset,NULL),globals->req);
}
TclWeb_PrintHeaders(globals->req);
Tcl_Flush(*(private->channel));
- Tcl_Release(interp);
+ Tcl_Release(interp_obj->interp);
return TCL_OK;
}
@@ -688,51 +765,48 @@ good:
*
* Arguments:
*
- * - rivet_thread_private : pointer to the structure collecting thread private data
- for Tcl and current request
- * - filename: pointer to a string storing the path to the template or
- * Tcl script
- * - toplevel: integer to be interpreted as a boolean meaning the
- * file is pointed by the request. When 0 that's a subtemplate
- * to be parsed and executed from another template
+ * - rivet_thread_private: pointer to the structure collecting thread private data
+ * for Tcl and current request
+ * - filename: pointer to a string storing the path to the template or
+ * Tcl script
+ * - toplevel: boolean value set when the argument 'filename' is the request
+ * toplevel script. The value is 0 when the function is called
+ * by command ::rivet::parse
*/
int
Rivet_ParseExecFile(rivet_thread_private* private, char *filename, int toplevel)
{
- char *hashKey = NULL;
- int isNew = 0;
- int result = 0;
- //TclWebRequest* req;
+ char* hashKey = NULL;
+ int isNew = 0;
+ int result = 0;
vhost_interp* rivet_interp;
- Tcl_Obj *outbuf = NULL;
- Tcl_HashEntry *entry = NULL;
+ Tcl_Obj* outbuf = NULL;
+ Tcl_HashEntry* entry = NULL;
Tcl_Interp* interp;
-
time_t ctime;
time_t mtime;
+ //rivet_server_conf *rsc;
- rivet_server_conf *rsc;
-
- rsc = Rivet_GetConf( private->r );
+ //rsc = Rivet_GetConf( private->r );
/* We have to fetch the interpreter data from the thread private environment */
- rivet_interp = private->interps[rsc->idx];
+ rivet_interp = private->interps[private->running_conf->idx];
interp = rivet_interp->interp;
/* If the user configuration has indeed been updated, I guess that
- pretty much invalidates anything that might have been
- cached. */
+ pretty much invalidates anything that might have been cached. */
/* This is all horrendously slow, and means we should *also* be
doing caching on the modification time of the .htaccess files
that concern us. FIXME */
- if (rsc->user_scripts_updated && (rivet_interp->cache_size != 0))
+ if (private->running_conf->user_scripts_updated && (rivet_interp->cache_size != 0))
{
int ct;
Tcl_HashEntry *delEntry;
+
/* Clean out the list. */
ct = rivet_interp->cache_free;
while (ct < rivet_interp->cache_size) {
@@ -789,8 +863,8 @@ Rivet_ParseExecFile(rivet_thread_private
Tcl_IncrRefCount(outbuf);
if (toplevel) {
- if (rsc->rivet_before_script) {
- Tcl_AppendObjToObj(outbuf,rsc->rivet_before_script);
+ if (private->running->rivet_before_script) {
+ Tcl_AppendObjToObj(outbuf,private->running->rivet_before_script);
}
}
@@ -818,8 +892,8 @@ Rivet_ParseExecFile(rivet_thread_private
return result;
}
- if (toplevel && rsc->rivet_after_script) {
- Tcl_AppendObjToObj(outbuf,rsc->rivet_after_script);
+ if (toplevel && private->running->rivet_after_script) {
+ Tcl_AppendObjToObj(outbuf,private->running->rivet_after_script);
}
if (rivet_interp->cache_size) {
@@ -875,10 +949,11 @@ Rivet_ParseExecFile(rivet_thread_private
Tcl_IncrRefCount(outbuf);
}
- rsc->user_scripts_updated = 0;
+ private->running_conf->user_scripts_updated = 0;
{
int res = 0;
- res = Rivet_ExecuteAndCheck(interp, outbuf, private->r);
+
+ res = Rivet_ExecuteAndCheck(private, outbuf);
Tcl_DecrRefCount(outbuf);
return res;
}
@@ -902,8 +977,9 @@ Rivet_ParseExecString (TclWebRequest* re
{
int res = 0;
Tcl_Obj* outbuf = Tcl_NewObj();
- Tcl_Interp *interp = req->interp;
+ rivet_thread_private* private;
+ ap_assert (apr_threadkey_private_get ((void **)&private,rivet_thread_key) == APR_SUCCESS);
Tcl_IncrRefCount(outbuf);
Tcl_AppendToObj(outbuf, "puts -nonewline \"", -1);
@@ -915,7 +991,7 @@ Rivet_ParseExecString (TclWebRequest* re
Tcl_AppendToObj(outbuf, "\n", -1);
- res = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
+ res = Rivet_ExecuteAndCheck(private, outbuf);
Tcl_DecrRefCount(outbuf);
return res;
@@ -1229,7 +1305,7 @@ Rivet_ServerInit (apr_pool_t *pPool, apr
module_globals->mpm_max_threads = 0;
module_globals->mpm_min_spare_threads = 0;
module_globals->mpm_max_spare_threads = 0;
- //module_globals->num_load_samples = 0;
+ //module_globals->num_load_samples = 0;
/* Another crucial point: we are storing here in the globals a reference to the
* root server_rec object from which threads are supposed to derive
Modified: tcl/rivet/trunk/src/experimental/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/mod_rivet.h?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/mod_rivet.h (original)
+++ tcl/rivet/trunk/src/experimental/mod_rivet.h Fri Sep 5 17:20:54 2014
@@ -83,33 +83,18 @@
module AP_MODULE_DECLARE_DATA rivet_module;
-typedef struct _rivet_conf_scripts {
-
- void* rivet_server_init_script; /* run before children are forked */
- void* rivet_global_init_script; /* run once when apache is started */
- void* rivet_child_init_script;
- void* rivet_child_exit_script;
- void* rivet_before_script; /* script run before each page */
- void* rivet_after_script; /* after */
- void* rivet_error_script; /* for errors */
- void* rivet_abort_script; /* script run upon abort_page call */
- void* after_every_script; /* script to be run always */
- void* rivet_default_error_script; /* for errors */
-
-} rivet_conf_scripts;
-
typedef struct _rivet_server_conf {
- Tcl_Obj *rivet_server_init_script; /* run before children are forked */
- Tcl_Obj *rivet_global_init_script; /* run once when apache is started */
- Tcl_Obj *rivet_child_init_script;
- Tcl_Obj *rivet_child_exit_script;
- Tcl_Obj *rivet_before_script; /* script run before each page */
- Tcl_Obj *rivet_after_script; /* after */
- Tcl_Obj *rivet_error_script; /* for errors */
- Tcl_Obj *rivet_abort_script; /* script run upon abort_page call */
- Tcl_Obj *after_every_script; /* script to be run always */
- Tcl_Obj *rivet_default_error_script; /* for errors */
+ char* rivet_server_init_script; /* run before children are forked */
+ char* rivet_global_init_script; /* run once when apache is started */
+ char* rivet_child_init_script;
+ char* rivet_child_exit_script;
+ char* rivet_before_script; /* script run before each page */
+ char* rivet_after_script; /* after */
+ char* rivet_error_script; /* for errors */
+ char* rivet_abort_script; /* script run upon abort_page call */
+ char* after_every_script; /* script to be always run */
+ char* rivet_default_error_script; /* for errors */
/* This flag is used with the above directives. If any of them have changed, it gets set. */
@@ -127,15 +112,15 @@ typedef struct _rivet_server_conf {
apr_table_t* rivet_user_vars;
int idx; /* server record index (to be used for the interps db) */
- //Tcl_Interp *server_interp; /* per server Tcl interpreter */
+ //Tcl_Interp *server_interp; /* per server Tcl interpreter */
//int* cache_size;
//int* cache_free;
//char** objCacheList; /* Array of cached objects (for priority handling) */
- //Tcl_HashTable* objCache; /* Objects cache - the key is the script name */
+ //Tcl_HashTable* objCache; /* Objects cache - the key is the script name */
/* this one must go, we keep just to avoid to duplicate the config handling function just
to avoid to poke stuff into this field */
- //Tcl_Channel* outchannel; /* stuff for buffering output */
+ //Tcl_Channel* outchannel; /* stuff for buffering output */
} rivet_server_conf;
@@ -156,6 +141,16 @@ enum
#define RIVET_CACHE_FULL 1
#define RIVET_INTERP_INITIALIZED 2
+typedef struct _interp_running_scripts {
+
+ Tcl_Obj* rivet_before_script; /* script run before each page */
+ Tcl_Obj* rivet_after_script; /* after */
+ Tcl_Obj* rivet_error_script;
+ Tcl_Obj* rivet_abort_script;
+ Tcl_Obj* after_every_script;
+
+} running_scripts;
+
typedef struct _vhost_interp {
Tcl_Interp* interp;
int cache_size;
@@ -163,6 +158,8 @@ typedef struct _vhost_interp {
Tcl_HashTable* objCache; /* Objects cache - the key is the script name */
char** objCacheList; /* Array of cached objects (for priority handling) */
apr_pool_t* pool; /* interpreters cache private memory pool */
+ running_scripts* scripts; /* base server conf scripts */
+ apr_hash_t* per_dir_scripts; /* per dir running scripts */
unsigned int flags; /* signals of various interp specific conditions */
} vhost_interp;
@@ -224,6 +221,10 @@ typedef struct _thread_worker_private {
TclWebRequest* req;
Tcl_Obj* request_init;
Tcl_Obj* request_cleanup;
+
+ rivet_server_conf* running_conf; /* running configuration */
+ running_scripts* running; /* (per request) running conf scripts */
+
} rivet_thread_private;
/* eventually we will transfer 'global' variables in here and 'de-globalize' them */
@@ -295,9 +296,9 @@ Tcl_Obj* Rivet_CurrentServerRec ( Tcl_In
/* these three must go in their own file */
-EXTERN int Rivet_ParseExecFile(rivet_thread_private* req, char* filename, int toplevel);
+EXTERN int Rivet_ParseExecFile (rivet_thread_private* req, char* filename, int toplevel);
EXTERN int Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf);
-EXTERN int Rivet_SendContent(rivet_thread_private *private);
+EXTERN int Rivet_SendContent (rivet_thread_private *private);
EXTERN Tcl_Interp* Rivet_CreateTclInterp (server_rec* s);
/* temporary content generation handler */
@@ -321,4 +322,27 @@ EXTERN int RivetContent (rivet_thread_pr
#define HTTP_REQUESTS_PROC(request_proc_call) request_proc_call;
#endif
+/* avoids unnecessary verbosity of repetitive code in functions
+ * overlaying and merging configuration records
+ */
+
+#define RIVET_CONF_SELECT(selected,base,overlay,field) \
+ selected->field = overlay->field ? overlay->field : base->field;
+
+#define RIVET_SCRIPT_INIT(running_script,rivet_conf_rec,objscript) \
+ if (rivet_conf_rec->objscript == NULL) {\
+ running_script->objscript = Tcl_NewStringObj("",-1);\
+ } else {\
+ running_script->objscript = Tcl_NewStringObj(rivet_conf_rec->objscript,-1);\
+ }\
+ Tcl_IncrRefCount(running_script->objscript);
+
+#define RIVET_NULL_SCRIPT_INIT(running_script,rivet_conf_rec,objscript) \
+ if (rivet_conf_rec->objscript == NULL) {\
+ running_script->objscript = NULL;\
+ } else {\
+ running_script->objscript = Tcl_NewStringObj(rivet_conf_rec->objscript,-1);\
+ Tcl_IncrRefCount(running_script->objscript);\
+ }\
+
#endif /* MOD_RIVET_H */
Modified: tcl/rivet/trunk/src/experimental/rivetInspect.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/rivetInspect.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/rivetInspect.c (original)
+++ tcl/rivet/trunk/src/experimental/rivetInspect.c Fri Sep 5 17:20:54 2014
@@ -107,8 +107,9 @@ Rivet_ReadConfParameter ( Tcl_Interp*
rivet_server_conf* rsc,
Tcl_Obj* par_name)
{
- int parameter_i;
- Tcl_Obj* par_value = NULL;
+ int parameter_i;
+ Tcl_Obj* int_value = NULL;
+ char* string_value = NULL;
if (Tcl_GetIndexFromObj(interp, par_name, confDirectives,
"<one of mod_rivet configuration directives>", 0, ¶meter_i) == TCL_ERROR) {
@@ -117,88 +118,46 @@ Rivet_ReadConfParameter ( Tcl_Interp*
switch (parameter_i)
{
- case server_init_script:
- {
- par_value = rsc->rivet_server_init_script;
- break;
- }
- case global_init_script:
- {
- par_value = rsc->rivet_global_init_script;
- break;
- }
- case child_init_script:
- {
- par_value = rsc->rivet_child_init_script;
- break;
- }
- case child_exit_script:
- {
- par_value = rsc->rivet_child_exit_script;
- break;
- }
- case before_script:
- {
- par_value = rsc->rivet_before_script;
- break;
- }
- case after_script:
- {
- par_value = rsc->rivet_after_script;
- break;
- }
- case after_every_script:
- {
- par_value = rsc->after_every_script;
- break;
- }
- case abort_script:
- {
- par_value = rsc->rivet_abort_script;
- break;
- }
- case error_script:
- {
- par_value = rsc->rivet_error_script;
- break;
- }
- case upload_max:
- {
- par_value = Tcl_NewIntObj(rsc->upload_max);
- break;
- }
- case upload_directory:
- {
- par_value = Tcl_NewStringObj(rsc->upload_dir,-1);
- break;
- }
- case upload_files_to_var:
- {
- par_value = Tcl_NewIntObj(rsc->upload_files_to_var);
- break;
- }
- case separate_virtual_interps:
- {
- par_value = Tcl_NewIntObj(rsc->separate_virtual_interps);
- break;
- }
- case honor_header_only_requests:
- {
- par_value = Tcl_NewIntObj(rsc->honor_header_only_reqs);
- break;
- }
- default:
- {
- return NULL;
- }
+ case server_init_script: string_value = rsc->rivet_server_init_script; break;
+ case global_init_script: string_value = rsc->rivet_global_init_script; break;
+ case child_init_script: string_value = rsc->rivet_child_init_script; break;
+ case child_exit_script: string_value = rsc->rivet_child_exit_script; break;
+ case before_script: string_value = rsc->rivet_before_script; break;
+ case after_script: string_value = rsc->rivet_after_script; break;
+ case after_every_script: string_value = rsc->after_every_script; break;
+ case abort_script: string_value = rsc->rivet_abort_script; break;
+ case error_script: string_value = rsc->rivet_error_script; break;
+ case upload_directory: string_value = (char *)rsc->upload_dir; break;
+ case upload_max: int_value = Tcl_NewIntObj(rsc->upload_max); break;
+ case upload_files_to_var: int_value = Tcl_NewIntObj(rsc->upload_files_to_var); break;
+ case separate_virtual_interps: int_value = Tcl_NewIntObj(rsc->separate_virtual_interps); break;
+ case honor_header_only_requests: int_value = Tcl_NewIntObj(rsc->honor_header_only_reqs); break;
+ default: return NULL;
}
- if (par_value == NULL)
+ /* if int_value == NULL and string_value == NULL
+ * we have to return one of the string valued options
+ * which is underfined, thus we gave it the conventional
+ * value "<undefined>"
+ */
+
+ if ((string_value == NULL) && (int_value == NULL))
{
- par_value = Tcl_NewStringObj("undefined",-1);
+ return Tcl_NewStringObj("undefined",-1);
+ }
+ else if (string_value != NULL)
+ {
+ /* otherwise if string_value is defined we return it as Tcl_Obj*/
+
+ return Tcl_NewStringObj(string_value,-1);
+ }
+ else
+ {
+ /* there is no other possible case: int_value must be returned */
+
+ return int_value;
}
- return par_value;
}
/*
Modified: tcl/rivet/trunk/src/experimental/rivet_aprthread_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/rivet_aprthread_mpm.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/rivet_aprthread_mpm.c (original)
+++ tcl/rivet/trunk/src/experimental/rivet_aprthread_mpm.c Fri Sep 5 17:20:54 2014
@@ -71,24 +71,32 @@ static void supervisor_housekeeping (voi
int Rivet_MPM_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s)
{
Tcl_Interp* interp;
+ Tcl_Obj* server_init;
rivet_server_conf* rsc = RIVET_SERVER_CONF( s->module_config );
interp = Rivet_CreateTclInterp(s) ; /* Tcl server init interpreter */
Rivet_PerInterpInit(interp,s,pPool);
if (rsc->rivet_server_init_script != NULL) {
+ server_init = Tcl_NewStringObj(rsc->rivet_server_init_script,-1);
+ Tcl_IncrRefCount(server_init);
- if (Tcl_EvalObjEx(interp, rsc->rivet_server_init_script, 0) != TCL_OK)
+ if (Tcl_EvalObjEx(interp, server_init, 0) != TCL_OK)
{
+
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": Error running ServerInitScript '%s': %s",
- Tcl_GetString(rsc->rivet_server_init_script),
+ rsc->rivet_server_init_script,
Tcl_GetVar(interp, "errorInfo", 0));
+
} else {
+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
MODNAME ": ServerInitScript '%s' successful",
- Tcl_GetString(rsc->rivet_server_init_script));
+ rsc->rivet_server_init_script);
+
}
+ Tcl_DecrRefCount(server_init);
}
Tcl_DeleteInterp(interp);
Modified: tcl/rivet/trunk/src/experimental/rivet_prefork_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/rivet_prefork_mpm.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/rivet_prefork_mpm.c (original)
+++ tcl/rivet/trunk/src/experimental/rivet_prefork_mpm.c Fri Sep 5 17:20:54 2014
@@ -55,7 +55,6 @@ apr_status_t Rivet_MPM_Finalize (void* d
int Rivet_MPM_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s)
{
rivet_server_conf* rsc = RIVET_SERVER_CONF( s->module_config );
- //Tcl_Channel* outchannel;
FILEDEBUGINFO;
@@ -77,18 +76,23 @@ int Rivet_MPM_ServerInit (apr_pool_t *pP
if (rsc->rivet_server_init_script != NULL) {
Tcl_Interp* interp = module_globals->server_interp->interp;
+ Tcl_Obj* server_init = Tcl_NewStringObj(rsc->rivet_server_init_script,-1);
- if (Tcl_EvalObjEx(interp, rsc->rivet_server_init_script, 0) != TCL_OK)
+ Tcl_IncrRefCount(server_init);
+
+ if (Tcl_EvalObjEx(interp, server_init, 0) != TCL_OK)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": Error running ServerInitScript '%s': %s",
- Tcl_GetString(rsc->rivet_server_init_script),
+ rsc->rivet_server_init_script,
Tcl_GetVar(interp, "errorInfo", 0));
} else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
MODNAME ": ServerInitScript '%s' successful",
- Tcl_GetString(rsc->rivet_server_init_script));
+ rsc->rivet_server_init_script);
}
+
+ Tcl_DecrRefCount(server_init);
}
Tcl_SetPanicProc(Rivet_Panic);
Modified: tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c?rev=1622742&r1=1622741&r2=1622742&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c (original)
+++ tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c Fri Sep 5 17:20:54 2014
@@ -32,6 +32,7 @@
#include "httpd.h"
#include "rivetChannel.h"
#include "apache_config.h"
+#include "rivet_config.h"
#define BRIDGE_SUPERVISOR_WAIT 1000000
@@ -134,7 +135,6 @@ static void* APR_THREAD_FUNC request_pro
if (Rivet_VirtualHostsInterps (private) == NULL)
{
- apr_thread_mutex_lock(module_globals->job_mutex);
*(apr_thread_t **) apr_array_push(module_globals->exiting) = thd;
apr_thread_cond_signal(module_globals->job_cond);
apr_thread_mutex_unlock(module_globals->job_mutex);
@@ -294,7 +294,7 @@ static void supervisor_housekeeping (voi
static void* APR_THREAD_FUNC threaded_bridge_supervisor(apr_thread_t *thd, void *data)
{
server_rec* s = (server_rec *)data;
-#ifdef RIVET_MPM_SINGLE_THREAD
+#ifdef RIVET_MPM_SINGLE_TCL_THREAD
int thread_to_start = 1;
#else
int thread_to_start = (int)round(module_globals->mpm_max_threads);
@@ -381,24 +381,32 @@ static void* APR_THREAD_FUNC threaded_br
int Rivet_MPM_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s)
{
Tcl_Interp* interp;
+ Tcl_Obj* server_init;
rivet_server_conf* rsc = RIVET_SERVER_CONF( s->module_config );
interp = Rivet_CreateTclInterp(s) ; /* Tcl server init interpreter */
Rivet_PerInterpInit(interp,s,pPool);
- if (rsc->rivet_server_init_script != NULL) {
- if (Tcl_EvalObjEx(interp, rsc->rivet_server_init_script, 0) != TCL_OK)
+ if (rsc->rivet_server_init_script != NULL) {
+ server_init = Tcl_NewStringObj(rsc->rivet_server_init_script,-1);
+ Tcl_IncrRefCount(server_init);
+ if (Tcl_EvalObjEx(interp, server_init, 0) != TCL_OK)
{
+
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": Error running ServerInitScript '%s': %s",
- Tcl_GetString(rsc->rivet_server_init_script),
+ rsc->rivet_server_init_script,
Tcl_GetVar(interp, "errorInfo", 0));
+
} else {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
MODNAME ": ServerInitScript '%s' successful",
- Tcl_GetString(rsc->rivet_server_init_script));
+ rsc->rivet_server_init_script);
+
}
+ Tcl_DecrRefCount(server_init);
}
Tcl_DeleteInterp(interp);
@@ -483,8 +491,8 @@ int Rivet_MPM_Request (request_rec* r)
if (request_private == NULL)
{
apr_thread_mutex_lock(module_globals->pool_mutex);
- request_private = apr_palloc(module_globals->pool,sizeof(handler_private));
- request_private->req = TclWeb_NewRequestObject (module_globals->pool);
+ request_private = apr_palloc(module_globals->pool,sizeof(handler_private));
+ request_private->req = TclWeb_NewRequestObject (module_globals->pool);
apr_thread_cond_create(&(request_private->cond), module_globals->pool);
apr_thread_mutex_create(&(request_private->mutex), APR_THREAD_MUTEX_UNNESTED, module_globals->pool);
apr_thread_mutex_unlock(module_globals->pool_mutex);
@@ -512,7 +520,6 @@ int Rivet_MPM_Request (request_rec* r)
else
{
request_private->code = HTTP_INTERNAL_SERVER_ERROR;
- // apr_sleep(100000);
}
return request_private->code;
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org