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/01/08 17:22:47 UTC
[tcl-rivet] 01/01: creating branch quattuor with initial
development for rivet 4
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 dbe71241ff1775336e410f7f116757a71c96e901
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Tue Jan 8 18:22:25 2019 +0100
creating branch quattuor with initial development for rivet 4
---
ChangeLog | 24 +++
VERSION | 2 +-
configure.ac | 1 +
doc/rivet.xml | 47 ++---
rivet/init.tcl | 4 +-
rivet/pkgIndex.tcl | 2 +-
src/librivet/rivetList.c | 4 +-
src/mod_rivet_ng/TclWebapache.c | 6 +-
src/mod_rivet_ng/mod_rivet.c | 301 ++++++++++++++++++++-----------
src/mod_rivet_ng/mod_rivet.h | 33 ++--
src/mod_rivet_ng/mod_rivet_common.c | 134 +++++++++-----
src/mod_rivet_ng/mod_rivet_common.h | 34 ++--
src/mod_rivet_ng/rivetCore.c | 18 +-
src/mod_rivet_ng/rivetCore.h | 2 +-
src/mod_rivet_ng/rivet_lazy_mpm.c | 24 ++-
src/mod_rivet_ng/rivet_prefork_mpm.c | 212 +++++++++++++++++-----
src/mod_rivet_ng/rivet_types.h | 14 +-
src/mod_rivet_ng/rivet_worker_mpm.c | 33 +++-
src/mod_rivet_ng/worker_prefork_common.c | 66 ++-----
src/mod_rivet_ng/worker_prefork_common.h | 4 +-
src/request/apache_multipart_buffer.c | 73 ++++----
src/request/apache_multipart_buffer.h | 28 +--
src/request/apache_request.c | 46 +++--
23 files changed, 704 insertions(+), 408 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d76c670..c6b23b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-01-08 Massimo Manghi <mx...@apache.org>
+ * : new branch quattuor created with an initial commit that tries
+ to remodel the initialization, optimize intepreter creation, remove
+ unneeded structures and other data keeping in mind the goal of
+ abating complexity
+
2019-01-05 Massimo Manghi <mx...@apache.org>
* doc/: merging from 3.1 fixes to various broken docbook elements
and new entities to external resources' URLs
@@ -20,6 +26,19 @@
installation directory of rivetlib, after files have been installed.
This executes "tclsh".
+2018-12-18 Massimo Manghi <mx...@apache.org>
+ * rivet/pkgIndex.tcl: update rivetlib version. The CMake build script doesn't run
+ pkg_mkIndex in order to update this file, so we still have to keep the package version
+ aligned with the those actually provided.
+
+2018-12-17 Massimo Manghi <mx...@apache.org>
+ * VERSION: changing version to 3.2.1 attempting to trigger an appveyor rebuild
+ * src/request/apache_request.c,src/request/apache_multipart_buffer.[c|h]:
+ explicit cast to int wherever needed by calls to Tcl_* functions and changed
+ int to size_t wherever required
+ * src/mod_rivet_ng/rivet_types.h,rivetCore.c: field 'size' in structure typed as size_t
+ * src/mod_rivet_ng/TclWebapache.c: argument to Tcl_ReadChars explicitly cast to int
+
2018-12-17 Georgios Petasis <pe...@apache.org>
* Readme.md: Added a separate badge for winbuild branch.
@@ -38,6 +57,11 @@
* src/mod_rivet_ng/mod_rivet.h: Removed statement "APLOG_USE_MODULE(rivet);"
from the module header file.
+2018-12-08 Massimo Manghi <mx...@apache.org>
+ * cmake/CMakeList.c: changed suffix of librivetparser.so and librivet.so
+ * src/mod_rivet_ng: various changes to have a compilable module
+ on Windows. Still the module not working tough
+
2018-12-07 Massimo Manghi <mx...@apache.org>
* rivet/pkgIndex.tcl: completed with actual list of packages
diff --git a/VERSION b/VERSION
index 944880f..fcdb2e1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.2.0
+4.0.0
diff --git a/configure.ac b/configure.ac
index b652bf9..1f5c279 100644
--- a/configure.ac
+++ b/configure.ac
@@ -836,6 +836,7 @@ RIVET_CORE_CMDS
RIVET_CHANNEL
SINGLE_WORKER_TCL_THREAD
HTTP_REQUESTS_MUTEX
+AC_HEADER_STDBOOL
# Let's separate the point version from the major and minor version
# to build a Rivet version to be substituted as basic version for
diff --git a/doc/rivet.xml b/doc/rivet.xml
index 89f940f..4aa257f 100644
--- a/doc/rivet.xml
+++ b/doc/rivet.xml
@@ -35,40 +35,43 @@
<!ENTITY asciiglyphs.xml SYSTEM "xml/asciiglyphs.xml" >
<!ENTITY lazybridge.xml SYSTEM "xml/lazybridge.xml" >
<!ENTITY formbroker.xml SYSTEM "xml/formbroker.xml" >
- <!ENTITY version "3.2" >
- <!ENTITY fullversion "3.2.0" >
- <!ENTITY version2-series "2.0,2.1,2.2,2.3" >
- <!ENTITY version2-generic "2.x" >
- <!ENTITY version30 "3.0" >
- <!ENTITY version31 "3.1" >
+ <!ENTITY version "4.0" >
+ <!ENTITY fullversion "4.0.0" >
+ <!ENTITY version2-series "2.0,2.1,2.2,2.3" >
+ <!ENTITY version2-generic "2.x" >
+ <!ENTITY version30 "3.0" >
+ <!ENTITY version31 "3.1" >
<!ENTITY tcltk-url "http://www.tcl.tk/" >
<!ENTITY apache-url "http://httpd.apache.org" >
+ <!ENTITY apache-apr "http://apr.apache.org/" >
+ <!ENTITY apache-apreq "http://httpd.apache.org/apreq/" >
+ <!ENTITY rivet-download "http://tcl.apache.org/rivet/html/download.html" >
<!ENTITY apachedoc-vhost "https://httpd.apache.org/docs/2.4/vhosts" >
- <!ENTITY apachedoc-mpm "https://httpd.apache.org/docs/2.4/mpm.html" >
- <!ENTITY apachedoc-prefork "https://httpd.apache.org/docs/2.4/mod/prefork.html" >
- <!ENTITY apachedoc-worker "https://httpd.apache.org/docs/2.4/mod/worker.html" >
- <!ENTITY apachedoc-event "https://httpd.apache.org/docs/2.4/mod/event.html" >
- <!ENTITY apachedoc-winnt "https://httpd.apache.org/docs/2.4/mod/mpm_winnt.html" >
+ <!ENTITY apachedoc-mpm "https://httpd.apache.org/docs/2.4/mpm.html" >
+ <!ENTITY apachedoc-prefork "https://httpd.apache.org/docs/2.4/mod/prefork.html" >
+ <!ENTITY apachedoc-worker "https://httpd.apache.org/docs/2.4/mod/worker.html" >
+ <!ENTITY apachedoc-event "https://httpd.apache.org/docs/2.4/mod/event.html" >
+ <!ENTITY apachedoc-winnt "https://httpd.apache.org/docs/2.4/mod/mpm_winnt.html" >
<!ENTITY apachedoc-docroot "https://httpd.apache.org/docs/2.4/mod/core.html#documentroot" >
- <!ENTITY apachedoc-alias "https://httpd.apache.org/docs/2.4/mod/mod_alias.html" >
+ <!ENTITY apachedoc-alias "https://httpd.apache.org/docs/2.4/mod/mod_alias.html" >
<!ENTITY apachedoc-rewrite "https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html" >
<!ENTITY apachedoc-perftuning "https://httpd.apache.org/docs/2.4/misc/perf-tuning.html" >
]>
<!--
- Copyright 2002-2005 The Apache Software Foundation
+ Copyright 2002-2019 The Apache Tcl Team
- Licensed under the Apache License, Version 2.0 (the "License"); you
- may not use this file except in compliance with the License. You
- may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied. See the License for the specific language governing
- permissions and limitations under the License.
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
-->
<article>
diff --git a/rivet/init.tcl b/rivet/init.tcl
index 657ffc7..f3b5a90 100644
--- a/rivet/init.tcl
+++ b/rivet/init.tcl
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package require rivetlib 3.2
+package require rivetlib 4.0
# the ::rivet namespace is created in mod_rivet_commoc.c:Rivet_PerInterpInit
# namespace eval ::rivet {} ; ## create namespace
@@ -259,4 +259,4 @@ proc ::Rivet::tcl_commands_export_list {tclpath} {
::Rivet::init
-package provide Rivet 3.2
+package provide Rivet 4.0
diff --git a/rivet/pkgIndex.tcl b/rivet/pkgIndex.tcl
index db51d5c..a01b7df 100644
--- a/rivet/pkgIndex.tcl
+++ b/rivet/pkgIndex.tcl
@@ -23,7 +23,7 @@ package ifneeded dio_Tdbc 0.1 [list source [file join $dir packages/dio/dio_Tdbc
package ifneeded form 1.0 [list source [file join $dir packages/form/form.tcl]]
package ifneeded form 2.1 [list source [file join $dir packages/form/form2.tcl]]
package ifneeded formbroker 1.0 [list source [file join $dir packages/formbroker/formbroker.tcl]]
-package ifneeded rivetlib 3.2.0 [list load [file join $dir librivetlib.so]]
+package ifneeded rivetlib 3.2.1 [list load [file join $dir librivetlib.so]]
package ifneeded rivetparser 0.2 [list load [file join $dir librivetparser.so]]
package ifneeded tclrivet 0.1 [list source [file join $dir packages/tclrivet/tclrivet.tcl]]
package ifneeded tclrivetparser 0.1 [list source [file join $dir packages/tclrivet/tclrivetparser.tcl]]
diff --git a/src/librivet/rivetList.c b/src/librivet/rivetList.c
index 4847acf..5884756 100644
--- a/src/librivet/rivetList.c
+++ b/src/librivet/rivetList.c
@@ -464,10 +464,10 @@ Rivet_CommaJoinObjCmd (notUsed, interp, objc, objv)
* calculations right!
*/
- Tcl_AppendToObj (resultPtr, strPtr, walkPtr - strPtr);
+ Tcl_AppendToObj (resultPtr, strPtr, (int)(walkPtr - strPtr));
strPtr = walkPtr - 1;
}
- Tcl_AppendToObj (resultPtr, strPtr, walkPtr - strPtr);
+ Tcl_AppendToObj (resultPtr, strPtr, (int)(walkPtr - strPtr));
}
Tcl_AppendToObj (resultPtr, "\"", 1);
return TCL_OK;
diff --git a/src/mod_rivet_ng/TclWebapache.c b/src/mod_rivet_ng/TclWebapache.c
index 0f3b1ec..2446072 100644
--- a/src/mod_rivet_ng/TclWebapache.c
+++ b/src/mod_rivet_ng/TclWebapache.c
@@ -96,7 +96,7 @@ TclWeb_InitRequest(rivet_thread_private* private, Tcl_Interp *interp)
{
request_rec* r = private->r;
TclWebRequest* req = private->req;
- int content_type_len = strlen(r->content_type);
+ size_t content_type_len = strlen(r->content_type);
req->interp = interp;
req->req = r;
@@ -725,7 +725,7 @@ int TclWeb_UploadData(char *varname, Tcl_Obj *data, TclWebRequest *req)
}
/* Put data in a variable */
- Tcl_ReadChars(chan, data, ApacheUpload_size(req->upload), 0);
+ Tcl_ReadChars(chan, data, (int)ApacheUpload_size(req->upload), 0);
if (Tcl_Close(req->interp, chan) == TCL_ERROR) {
return TCL_ERROR;
}
@@ -739,7 +739,7 @@ int TclWeb_UploadData(char *varname, Tcl_Obj *data, TclWebRequest *req)
int TclWeb_UploadSize(Tcl_Obj *sz, TclWebRequest *req)
{
- Tcl_SetIntObj(sz, ApacheUpload_size(req->upload));
+ Tcl_SetIntObj(sz, (int)ApacheUpload_size(req->upload));
return TCL_OK;
}
diff --git a/src/mod_rivet_ng/mod_rivet.c b/src/mod_rivet_ng/mod_rivet.c
index 6cb94a5..0c2dd75 100644
--- a/src/mod_rivet_ng/mod_rivet.c
+++ b/src/mod_rivet_ng/mod_rivet.c
@@ -19,8 +19,6 @@
under the License.
*/
-/* $Id$ */
-
/* Rivet config */
#ifdef HAVE_CONFIG_H
#include <rivet_config.h>
@@ -57,7 +55,7 @@
#include "apache_config.h"
/* Function prototypes are defined with EXTERN. Since we are in the same DLL,
- * no need to keep this extern... */
+* no need to keep this extern... */
#ifdef EXTERN
# undef EXTERN
# define EXTERN
@@ -66,19 +64,41 @@
#include "mod_rivet_common.h"
#include "mod_rivet_generator.h"
-module AP_MODULE_DECLARE_DATA rivet_module;
-extern Tcl_ChannelType RivetChan;
-DLLEXPORT apr_threadkey_t* rivet_thread_key = NULL;
-DLLEXPORT mod_rivet_globals* module_globals = NULL;
+/*
+* Macros DLLIMPORT and DLLEXPORT are defined in tcl.h
+*/
+
+extern Tcl_ChannelType RivetChan;
+DLLEXPORT apr_threadkey_t* rivet_thread_key = NULL;
+DLLEXPORT mod_rivet_globals* module_globals = NULL;
+DLLEXPORT module rivet_module;
#define ERRORBUF_SZ 256
#define TCL_HANDLER_FILE RIVET_DIR"/default_request_handler.tcl"
/*
- * -- Rivet_SeekMPMBridge
- *
- *
- */
+* -- Rivet_SeekMPMBridge
+*
+* Determing the bridge name to be loaded following these steps
+*
+* * The RIVET_MPM_BRIDGE environment variable is checked and if
+* existing its definition is taken to be the path to the bridge
+* module
+*
+* * The configuration is checked to see if an mpm_bridge line
+* defined exists (as sepecified with the configuration MpmBridge
+* directive) and if defined:
+*
+* - the string is interpolated with RIVET_MPM_BRIDGE_COMPOSE
+* - if the former step fails the string is
+* interpreted as a full path to a bridge module
+*
+* * if MpmBridge was not defined the code adopt an heuristics based
+* on the response from the call to ap_mpm_query. If
+* the MPM is not threaded we load the prefork bridge
+*
+* * If everything fails the worker bridge is loaded
+*/
static char*
Rivet_SeekMPMBridge (apr_pool_t* pool,server_rec* server)
@@ -154,17 +174,17 @@ Rivet_SeekMPMBridge (apr_pool_t* pool,server_rec* server)
}
/*
- * -- Rivet_CreateModuleGlobals
- *
- * module globals (mod_rivet_globals) allocation and initialization
- *
- */
+* -- Rivet_CreateModuleGlobals
+*
+* module globals (mod_rivet_globals) allocation and initialization
+*
+*/
static mod_rivet_globals*
Rivet_CreateModuleGlobals (apr_pool_t* pool, server_rec* server)
{
mod_rivet_globals* mod_rivet_g;
-
+
mod_rivet_g = apr_palloc(pool,sizeof(mod_rivet_globals));
if (apr_pool_create(&mod_rivet_g->pool, NULL) != APR_SUCCESS)
{
@@ -173,6 +193,12 @@ Rivet_CreateModuleGlobals (apr_pool_t* pool, server_rec* server)
exit(1);
}
+ /* This mutex should protect the process wide pool */
+
+ //apr_thread_mutex_create(&mod_rivet_g->pool_mutex, APR_THREAD_MUTEX_UNNESTED, pool);
+
+ /* establishing the name of the bridge to be loaded */
+
mod_rivet_g->rivet_mpm_bridge = Rivet_SeekMPMBridge(pool,server);
/* read the default request handler code */
@@ -185,23 +211,23 @@ Rivet_CreateModuleGlobals (apr_pool_t* pool, server_rec* server)
MODNAME ": could not read rivet default handler");
exit(1);
}
-
+
/* We cannot assume we are running in an OS with a fork system call
* therefore we have to check module_globals in order to establish if the
* structure has to be allocated
*/
-
+
mod_rivet_g->server = server;
return mod_rivet_g;
}
/*
- * -- Rivet_Exit_Handler
- *
- *
- *
- */
+* -- Rivet_Exit_Handler
+*
+*
+*
+*/
int Rivet_Exit_Handler(int code)
{
@@ -211,93 +237,159 @@ int Rivet_Exit_Handler(int code)
}
/*
- * -- Rivet_RunServerInit
- *
- *
- */
+* -- Rivet_RunServerInit
+*
+* Server initialization
+*
+*/
static int
-Rivet_RunServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s)
+Rivet_RunServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *server)
{
-#ifdef WIN32
- char* parent_pid_var = NULL;
-#endif
- rivet_server_conf* rsc = RIVET_SERVER_CONF( s->module_config );
+ server_rec* s;
+ int idx;
+ rivet_thread_private* private;
FILEDEBUGINFO;
- /* we create and initialize a master (server) interpreter */
-
- module_globals->server_interp = Rivet_NewVHostInterp(pPool,s); /* root interpreter */
-
- /* We initialize the interpreter and we won't register a channel with it because
- * we couldn't send data to the stdout anyway
- */
+#ifdef WIN32
- Rivet_PerInterpInit(module_globals->server_interp,NULL,s,pPool);
+ /* This code conditionally compiled when we are building for the
+ * Windows family of OS. The winnt MPM runs the post_config
+ * hooks after it has spawned a child process but we don't want
+ * to run the Tcl server initialization script again. We
+ * detect we are in a child process by checking
+ * the environment variable AP_PARENT_PID
+ * (https://wiki.apache.org/httpd/ModuleLife)
+ */
- /* This code conditionally compiled when we are building for the
- * Windows family of OS. The winnt MPM runs the post_config
- * hooks after it has spawned a child process but we don't want
- * to run the Tcl server initialization script again. We
- * detect we are in a child process by checking
- * the environment variable AP_PARENT_PID
- * (https://wiki.apache.org/httpd/ModuleLife)
- */
-
- #ifdef WIN32
-
- /* if the environment variable AP_PARENT_PID is set
+ /*
+ * if the environment variable AP_PARENT_PID is set
* we know we are in a child process of the winnt MPM
*/
-
- apr_env_get(&parent_pid_var,"AP_PARENT_PID",pTemp);
- if (parent_pid_var != NULL)
- {
- ap_log_error(APLOG_MARK,APLOG_INFO,0,s,
- "AP_PARENT_PID found: not running the Tcl server script in winnt MPM child process");
- return OK;
- } else {
- ap_log_error(APLOG_MARK,APLOG_INFO,0,s,
- "AP_PARENT_PID undefined, we proceed with server initialization");
- }
-
- #endif
-
- /* We don't create the cache here: it would make sense for prefork MPM
- * but threaded MPM bridges have their pool of threads. Each of them
- * will by now have their own cache
- */
-
- 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);
-
- Tcl_IncrRefCount(server_init);
+ {
+ char* parent_pid_var = NULL;
- if (Tcl_EvalObjEx(interp, server_init, 0) != TCL_OK)
+ apr_env_get(&parent_pid_var,"AP_PARENT_PID",pTemp);
+ if (parent_pid_var != NULL)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- MODNAME ": Error running ServerInitScript '%s': %s",
- rsc->rivet_server_init_script,
- Tcl_GetVar(interp, "errorInfo", 0));
+ ap_log_error(APLOG_MARK,APLOG_DEBUG,0,server,
+ "AP_PARENT_PID found: not running the Tcl server script in winnt MPM child process");
+ return OK;
} else {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
- MODNAME ": ServerInitScript '%s' successful",
- rsc->rivet_server_init_script);
+ ap_log_error(APLOG_MARK,APLOG_DEBUG,0,server,
+ "AP_PARENT_PID undefined, we proceed with server initialization");
}
+ }
+
+#endif
- Tcl_DecrRefCount(server_init);
+ ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pPool) == APR_SUCCESS);
+
+ /* we create the thread private data. Fork capabale OS should be able to replicate
+ * this data in the child process which includes the process memory pool */
+
+ private = Rivet_CreatePrivateData(pPool,false);
+
+ Rivet_SetupTclPanicProc();
+
+ /* In order to know the size of the server_interps array we need
+ * to count the virtual hosts. This is an extra work to do
+ * but it's done only once
+ */
+
+ idx = 0;
+ for (s = server; s != NULL; s = s->next)
+ {
+ rivet_server_conf* vhost_rsc;
+
+ vhost_rsc = RIVET_SERVER_CONF(s->module_config);
+ vhost_rsc->idx = idx++;
}
+ module_globals->vhosts_count = idx;
+ module_globals->server_interps = apr_pcalloc(pPool,module_globals->vhosts_count*sizeof(rivet_thread_interp));
+
+ for (s = server; s != NULL; s = s->next)
+ {
+ rivet_server_conf* vhost_rsc;
+ rivet_thread_interp* interp_obj = NULL;
+
+ vhost_rsc = RIVET_SERVER_CONF(s->module_config);
+
+ if (vhost_rsc->rivet_server_init_script != NULL)
+ {
+ Tcl_Interp* interp;
+ Tcl_Obj* server_init;
+
+ /* either we want separate virtual interps or we haven't
+ * created an interpreter so far we create one
+ */
+
+ if ((interp_obj == NULL) || vhost_rsc->separate_virtual_interps)
+ {
+ interp_obj = Rivet_NewVHostInterp(private,s);
+
+ /* We initialize the interpreter and we won't
+ * register a channel with it because
+ * we couldn't send data to the stdout anyway
+ */
+
+ Rivet_PerInterpInit(interp_obj,private,s,pPool);
+ }
+
+ /* This loop enables the prefork bridge to pick
+ * its interpreters pointer from the module globals
+ */
+
+ module_globals->server_interps[vhost_rsc->idx] = interp_obj;
+
+ /* We don't create the cache here: it would make sense only
+ * for the prefork MPM. Non-fork bridges should do it
+ * themselves
+ */
+
+ interp = interp_obj->interp;
+ server_init = Tcl_NewStringObj(vhost_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, server,
+ MODNAME ": Error running ServerInitScript '%s': %s",
+ vhost_rsc->rivet_server_init_script,
+ Tcl_GetVar(interp, "errorInfo", 0));
+ }
+ else
+ {
+ ap_log_error (APLOG_MARK, APLOG_DEBUG, 0, server,
+ MODNAME ": ServerInitScript '%s' successful",
+ vhost_rsc->rivet_server_init_script);
+ }
+
+ Tcl_DecrRefCount(server_init);
+
+ }
+ else if (s == server)
+ {
+ /* an interpreter on the initial position is always set */
+ interp_obj = Rivet_NewVHostInterp(private,s);
+ Rivet_PerInterpInit(interp_obj,private,s,pPool);
+ module_globals->server_interps[vhost_rsc->idx] = interp_obj;
+ }
+
+ }
+
/* bridge specific server init script */
- RIVET_MPM_BRIDGE_CALL(server_init,pPool,pLog,pTemp,s);
+ RIVET_MPM_BRIDGE_CALL(server_init,pPool,pLog,pTemp,server);
return OK;
}
-/* -- Rivet_ServerInit
+/*
+ * -- Rivet_ServerInit
*
* Post config hook. The server initialization loads the MPM bridge
* and runs the Tcl server initialization script
@@ -317,9 +409,8 @@ Rivet_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server
ap_add_version_component(pPool,RIVET_PACKAGE_NAME);
#endif
- /* This function runs as post_config_hook
- * and as such it's run twice by design.
- * This is the recommended way to avoid a double load of
+ /* This function runs as post_config_hook and as such it's run twice
+ * by design. This is the recommended way to avoid a double load of
* external modules.
*/
@@ -335,9 +426,8 @@ Rivet_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server
return OK; /* This would be the first time through */
}
- /* Everything revolves around this structure: module_globals */
-
- /* the module global structure is allocated and the MPM bridge name established */
+ /* Everything revolves around this structure: module_globals. The structure
+ * is allocated and the MPM bridge name is established */
module_globals = Rivet_CreateModuleGlobals (pPool,server);
@@ -371,7 +461,7 @@ Rivet_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server
ap_assert(RIVET_MPM_BRIDGE_FUNCTION(request_processor) != NULL);
ap_assert(RIVET_MPM_BRIDGE_FUNCTION(thread_interp) != NULL);
- apr_thread_mutex_create(&module_globals->pool_mutex, APR_THREAD_MUTEX_UNNESTED, pPool);
+ //apr_thread_mutex_create(&module_globals->pool_mutex, APR_THREAD_MUTEX_UNNESTED, pPool);
}
else
@@ -411,10 +501,6 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server)
rivet_server_conf* root_server_conf;
server_rec* s;
- /* the thread key used to access to Tcl threads private data */
-
- ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pChild) == APR_SUCCESS);
-
/* This code is run once per child process. In a threaded Tcl builds the forking
* of a child process most likely has not preserved the thread where the Tcl
* notifier runs. The Notifier should have been restarted by one the
@@ -427,23 +513,19 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server)
Tcl_InitNotifier();
#endif
+ /* for any non-prefork bridge the module globals are to be created here */
+
if (module_globals == NULL)
{
- module_globals = Rivet_CreateModuleGlobals (pChild,server);
+ module_globals = Rivet_CreateModuleGlobals(pChild,server);
}
- /* This mutex should protect the process wide pool from concurrent access by
- * different threads
- */
-
- apr_thread_mutex_create(&module_globals->pool_mutex, APR_THREAD_MUTEX_UNNESTED, pChild);
-
/* Once we have established a pool with the same lifetime of the child process we
* process all the configured server records assigning an integer as unique key
* to each of them
*/
- root_server_conf = RIVET_SERVER_CONF( server->module_config );
+ root_server_conf = RIVET_SERVER_CONF(server->module_config);
idx = 0;
for (s = server; s != NULL; s = s->next)
{
@@ -455,10 +537,11 @@ static void Rivet_ChildInit (apr_pool_t *pChild, server_rec *server)
* was called. We really need a separate one for each server,
* so we go ahead and create one here, if necessary. */
- if (s != server && myrsc == root_server_conf) {
+ if (s != server && myrsc == root_server_conf)
+ {
myrsc = RIVET_NEW_CONF(pChild);
ap_set_module_config(s->module_config, &rivet_module, myrsc);
- Rivet_CopyConfig( root_server_conf, myrsc );
+ Rivet_CopyConfig(root_server_conf,myrsc);
}
myrsc->idx = idx++;
diff --git a/src/mod_rivet_ng/mod_rivet.h b/src/mod_rivet_ng/mod_rivet.h
index a3633a5..8f8c476 100644
--- a/src/mod_rivet_ng/mod_rivet.h
+++ b/src/mod_rivet_ng/mod_rivet.h
@@ -19,8 +19,6 @@
under the License.
*/
-/* $Id$ */
-
#ifndef __mod_rivet_h__
#define __mod_rivet_h__
@@ -116,11 +114,11 @@ typedef struct _rivet_server_conf {
char* rivet_before_script; /* script run before each page */
char* rivet_after_script; /* after */
- /* --------------------------------------------------------------------------- */
+ /* ------------------------------------------------------------------------ */
/* This flag is used with the above directives. If any of them have changed, it gets set. */
- unsigned int user_scripts_status;
+ unsigned int user_scripts_status;
int default_cache_size;
int upload_max;
@@ -173,6 +171,7 @@ typedef struct _rivet_thread_interp {
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 */
+ Tcl_Namespace* rivet_ns; /* the ::rivet namespace internal representation */
} rivet_thread_interp;
typedef struct _thread_worker_private rivet_thread_private;
@@ -199,20 +198,19 @@ typedef struct _mpm_bridge_table {
typedef struct mpm_bridge_status mpm_bridge_status;
typedef struct _mod_rivet_globals {
- apr_pool_t* pool;
- char* rivet_mpm_bridge; /* name of the MPM bridge */
- server_rec* server; /* default host server_rec obj */
- int vhosts_count; /* Number of configured virtual host including
- * the root server thus it's supposed to be >= 1 */
- char* default_handler; /* Default request handler code */
- int default_handler_size; /* Size of the default_handler buffer */
- rivet_thread_interp*
- server_interp; /* server and prefork MPM interpreter */
- apr_thread_mutex_t* pool_mutex; /* threads commmon pool mutex */
- rivet_bridge_table* bridge_jump_table; /* Jump table to bridge specific procedures */
- mpm_bridge_status* mpm; /* bridge private control structure */
+ apr_pool_t* pool;
+ char* rivet_mpm_bridge; /* name of the MPM bridge */
+ server_rec* server; /* default host server_rec obj */
+ int vhosts_count; /* Number of configured virtual host including
+ * the root server thus it's supposed to be >= 1 */
+ char* default_handler; /* Default request handler code */
+ int default_handler_size; /* Size of the default_handler buffer */
+ rivet_thread_interp** server_interps; /* server and prefork MPM interpreter */
+ //apr_thread_mutex_t* pool_mutex; /* threads commmon pool mutex */
+ rivet_bridge_table* bridge_jump_table; /* Jump table to bridge specific procedures */
+ mpm_bridge_status* mpm; /* bridge private control structure */
#ifdef RIVET_SERIALIZE_HTTP_REQUESTS
- apr_thread_mutex_t* req_mutex;
+ apr_thread_mutex_t* req_mutex;
#endif
} mod_rivet_globals;
@@ -225,7 +223,6 @@ typedef struct _thread_worker_private {
rivet_req_ctype ctype; /* */
request_rec* r; /* current request_rec */
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 */
diff --git a/src/mod_rivet_ng/mod_rivet_common.c b/src/mod_rivet_ng/mod_rivet_common.c
index 7c3b8a8..3da2ba6 100644
--- a/src/mod_rivet_ng/mod_rivet_common.c
+++ b/src/mod_rivet_ng/mod_rivet_common.c
@@ -21,14 +21,13 @@
under the License.
*/
-/* $Id$ */
-
#include <httpd.h>
#include <apr_strings.h>
#include <apr_env.h>
#include <ap_mpm.h>
#include <apr_file_io.h>
#include <apr_file_info.h>
+#include <mpm_common.h>
#include "mod_rivet.h"
#include "rivetChannel.h"
@@ -36,7 +35,7 @@
#include "rivetParser.h"
#include "rivet.h"
#include "apache_config.h"
-#include <mpm_common.h>
+
/* as long as we need to emulate ap_chdir_file we need to include unistd.h */
#ifdef RIVET_HAVE_UNISTD_H
@@ -58,7 +57,37 @@
extern apr_threadkey_t* rivet_thread_key;
extern mod_rivet_globals* module_globals;
-extern module rivet_module;
+extern module rivet_module;
+
+/*
+ * Rivet_DuplicateVhostInterp
+ *
+ *
+ */
+
+rivet_thread_interp*
+Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj)
+{
+ rivet_thread_interp* interp_obj = apr_pcalloc(pool,sizeof(rivet_thread_interp));
+
+ interp_obj->interp = source_obj->interp;
+ interp_obj->channel = source_obj->channel;
+ interp_obj->cache_free = source_obj->cache_free;
+ interp_obj->cache_size = source_obj->cache_size;
+ interp_obj->rivet_ns = source_obj->rivet_ns;
+
+ /* An intepreter must have its own cache */
+
+ if (interp_obj->cache_size) {
+ RivetCache_Create(pool,interp_obj);
+ }
+
+ interp_obj->pool = source_obj->pool;
+ interp_obj->scripts = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts));
+ interp_obj->per_dir_scripts = apr_hash_make(pool);
+ interp_obj->flags = source_obj->flags;
+ return interp_obj;
+}
/*
* -- Rivet_ReadFile
@@ -66,12 +95,11 @@ extern module rivet_module;
*/
int
-Rivet_ReadFile (apr_pool_t* pool,char* filename,
- char** buffer,int* nbytes)
+Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes)
{
- apr_finfo_t* file_info;
- apr_file_t* apr_fp;
- apr_size_t buffer_size;
+ apr_finfo_t* file_info;
+ apr_file_t* apr_fp;
+ apr_size_t buffer_size;
*nbytes = 0;
@@ -166,14 +194,20 @@ running_scripts* Rivet_RunningScripts ( apr_pool_t* pool,
{
char* request_handler;
int handler_size;
-
+
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, module_globals->server,
+ MODNAME ": reading request handler %s",rivet_conf->request_handler);
+
ap_assert(Rivet_ReadFile(pool,rivet_conf->request_handler,
&request_handler,&handler_size) == 0);
- scripts->request_processing =
- Tcl_NewStringObj(request_handler,handler_size);
+ scripts->request_processing = Tcl_NewStringObj(request_handler,handler_size);
} else {
+
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, module_globals->server,
+ MODNAME ": reading default request handler %s",module_globals->default_handler);
+
scripts->request_processing =
Tcl_NewStringObj(module_globals->default_handler,
module_globals->default_handler_size);
@@ -203,7 +237,7 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
server_rec *s,
apr_pool_t *p)
{
- rivet_interp_globals* globals = NULL;
+ // rivet_interp_globals* globals = NULL;
Tcl_Obj* auto_path = NULL;
Tcl_Obj* rivet_tcl = NULL;
Tcl_Interp* interp = interp_obj->interp;
@@ -213,8 +247,8 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
/* Set up interpreter associated data */
- globals = ckalloc(sizeof(rivet_interp_globals));
- Tcl_SetAssocData (interp,"rivet",NULL,globals);
+ //globals = ckalloc(sizeof(rivet_interp_globals));
+ //Tcl_SetAssocData (interp,"rivet",NULL,globals);
/*
* the ::rivet namespace is the only information still stored
@@ -223,8 +257,8 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
/* Rivet commands namespace is created */
- globals->rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,NULL,
- (Tcl_NamespaceDeleteProc *)NULL);
+ interp_obj->rivet_ns =
+ Tcl_CreateNamespace (interp,RIVET_NS,private,(Tcl_NamespaceDeleteProc *)NULL);
/* We put in front the auto_path list the path to the directory where
* init.tcl is located (provides package Rivet, previously RivetTcl)
@@ -260,7 +294,7 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
if (private != NULL) private->running_conf = RIVET_SERVER_CONF (s->module_config);
/* Initialize the interpreter with Rivet's Tcl commands. */
- Rivet_InitCore(interp,private);
+ Rivet_InitCore(interp_obj,private);
/* Create a global array with information about the server. */
Rivet_InitServerVariables(interp,p);
@@ -275,11 +309,11 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
* across patchlevel releases
*/
- if (Tcl_PkgRequire(interp, "Rivet", RIVET_INIT_VERSION, 1) == NULL)
+ if (Tcl_PkgRequire(interp,"Rivet",RIVET_INIT_VERSION,1) == NULL)
{
- ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ ap_log_error (APLOG_MARK,APLOG_ERR,APR_EGENERAL,s,
MODNAME ": init.tcl must be installed correctly for Apache Rivet to function: %s (%s)",
- Tcl_GetStringResult(interp), RIVET_DIR );
+ Tcl_GetStringResult(interp),RIVET_DIR);
exit(1);
}
@@ -301,8 +335,9 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
*
*/
-rivet_thread_interp* Rivet_NewVHostInterp(apr_pool_t *pool,server_rec* server)
+rivet_thread_interp* Rivet_NewVHostInterp(rivet_thread_private* private,server_rec* server)
{
+ apr_pool_t* pool = private->pool;
rivet_thread_interp* interp_obj = apr_pcalloc(pool,sizeof(rivet_thread_interp));
rivet_server_conf* rsc;
@@ -313,12 +348,9 @@ rivet_thread_interp* Rivet_NewVHostInterp(apr_pool_t *pool,server_rec* server)
/* This calls needs the root server_rec just for logging purposes */
interp_obj->interp = Rivet_CreateTclInterp(server);
-
- /* We now read from the pointers to the cache_size and cache_free conf parameters
- * for compatibility with mod_rivet current version, but these values must become
- * integers not pointers
- */
+ /* We establish the cache size */
+
if (rsc->default_cache_size < 0) {
if (ap_max_requests_per_child != 0) {
interp_obj->cache_size = ap_max_requests_per_child / 5;
@@ -361,11 +393,11 @@ rivet_thread_interp* Rivet_NewVHostInterp(apr_pool_t *pool,server_rec* server)
*
* -- Rivet_CreateRivetChannel
*
- * Creates a channel and registers with to the interpreter
+ * Creates a channel
*
* Arguments:
*
- * - apr_pool_t* pPool: a pointer to an APR memory pool
+ * - apr_pool_t* pPool: a pointer to an APR memory pool
*
* Returned value:
*
@@ -438,38 +470,56 @@ Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel)
*
* Arguments:
*
- * - apr_threadkey_t* rivet_thread_key
+ * - 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
*
* Returned value:
*
- * - rivet_thread_private* private data object
+ * - rivet_thread_private* thread private data structure instance
*
*-----------------------------------------------------------------------------
*/
-rivet_thread_private* Rivet_CreatePrivateData (void)
+rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* pPool,bool create_request_obj)
{
rivet_thread_private* private;
ap_assert (apr_threadkey_private_get ((void **)&private,rivet_thread_key) == APR_SUCCESS);
- apr_thread_mutex_lock(module_globals->pool_mutex);
- private = apr_pcalloc (module_globals->pool,sizeof(*private));
- apr_thread_mutex_unlock(module_globals->pool_mutex);
+ //apr_thread_mutex_lock(module_globals->pool_mutex);
+ private = apr_pcalloc (pPool,sizeof(*private));
+ //apr_thread_mutex_unlock(module_globals->pool_mutex);
- if (apr_pool_create (&private->pool, NULL) != APR_SUCCESS)
+ /*
+ if (create_pool)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server,
- MODNAME ": could not create thread private pool");
- return NULL;
+ if (apr_pool_create (&private->pool, NULL) != APR_SUCCESS)
+ {
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server,
+ MODNAME ": could not create thread private pool");
+ return NULL;
+ }
}
+ */
+
+ private->pool = pPool;
private->req_cnt = 0;
private->r = NULL;
- private->req = TclWeb_NewRequestObject(private->pool);
private->page_aborting = 0;
private->thread_exit = 0;
private->exit_status = 0;
private->abort_code = NULL;
+ private->channel = NULL;
+ private->req = NULL;
+
+ if (create_request_obj)
+ {
+ private->req = TclWeb_NewRequestObject(private->pool);
+ }
apr_threadkey_private_set (private,rivet_thread_key);
return private;
@@ -484,7 +534,7 @@ rivet_thread_private* Rivet_CreatePrivateData (void)
* - create a Tcl channel
* - set up the Panic procedure
*/
-
+/*
rivet_thread_private* Rivet_ExecutionThreadInit (void)
{
rivet_thread_private* private = Rivet_CreatePrivateData();
@@ -494,6 +544,7 @@ rivet_thread_private* Rivet_ExecutionThreadInit (void)
return private;
}
+*/
/*
*-----------------------------------------------------------------------------
@@ -780,4 +831,3 @@ int Rivet_chdir_file (const char *file)
return chdir_retval;
}
-
diff --git a/src/mod_rivet_ng/mod_rivet_common.h b/src/mod_rivet_ng/mod_rivet_common.h
index e074ff6..5cac8aa 100644
--- a/src/mod_rivet_ng/mod_rivet_common.h
+++ b/src/mod_rivet_ng/mod_rivet_common.h
@@ -19,23 +19,25 @@
under the License.
*/
-#ifndef _MOD_RIVET_COMMON_
-#define _MOD_RIVET_COMMON_
+#ifndef __mod_rivet_common__
+#define __mod_rivet_common__
-EXTERN running_scripts* Rivet_RunningScripts (apr_pool_t* pool,running_scripts* scripts,rivet_server_conf* rivet_conf);
-EXTERN void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,rivet_thread_private* private, server_rec *s, apr_pool_t *p);
-EXTERN void Rivet_CreateCache (apr_pool_t *p, rivet_thread_interp* interp_obj);
-EXTERN rivet_thread_interp* Rivet_NewVHostInterp(apr_pool_t *pool,server_rec* s);
-EXTERN void Rivet_ProcessorCleanup (void *data);
-EXTERN int Rivet_chdir_file (const char *file);
-EXTERN void Rivet_CleanupRequest(request_rec *r);
-EXTERN void Rivet_InitServerVariables(Tcl_Interp *interp, apr_pool_t *pool);
-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 (void);
-EXTERN rivet_thread_private* Rivet_ExecutionThreadInit (void);
+EXTERN rivet_thread_interp* Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj);
+EXTERN running_scripts* Rivet_RunningScripts (apr_pool_t* pool,running_scripts* scripts,rivet_server_conf* rivet_conf);
+EXTERN void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,rivet_thread_private* private,
+ server_rec *s, apr_pool_t *p);
+EXTERN void Rivet_CreateCache (apr_pool_t *p, rivet_thread_interp* interp_obj);
+EXTERN rivet_thread_interp* Rivet_NewVHostInterp(rivet_thread_private* private,server_rec* s);
+EXTERN void Rivet_ProcessorCleanup (void *data);
+EXTERN int Rivet_chdir_file (const char *file);
+EXTERN void Rivet_CleanupRequest(request_rec *r);
+EXTERN void Rivet_InitServerVariables(Tcl_Interp *interp, apr_pool_t *pool);
+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_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);
+EXTERN void Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel);
+EXTERN int Rivet_ReadFile (apr_pool_t* pool,char* filename,char** buffer,int* nbytes);
#endif
diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c
index 66cb9d8..ae2af92 100644
--- a/src/mod_rivet_ng/rivetCore.c
+++ b/src/mod_rivet_ng/rivetCore.c
@@ -151,7 +151,7 @@ TCL_CMD_HEADER( Rivet_MakeURL )
{
/* relative path */
char* script_name = TclWeb_GetEnvVar (private,"SCRIPT_NAME");
- int script_name_l = strlen(script_name);
+ size_t script_name_l = strlen(script_name);
// regardless the reason for a SCRIPT_NAME being undefined we
// prevent a segfault and we revert the behavior of makeurl
@@ -1791,8 +1791,7 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd )
return TCL_OK;
}
-#define TESTPANIC 0
-
+#undef TESTPANIC
#ifdef TESTPANIC
/*
*----------------------------------------------------------------------
@@ -1947,9 +1946,10 @@ TCL_CMD_HEADER( Rivet_UrlScript )
*/
DLLEXPORT int
-Rivet_InitCore(Tcl_Interp *interp,rivet_thread_private* private)
+Rivet_InitCore(rivet_thread_interp* interp_obj,rivet_thread_private* private)
{
- rivet_server_conf* server_conf;
+ Tcl_Interp* interp = interp_obj->interp;
+ rivet_server_conf* server_conf;
RIVET_OBJ_CMD ("makeurl",Rivet_MakeURL,private);
RIVET_OBJ_CMD ("headers",Rivet_Headers,private);
@@ -1987,11 +1987,11 @@ Rivet_InitCore(Tcl_Interp *interp,rivet_thread_private* private)
if (server_conf->export_rivet_ns)
{
- rivet_interp_globals *globals = NULL;
- Tcl_Namespace *rivet_ns;
+ //rivet_interp_globals* globals = NULL;
+ Tcl_Namespace* rivet_ns = interp_obj->rivet_ns;
- globals = Tcl_GetAssocData(interp, "rivet", NULL);
- rivet_ns = globals->rivet_ns;
+ //globals = Tcl_GetAssocData(interp,"rivet", NULL);
+ //rivet_ns = globals->rivet_ns;
RIVET_EXPORT_CMD(interp,rivet_ns,"makeurl");
RIVET_EXPORT_CMD(interp,rivet_ns,"headers");
diff --git a/src/mod_rivet_ng/rivetCore.h b/src/mod_rivet_ng/rivetCore.h
index d996150..8c1ec7d 100644
--- a/src/mod_rivet_ng/rivetCore.h
+++ b/src/mod_rivet_ng/rivetCore.h
@@ -23,6 +23,6 @@
#ifndef __rivetcore_h__
#define __rivetcore_h__
-EXTERN int Rivet_InitCore(Tcl_Interp *interp,rivet_thread_private* private);
+EXTERN int Rivet_InitCore(rivet_thread_interp* interp_obj,rivet_thread_private* private);
#endif
diff --git a/src/mod_rivet_ng/rivet_lazy_mpm.c b/src/mod_rivet_ng/rivet_lazy_mpm.c
index d406f55..a573fdb 100644
--- a/src/mod_rivet_ng/rivet_lazy_mpm.c
+++ b/src/mod_rivet_ng/rivet_lazy_mpm.c
@@ -19,8 +19,6 @@
under the License.
*/
-/* $Id$ */
-
#include <httpd.h>
#include <http_request.h>
#include <ap_compat.h>
@@ -36,9 +34,9 @@
#include "rivetChannel.h"
#include "apache_config.h"
-extern DLLIMPORT mod_rivet_globals* module_globals;
-extern DLLIMPORT apr_threadkey_t* rivet_thread_key;
-extern DLLIMPORT module rivet_module;
+DLLIMPORT mod_rivet_globals* module_globals;
+DLLIMPORT apr_threadkey_t* rivet_thread_key;
+module rivet_module;
enum
{
@@ -160,7 +158,12 @@ 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_CreatePrivateData(apr_thread_pool_get(thd),true);
+ ap_assert(private != NULL);
+
+ private->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
+
+ Rivet_SetupTclPanicProc();
/* 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
@@ -168,8 +171,10 @@ 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);
- RIVET_POKE_INTERP(private,rsc,Rivet_NewVHostInterp(private->pool,w->server));
+
+ RIVET_POKE_INTERP(private,rsc,Rivet_NewVHostInterp(private,w->server));
private->ext->interp->channel = private->channel;
/* The worker thread can respond to a single request at a time therefore
@@ -290,6 +295,10 @@ void Lazy_MPM_ChildInit (apr_pool_t* pool, server_rec* server)
server_rec* s;
server_rec* root_server = module_globals->server;
+ /* the thread key used to access to Tcl threads private data */
+
+ ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pool) == APR_SUCCESS);
+
module_globals->mpm = apr_pcalloc(pool,sizeof(mpm_bridge_status));
/* This mutex is only used to consistently carry out these
@@ -463,6 +472,7 @@ apr_status_t Lazy_MPM_Finalize (void* data)
apr_thread_mutex_unlock(mutex);
}
+ apr_threadkey_private_delete (rivet_thread_key);
return APR_SUCCESS;
}
diff --git a/src/mod_rivet_ng/rivet_prefork_mpm.c b/src/mod_rivet_ng/rivet_prefork_mpm.c
index d14ec04..ad39d31 100644
--- a/src/mod_rivet_ng/rivet_prefork_mpm.c
+++ b/src/mod_rivet_ng/rivet_prefork_mpm.c
@@ -17,9 +17,7 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
- */
-
-/* $Id$ */
+*/
#include <apr_strings.h>
@@ -27,26 +25,78 @@
#include "mod_rivet_common.h"
#include "mod_rivet_generator.h"
#include "httpd.h"
-#include "rivetChannel.h"
#include "apache_config.h"
#include "rivet.h"
#include "rivetCore.h"
#include "worker_prefork_common.h"
+#include "TclWeb.h"
extern DLLIMPORT mod_rivet_globals* module_globals;
extern DLLIMPORT apr_threadkey_t* rivet_thread_key;
+module rivet_module;
+
+rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private);
+
+int Prefork_Bridge_ServerInit (apr_pool_t *pPool,
+ apr_pool_t *pLog,
+ apr_pool_t *pTemp, server_rec *server)
+{
+ rivet_thread_interp** server_interps = module_globals->server_interps;
+ rivet_server_conf* rsc;
+ server_rec* s;
+ rivet_thread_interp* interp_obj;
+ rivet_thread_private* private;
+
+ RIVET_PRIVATE_DATA_NOT_NULL(rivet_thread_key,private)
+
+ /* Assuming the first interpreter in server_interps array to always be set */
-rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private);
+ interp_obj = server_interps[0];
+
+ /*
+ * Looping through all the server records and creating (or assigning
+ * when no virtual host interpreters are required) interpreters
+ */
+
+ for (s = server; s != NULL; s = s->next)
+ {
+ int idx;
+
+ rsc = RIVET_SERVER_CONF(s->module_config);
+ idx = rsc->idx;
+
+ /*
+ * travelling the servers records. We create a new interpreter
+ * if not created by Rivet_ServerInit
+ */
+
+ if (server_interps[idx] == NULL)
+ {
+ if ((s == server) || (rsc->separate_virtual_interps == 0))
+ {
+ module_globals->server_interps[idx] = interp_obj;
+ }
+ else
+ {
+ server_interps[idx] = Rivet_NewVHostInterp(private,s);
+ Rivet_PerInterpInit(server_interps[idx],private,s,pPool);
+ }
+ }
+ }
+
+
+ return OK;
+}
-/* -- Prefork_MPM_Finalize */
+/* -- Prefork_Bridge_Finalize */
-apr_status_t Prefork_MPM_Finalize (void* data)
+apr_status_t Prefork_Bridge_Finalize (void* data)
{
rivet_thread_private* private;
server_rec* s = (server_rec*) data;
RIVET_PRIVATE_DATA_NOT_NULL(rivet_thread_key,private)
- ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, "Running prefork bridge finalize method");
+ ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,s,"Running prefork bridge finalize method");
// No, we don't do any clean up anymore as we are just shutting this process down
// Rivet_ProcessorCleanup(private);
@@ -54,39 +104,119 @@ apr_status_t Prefork_MPM_Finalize (void* data)
return OK;
}
+/* -- Prefork_Bridge_ChildInit: bridge child process initialization */
-/* -- Prefork_MPM_ChildInit: bridge child process initialization
- *
- */
-
-
-void Prefork_MPM_ChildInit (apr_pool_t* pool, server_rec* server)
+void Prefork_Bridge_ChildInit (apr_pool_t* pool, server_rec* server)
{
rivet_thread_private* private;
+ Tcl_Obj* global_tcl_script;
+ rivet_server_conf* root_server_conf;
+ rivet_thread_interp** server_interps = module_globals->server_interps;
+ rivet_server_conf* rsc;
+ int idx;
- ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pool) == APR_SUCCESS);
+ RIVET_PRIVATE_DATA_NOT_NULL(rivet_thread_key,private)
+ /*
+ * Assuming the good global initialization script is in the
+ * first server configuration record
+ */
+
+ root_server_conf = RIVET_SERVER_CONF(server->module_config);
+ if (root_server_conf->rivet_global_init_script != NULL)
+ {
+ server_rec* s;
+
+ global_tcl_script = Tcl_NewStringObj(root_server_conf->rivet_global_init_script,-1);
+ Tcl_IncrRefCount(global_tcl_script);
+
+ if (root_server_conf->separate_virtual_interps)
+ {
+ for (s = server; s != NULL; s = s->next)
+ {
+
+ rsc = RIVET_SERVER_CONF(s->module_config);
+ idx = rsc->idx;
+
+ ap_assert(server_interps[idx] != NULL);
+ if (Tcl_EvalObjEx(server_interps[idx]->interp,global_tcl_script,0) != TCL_OK)
+ {
+ ap_log_error (APLOG_MARK,APLOG_ERR,APR_EGENERAL,s,
+ MODNAME ": Error running GlobalInitScript '%s': %s",
+ root_server_conf->rivet_global_init_script,
+ Tcl_GetVar(server_interps[idx]->interp, "errorInfo", 0));
+ } else {
+ ap_log_error(APLOG_MARK,APLOG_DEBUG,0,s,
+ MODNAME ": GlobalInitScript '%s' successful",
+ root_server_conf->rivet_global_init_script);
+ }
+
+ }
+ }
+ else
+ {
+ rsc = RIVET_SERVER_CONF(server->module_config);
+ idx = rsc->idx;
+ Rivet_PerInterpInit(server_interps[idx],NULL,server,pool);
+ if (Tcl_EvalObjEx(server_interps[idx]->interp,global_tcl_script,0) != TCL_OK)
+ {
+ ap_log_error (APLOG_MARK,APLOG_ERR,APR_EGENERAL,server,
+ MODNAME ": Error running GlobalInitScript '%s': %s",
+ root_server_conf->rivet_global_init_script,
+ Tcl_GetVar(server_interps[idx]->interp, "errorInfo", 0));
+ } else {
+ ap_log_error(APLOG_MARK,APLOG_DEBUG,0,server,
+ MODNAME ": GlobalInitScript '%s' successful",
+ root_server_conf->rivet_global_init_script);
+ }
+ }
+
+ Tcl_DecrRefCount(global_tcl_script);
+ }
+
+ /* The intepreter was created by the server initiazione, we now create its Rivet channel */
+
+ private->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
+
/*
- * This is the only execution thread in this process so we create
- * the Tcl thread private data here. In a fork capable OS
- * private data should have been created by the httpd parent process
+ * Prefork bridge has inherited the parent process pool but we have to initialize ourselves
+ * the request descriptor obj
*/
- private = Rivet_ExecutionThreadInit();
+ private->req = TclWeb_NewRequestObject(private->pool);
+
+ /* Bridge specific data are allocate here */
+
private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific));
- private->ext->interps =
- apr_pcalloc(private->pool,module_globals->vhosts_count*sizeof(rivet_thread_interp));
+ private->ext->interps = module_globals->server_interps;
+
+ //apr_pcalloc(private->pool,module_globals->vhosts_count*sizeof(rivet_thread_interp));
+ /* This step is not needed anymore, we rely on the initialization that took
+ * place with the server initialization
+ */
/* we now establish the full rivet core command set for the root interpreter */
- Rivet_InitCore (module_globals->server_interp->interp,private);
+ //Rivet_InitCore (module_globals->server_interp->interp,private);
#ifdef RIVET_NAMESPACE_IMPORT
+
{
- char* tcl_import_cmd = "namespace eval :: { namespace import -force ::rivet::* }\n";
+ rivet_server_conf* rsc;
+ server_rec* s;
+ char* tcl_import_cmd = "namespace eval :: { namespace import -force ::rivet::* }\n";
+
+ for (s = server; s != NULL; s = s->next)
+ {
+ int idx;
- Tcl_Eval (module_globals->server_interp->interp,tcl_import_cmd);
+ rsc = RIVET_SERVER_CONF(s->module_config);
+ idx = rsc->idx;
+
+ Tcl_Eval (module_globals->server_interps[idx]->interp,tcl_import_cmd);
+
+ }
}
#endif
@@ -103,7 +233,7 @@ void Prefork_MPM_ChildInit (apr_pool_t* pool, server_rec* server)
}
/*
- * -- Prefork_MPM_Request
+ * -- Prefork_Bridge_Request
*
* The prefork implementation of this function is basically a wrapper of
* Rivet_SendContent. The real job is fetching the thread private data
@@ -117,7 +247,7 @@ void Prefork_MPM_ChildInit (apr_pool_t* pool, server_rec* server)
* HTTP status code (see the Apache HTTP web server documentation)
*/
-int Prefork_MPM_Request (request_rec* r,rivet_req_ctype ctype)
+int Prefork_Bridge_Request (request_rec* r,rivet_req_ctype ctype)
{
rivet_thread_private* private;
@@ -136,9 +266,9 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* server)
rivet_thread_private* private;
int tcl_status;
- RIVET_PRIVATE_DATA_NOT_NULL (rivet_thread_key, private);
+ RIVET_PRIVATE_DATA_NOT_NULL (rivet_thread_key,private);
- module_globals->server_interp->channel = private->channel;
+ module_globals->server_interps[0]->channel = private->channel;
/*
* We are returning the interpreter inherited from
@@ -150,18 +280,18 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* server)
* calling a Tcl script fragment
*/
- tcl_status = Tcl_Eval(module_globals->server_interp->interp,"expr {srand([clock clicks] + [pid])}");
+ tcl_status = Tcl_Eval(module_globals->server_interps[0]->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;
+ return module_globals->server_interps[0];
}
/*
- * -- Prefork_MPM_ExitHandler
+ * -- Prefork_Bridge_ExitHandler
*
* Just calling Tcl_Exit
*
@@ -173,7 +303,7 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* server)
* the thread running the Tcl script will exit
*/
-int Prefork_MPM_ExitHandler(int code)
+int Prefork_Bridge_ExitHandler(int code)
{
Tcl_Exit(code);
@@ -181,9 +311,9 @@ int Prefork_MPM_ExitHandler(int code)
return TCL_OK;
}
-rivet_thread_interp* Prefork_MPM_Interp (rivet_thread_private* private,
- rivet_server_conf* conf,
- rivet_thread_interp* interp)
+rivet_thread_interp* Prefork_Bridge_Interp (rivet_thread_private* private,
+ rivet_server_conf* conf,
+ rivet_thread_interp* interp)
{
if (interp != NULL) { private->ext->interps[conf->idx] = interp; }
@@ -192,11 +322,11 @@ rivet_thread_interp* Prefork_MPM_Interp (rivet_thread_private* private,
DLLEXPORT
RIVET_MPM_BRIDGE {
- NULL,
- Prefork_MPM_ChildInit,
- Prefork_MPM_Request,
- Prefork_MPM_Finalize,
- Prefork_MPM_ExitHandler,
- Prefork_MPM_Interp
+ Prefork_Bridge_ServerInit,
+ Prefork_Bridge_ChildInit,
+ Prefork_Bridge_Request,
+ Prefork_Bridge_Finalize,
+ Prefork_Bridge_ExitHandler,
+ Prefork_Bridge_Interp
};
diff --git a/src/mod_rivet_ng/rivet_types.h b/src/mod_rivet_ng/rivet_types.h
index 25151c5..8f261b0 100644
--- a/src/mod_rivet_ng/rivet_types.h
+++ b/src/mod_rivet_ng/rivet_types.h
@@ -21,14 +21,18 @@
under the License.
*/
-/* $Id$ */
-
-#ifndef _RIVET_TYPES_H_
-#define _RIVET_TYPES_H_
+#ifndef __rivet_types_h__
+#define __rivet_types_h__
#include <httpd.h>
#include <tcl.h>
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else
+typedef enum {false=0, true=1} bool;
+#endif
+
typedef struct _ApacheRequest ApacheRequest;
typedef struct _ApacheUpload ApacheUpload;
@@ -39,7 +43,7 @@ typedef struct _ApacheUpload {
char* tempname;
apr_table_t* info;
apr_file_t* fp;
- long size;
+ size_t size;
ApacheRequest* req;
} ApacheUpload;
diff --git a/src/mod_rivet_ng/rivet_worker_mpm.c b/src/mod_rivet_ng/rivet_worker_mpm.c
index 7c36afe..f3d9f04 100644
--- a/src/mod_rivet_ng/rivet_worker_mpm.c
+++ b/src/mod_rivet_ng/rivet_worker_mpm.c
@@ -51,6 +51,7 @@
extern DLLIMPORT mod_rivet_globals* module_globals;
extern DLLIMPORT apr_threadkey_t* rivet_thread_key;
+DLLIMPORT module rivet_module;
apr_threadkey_t* handler_thread_key;
@@ -180,13 +181,20 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
apr_thread_mutex_lock(module_globals->mpm->job_mutex);
- private = Rivet_ExecutionThreadInit();
+ private = Rivet_CreatePrivateData(apr_thread_pool_get(thd),true);
+ ap_assert(private != NULL);
+
+ private->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
+
+ Rivet_SetupTclPanicProc();
+
+ /* bridge specific data */
+
private->ext = apr_pcalloc(private->pool,sizeof(mpm_bridge_specific));
private->ext->keep_going = 1;
private->ext->interps =
apr_pcalloc(private->pool,module_globals->vhosts_count*sizeof(rivet_thread_interp));
-
/* So far nothing differs much with what we did for the prefork bridge */
/* At this stage we have to set up the private interpreters of configured
@@ -444,8 +452,6 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void
return NULL;
}
-// int Worker_MPM_ServerInit (apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s) { return OK; }
-
/*
* -- Worker_MPM_ChildInit
*
@@ -461,7 +467,15 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void
void Worker_MPM_ChildInit (apr_pool_t* pool, server_rec* server)
{
apr_status_t rv;
-
+
+ /* the thread key used to access to Tcl threads private data */
+
+ ap_assert (apr_threadkey_private_create (&rivet_thread_key, NULL, pool) == APR_SUCCESS);
+
+ /* On some platform this is required in order to initialize the
+ *
+ */
+
apr_atomic_init(pool);
#ifdef RIVET_SERIALIZE_HTTP_REQUESTS
@@ -691,7 +705,7 @@ apr_status_t Worker_MPM_Finalize (void* data)
}
}
- // apr_threadkey_private_delete (handler_thread_key);
+ apr_threadkey_private_delete (rivet_thread_key);
return OK;
}
@@ -713,7 +727,7 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* s)
RIVET_PRIVATE_DATA_NOT_NULL(rivet_thread_key,private)
- interp_obj = Rivet_NewVHostInterp(private->pool,s);
+ interp_obj = Rivet_NewVHostInterp(private,s);
interp_obj->channel = private->channel;
Rivet_PerInterpInit(interp_obj, private, s, private->pool);
return interp_obj;
@@ -722,10 +736,11 @@ rivet_thread_interp* MPM_MasterInterp(server_rec* s)
/*
* -- Worker_MPM_ExitHandler
*
- * Signals a thread to exit by setting the loop control flag to 0
+ * Signals a thread to exit by setting the loop control flag to 0
* and by returning a Tcl error with error code THREAD_EXIT_CODE
*
* Arguments:
+ *
* int code
*
* Side Effects:
@@ -757,7 +772,7 @@ int Worker_MPM_ExitHandler(int code)
return TCL_OK;
}
-rivet_thread_interp* Worker_MPM_Interp (rivet_thread_private* private,
+rivet_thread_interp* Worker_MPM_Interp (rivet_thread_private* private,
rivet_server_conf* conf,
rivet_thread_interp* interp)
{
diff --git a/src/mod_rivet_ng/worker_prefork_common.c b/src/mod_rivet_ng/worker_prefork_common.c
index a3f170c..c93cdb3 100644
--- a/src/mod_rivet_ng/worker_prefork_common.c
+++ b/src/mod_rivet_ng/worker_prefork_common.c
@@ -19,56 +19,28 @@
under the License.
*/
-/* $Id$ */
-
#include <httpd.h>
#include <apr_strings.h>
#include "mod_rivet.h"
+
/* Function prototypes are defined with EXTERN. Since we are in the same DLL,
* no need to keep this extern... */
-#ifdef EXTERN
-# undef EXTERN
-# define EXTERN
+
+#ifdef EXTERN
+#undef EXTERN
+#define EXTERN
#endif /* EXTERN */
+
#include "mod_rivet_common.h"
#include "mod_rivet_cache.h"
#include "worker_prefork_common.h"
extern DLLIMPORT mod_rivet_globals* module_globals;
extern DLLIMPORT apr_threadkey_t* rivet_thread_key;
-extern DLLIMPORT module rivet_module;
+extern DLLIMPORT module rivet_module;
extern rivet_thread_interp* MPM_MasterInterp(server_rec* s);
-/*
- * Rivet_DuplicateVhostInterp
- *
- *
- */
-
-static rivet_thread_interp*
-Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj)
-{
- rivet_thread_interp* interp_obj = apr_pcalloc(pool,sizeof(rivet_thread_interp));
-
- interp_obj->interp = source_obj->interp;
- interp_obj->channel = source_obj->channel;
- interp_obj->cache_free = source_obj->cache_free;
- interp_obj->cache_size = source_obj->cache_size;
-
- /* An intepreter must have its own cache */
-
- if (interp_obj->cache_size) {
- RivetCache_Create(pool,interp_obj);
- }
-
- interp_obj->pool = source_obj->pool;
- interp_obj->scripts = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts));
- interp_obj->per_dir_scripts = apr_hash_make(pool);
- interp_obj->flags = source_obj->flags;
- return interp_obj;
-}
-
/* -- Rivet_VirtualHostsInterps
*
* The server_rec chain is walked through and server configurations is read to
@@ -90,13 +62,13 @@ Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj)
rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private)
{
- server_rec* s;
- server_rec* root_server = module_globals->server;
- rivet_server_conf* root_server_conf;
- rivet_server_conf* myrsc;
- rivet_thread_interp* root_interp;
- void* parentfunction; /* this is topmost initialization script */
- void* function;
+ server_rec* s;
+ server_rec* root_server = module_globals->server;
+ rivet_server_conf* root_server_conf;
+ rivet_server_conf* myrsc;
+ rivet_thread_interp* root_interp;
+ void* parentfunction; /* this is topmost initialization script */
+ void* function;
root_server_conf = RIVET_SERVER_CONF (root_server->module_config);
root_interp = MPM_MasterInterp(module_globals->server);
@@ -153,7 +125,7 @@ rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private)
{
if (root_server_conf->separate_virtual_interps)
{
- rivet_interp = Rivet_NewVHostInterp(private->pool,s);
+ rivet_interp = Rivet_NewVHostInterp(private,s);
if (myrsc->separate_channels)
{
rivet_interp->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
@@ -194,9 +166,9 @@ rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private)
* has the child process' same lifespan
*/
- apr_thread_mutex_lock(module_globals->pool_mutex);
+ //apr_thread_mutex_lock(module_globals->pool_mutex);
myrsc->server_name = (char*) apr_pstrdup (private->pool, s->server_hostname);
- apr_thread_mutex_unlock(module_globals->pool_mutex);
+ //apr_thread_mutex_unlock(module_globals->pool_mutex);
/* when configured a child init script gets evaluated */
@@ -227,8 +199,7 @@ rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private)
private->running_conf = myrsc;
if (Tcl_EvalObjEx(interp,tcl_child_init, 0) != TCL_OK) {
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server,
- errmsg, function);
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server, errmsg, function);
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server,
"errorCode: %s", Tcl_GetVar(interp, "errorCode", 0));
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, root_server,
@@ -241,7 +212,6 @@ rivet_thread_private* Rivet_VirtualHostsInterps (rivet_thread_private* private)
return private;
}
-
/*
* -- Rivet_ProcessorCleanup
*
diff --git a/src/mod_rivet_ng/worker_prefork_common.h b/src/mod_rivet_ng/worker_prefork_common.h
index 70c1d6a..e79c388 100644
--- a/src/mod_rivet_ng/worker_prefork_common.h
+++ b/src/mod_rivet_ng/worker_prefork_common.h
@@ -19,8 +19,6 @@
under the License.
*/
-/* $Id$ */
-
#ifndef __worker_prefork_common_h__
#define __worker_prefork_common_h__
@@ -34,4 +32,6 @@ typedef struct mpm_bridge_specific {
rivet_thread_interp** interps;
} mpm_bridge_specific;
+int Interps_Init (rivet_thread_interp** , apr_pool_t* , server_rec* );
+
#endif /* */
diff --git a/src/request/apache_multipart_buffer.c b/src/request/apache_multipart_buffer.c
index 36be086..484b8f3 100644
--- a/src/request/apache_multipart_buffer.c
+++ b/src/request/apache_multipart_buffer.c
@@ -31,25 +31,25 @@
if partial is true, partial matches are allowed at the end of the buffer.
returns NULL if not found, or a pointer to the start of the first match.
*/
-void* my_memstr(char* haystack, int haystacklen, const char* needle,
- int partial)
+void* my_memstr(char* haystack,int haystacklen,const char* needle,int partial)
{
- int needlen = strlen(needle);
+ size_t needlen = strlen(needle);
int len = haystacklen;
char *ptr = haystack;
/* iterate through first character matches */
while( (ptr = memchr(ptr, needle[0], len)) ) {
- /* calculate length after match */
- len = haystacklen - (ptr - (char *)haystack);
-
- /* done if matches up to capacity of buffer */
- if(memcmp(needle, ptr, needlen) == 0 &&
- (partial || len >= needlen))
- break;
-
- /* next character */
- ptr++; len--;
+ /* calculate length after match */
+ len = haystacklen - (int)(ptr - (char *)haystack);
+
+ /* done if matches up to capacity of buffer */
+ if(memcmp(needle, ptr, needlen) == 0 && (partial || len >= needlen))
+ {
+ break;
+ }
+
+ /* next character */
+ ptr++; len--;
}
return ptr;
@@ -73,7 +73,7 @@ int fill_buffer(multipart_buffer *self)
bytes_to_read = self->bufsize - self->bytes_in_buffer;
if (bytes_to_read >= self->r->remaining) {
- bytes_to_read = self->r->remaining - strlen(self->boundary);
+ bytes_to_read = (int)(self->r->remaining - (apr_off_t)strlen(self->boundary));
#ifdef DEBUG
ap_log_rerror(MPB_ERROR, "mozilla 0.97 hack: '%ld'", self->r->remaining);
#endif
@@ -118,7 +118,7 @@ char* next_line(multipart_buffer *self)
/* bump the pointer */
self->buf_begin = ptr + 1;
- self->bytes_in_buffer -= (self->buf_begin - line);
+ self->bytes_in_buffer -= (int)(self->buf_begin - line);
}
/* no LF found */
@@ -177,17 +177,18 @@ int find_boundary(multipart_buffer *self, char *boundary)
/*********************** external functions *********************/
/* create new multipart_buffer structure */
-multipart_buffer *multipart_buffer_new(char *boundary, long length, request_rec *r)
+multipart_buffer *multipart_buffer_new(char *boundary, apr_off_t length, request_rec *r)
{
multipart_buffer *self = (multipart_buffer *)
apr_pcalloc (r->pool, sizeof(multipart_buffer));
- int minsize = strlen(boundary)+6;
+ size_t minsize = strlen(boundary)+6;
+
if(minsize < FILLUNIT) minsize = FILLUNIT;
self->r = r;
self->buffer = (char *) apr_pcalloc(r->pool, minsize+1);
- self->bufsize = minsize;
+ self->bufsize = (int)minsize;
self->request_length = length;
self->boundary = (char*) apr_pstrcat(r->pool, "--", boundary, NULL);
self->boundary_next = (char*) apr_pstrcat(r->pool, "\n", self->boundary, NULL);
@@ -243,35 +244,35 @@ apr_table_t *multipart_buffer_headers(multipart_buffer *self)
}
/* read until a boundary condition */
-int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes)
+size_t multipart_buffer_read(multipart_buffer *self, char *buf, size_t bytes)
{
- int len, max;
- char *bound;
+ size_t max;
+ size_t len;
+ char* bound;
/* fill buffer if needed */
if(bytes > self->bytes_in_buffer) fill_buffer(self);
/* look for a potential boundary match, only read data up to that point */
- if( (bound = my_memstr(self->buf_begin, self->bytes_in_buffer,
- self->boundary_next, 1)) ) {
- max = bound - self->buf_begin;
- } else {
- max = self->bytes_in_buffer;
- }
+ if( (bound = my_memstr(self->buf_begin, self->bytes_in_buffer, self->boundary_next, 1)) ) {
+ max = bound - self->buf_begin;
+ } else {
+ max = self->bytes_in_buffer;
+ }
/* maximum number of bytes we are reading */
len = max < bytes-1 ? max : bytes-1;
/* if we read any data... */
- if(len > 0) {
- /* copy the data */
- memcpy(buf, self->buf_begin, len);
- buf[len] = 0;
- if(bound && len > 0 && buf[len-1] == '\r') buf[--len] = 0;
-
- /* update the buffer */
- self->bytes_in_buffer -= len;
- self->buf_begin += len;
+ if (len > 0) {
+ /* copy the data */
+ memcpy(buf, self->buf_begin, len);
+ buf[len] = 0;
+ if(bound && len > 0 && buf[len-1] == '\r') buf[--len] = 0;
+
+ /* update the buffer */
+ self->bytes_in_buffer -= (int)len;
+ self->buf_begin += len;
}
#ifdef DEBUG
diff --git a/src/request/apache_multipart_buffer.h b/src/request/apache_multipart_buffer.h
index 2237942..b899a46 100644
--- a/src/request/apache_multipart_buffer.h
+++ b/src/request/apache_multipart_buffer.h
@@ -30,27 +30,27 @@
typedef struct _multipart_buffer {
/* request info */
- request_rec *r;
- long request_length;
+ request_rec* r;
+ apr_off_t request_length;
/* read buffer */
- char *buffer;
- char *buf_begin;
- int bufsize;
- int bytes_in_buffer;
+ char* buffer;
+ char* buf_begin;
+ int bufsize;
+ int bytes_in_buffer;
/* boundary info */
- char *boundary;
- char *boundary_next;
- char *boundary_end;
+ char* boundary;
+ char* boundary_next;
+ char* boundary_end;
} multipart_buffer;
-multipart_buffer *multipart_buffer_new(char *boundary, long length, request_rec *r);
+multipart_buffer* multipart_buffer_new(char* boundary,apr_off_t length,request_rec* r);
///*table*/apr_table_t *multipart_buffer_headers(multipart_buffer *self);
-int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes);
-char *multipart_buffer_read_body(multipart_buffer *self);
-apr_table_t *multipart_buffer_headers(multipart_buffer *self);
-int multipart_buffer_eof(multipart_buffer *self);
+size_t multipart_buffer_read(multipart_buffer* self,char* buf,size_t bytes);
+char* multipart_buffer_read_body(multipart_buffer *self);
+apr_table_t* multipart_buffer_headers(multipart_buffer *self);
+int multipart_buffer_eof(multipart_buffer *self);
#ifdef __cplusplus
}
diff --git a/src/request/apache_request.c b/src/request/apache_request.c
index b5f36f9..b370273 100644
--- a/src/request/apache_request.c
+++ b/src/request/apache_request.c
@@ -42,9 +42,12 @@ util_read(ApacheRequest *req, const char **rbuf)
if (ap_should_client_block(r)) {
char buff[HUGE_STRING_LEN];
- int rsize, len_read, rpos=0;
- long length = r->remaining;
+ int len_read;
+ apr_off_t rpos;
+ apr_off_t rsize;
+ apr_off_t length = r->remaining;
+ rpos = 0;
if (length > req->post_max && req->post_max > 0) {
ap_log_rerror(REQ_ERROR,"entity too large (%d, max=%d)",
(int)length, req->post_max);
@@ -509,14 +512,14 @@ apr_file_t *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload)
int
ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
{
- request_rec *r = req->r;
- int rc = OK;
- long length;
- char *boundary;
- multipart_buffer *mbuff;
- ApacheUpload *upload = NULL;
- apr_status_t status;
- char error[1024];
+ request_rec* r = req->r;
+ int rc = OK;
+ apr_off_t length;
+ char* boundary;
+ multipart_buffer* mbuff;
+ ApacheUpload* upload = NULL;
+ apr_status_t status;
+ char error[1024];
if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
return rc;
@@ -533,7 +536,7 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
}
do {
- int blen;
+ size_t blen;
boundary = ap_getword(r->pool, &ct, '=');
if (boundary == NULL)
return DECLINED;
@@ -550,10 +553,12 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
}
while (!multipart_buffer_eof(mbuff)) {
- apr_table_t *header = (apr_table_t*) multipart_buffer_headers(mbuff);
- const char *cd, *param=NULL, *filename=NULL;
- char buff[FILLUNIT];
- int blen;
+ apr_table_t* header = (apr_table_t*) multipart_buffer_headers(mbuff);
+ const char* cd;
+ const char* param = NULL;
+ const char* filename=NULL;
+ char buff[FILLUNIT];
+ size_t blen;
if (!header) {
#ifdef DEBUG
@@ -625,12 +630,13 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
}
while ((blen = multipart_buffer_read(mbuff, buff, sizeof(buff)))) {
- apr_size_t bytes_to_write = (apr_size_t) blen;
- status = apr_file_write(upload->fp,buff,&bytes_to_write);
- if (status != 0) {
- apr_strerror(status,error,1024);
+ apr_size_t bytes_to_write = (apr_size_t) blen;
+ status = apr_file_write(upload->fp,buff,&bytes_to_write);
+
+ if (status != 0) {
+ apr_strerror(status,error,1024);
return HTTP_INTERNAL_SERVER_ERROR;
- }
+ }
upload->size += blen;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org