You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by mx...@apache.org on 2010/12/03 23:01:03 UTC
svn commit: r1042023 - in /tcl/rivet/trunk: ChangeLog Makefile.in
configure.ac doc/xml/directives.xml doc/xml/install.xml rivet/init.tcl
src/apache-2/mod_rivet.c src/apache-2/mod_rivet.h
Author: mxmanghi
Date: Fri Dec 3 22:01:03 2010
New Revision: 1042023
URL: http://svn.apache.org/viewvc?rev=1042023&view=rev
Log:
2010-12-03 Massimo Manghi <mx...@apache.org>
* configure.ac: new macros to set default values of configuration parameters.
* src/apache-2/mod_rivet.c,mod_rivet.h: Default values are set in rivet_config.h through autotools. The Tcl
Rivet environment is now loaded from mod_rivet by calling Tcl_PackageRequire("RivetTcl","1.1"); after auto_path
is properly set. Configuration scripts are now stored in Tcl_Obj objects
* doc/xml/install.xml: Add documentation for new 'configure' switch.
* rivet/init.tcl: the path to RIVETLIB_DESTDIR is added to auto_path in mod_rivet.
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/Makefile.in
tcl/rivet/trunk/configure.ac
tcl/rivet/trunk/doc/xml/directives.xml
tcl/rivet/trunk/doc/xml/install.xml
tcl/rivet/trunk/rivet/init.tcl
tcl/rivet/trunk/src/apache-2/mod_rivet.c
tcl/rivet/trunk/src/apache-2/mod_rivet.h
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Fri Dec 3 22:01:03 2010
@@ -1,3 +1,11 @@
+2010-12-03 Massimo Manghi <mx...@apache.org>
+ * configure.ac: new macros to set default values of configuration parameters.
+ * src/apache-2/mod_rivet.c,mod_rivet.h: Default values are set in rivet_config.h through autotools. The Tcl
+ Rivet environment is now loaded from mod_rivet by calling Tcl_PackageRequire("RivetTcl","1.1"); after auto_path
+ is properly set. Configuration scripts are now stored in Tcl_Obj objects
+ * doc/xml/install.xml: Add documentation for new 'configure' switch.
+ * rivet/init.tcl: the path to RIVETLIB_DESTDIR is added to auto_path in mod_rivet.
+
2010-12-02 Massimo Manghi <mx...@apache.org>
* debian/libapache2-mod-rivet.*,debian/changelog: removed redundant lines from postist script (Debian package)
* rivet/rivet-tcl/cookie.tcl: add command "cookie unset"
Modified: tcl/rivet/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/Makefile.in?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/Makefile.in (original)
+++ tcl/rivet/trunk/Makefile.in Fri Dec 3 22:01:03 2010
@@ -185,6 +185,7 @@ MAKE_SHARED_LIB = @MAKE_SHARED_LIB@
MAKE_STATIC_LIB = @MAKE_STATIC_LIB@
MAKE_STUB_LIB = @MAKE_STUB_LIB@
MATH_LIBS = @MATH_LIBS@
+MAX_POST = @MAX_POST@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJEXT = @OBJEXT@
@@ -209,6 +210,7 @@ RANLIB = @RANLIB@
RANLIB_STUB = @RANLIB_STUB@
RIVET_BASE_INCLUDE = @RIVET_BASE_INCLUDE@
RIVET_TCL_TARGET = @RIVET_TCL_TARGET@
+RIVET_UPLOAD_DIR = @RIVET_UPLOAD_DIR@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHARED_BUILD = @SHARED_BUILD@
Modified: tcl/rivet/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/configure.ac?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/configure.ac (original)
+++ tcl/rivet/trunk/configure.ac Fri Dec 3 22:01:03 2010
@@ -22,7 +22,7 @@ dnl
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------
-AC_INIT([Rivet],[2.0.2])
+AC_INIT([Rivet],[2.0.3])
TEA_INIT([3.9])
AC_CONFIG_AUX_DIR(tclconfig)
@@ -428,6 +428,9 @@ AC_DEFUN([RIVET_TCL_LIB],[
AC_MSG_RESULT([$with_rivet_target_dir])
])
+
+# DISPLAY_RIVET_VERSION
+#
# --enable-version-display=[yes|no] (default: no)
# switches on version number display in Apache's signature.
#
@@ -450,6 +453,122 @@ AC_DEFUN([DISPLAY_RIVET_VERSION],[
fi
])
+# UPLOAD_DIRECTORY
+#
+# Adds '--with-upload-dir=DIR' to configure's arguments
+#
+# let's make configuration of the upload directory more flexible for windows builds
+# (in case someone steps forward and takes up the Windows port)
+# The upload directory can be changed in the configuration, but we give the
+# user/packager the chance to set a default at compile time.
+# Default: /tmp
+
+AC_DEFUN([UPLOAD_DIRECTORY],[
+ AC_ARG_WITH(
+ upload_dir,
+ [ --with-upload-dir=DIR Default directory for uploads],,
+ with_upload_dir="/tmp"
+ )
+ AC_MSG_CHECKING(where Rivet will save uploads)
+ RIVET_UPLOAD_DIR=${with_upload_dir}
+ AC_SUBST(RIVET_UPLOAD_DIR)
+ AC_MSG_RESULT([$with_upload_dir])
+])
+
+# HONOR_HEAD_REQUESTS (--enable-head-requests)
+# Rivet answers to HEAD requests with a standard response to avoid the whole workload
+# of generating the content of a page with to the sole purpose of returning the HTTP
+# headers.To test the configuration or scripts that manipulate the headers it
+# can be useful to let Rivet honor a HEAD request as if the whole content was
+# generated so that the real headers are returned (this can be set in configuration
+# by adding "RivetServerConf HonorHeaderOnlyRequests yes" to the server configuration)
+# Default: no
+
+AC_DEFUN([HONOR_HEAD_REQUESTS],[
+ AC_ARG_ENABLE(
+ head_requests,
+ [ --enable-head-requests Returns real headers in response to a HEAD request],
+ [ honor_head_requests=$enable_head_requests ],
+ [ honor_head_requests="no"]
+ )
+
+ AC_MSG_CHECKING(whether Rivet has to honor HEAD requests)
+ if test "$honor_head_requests" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HEAD_REQUESTS,1,[Honor HEAD requests])
+ else
+ AC_MSG_RESULT([no, Rivet will shunt HEAD requests])
+ AC_DEFINE(HEAD_REQUESTS,0,[Honor HEAD requests])
+ fi
+])
+
+# SEPARATE_VIRTUAL_INTERPS (--enable-virtual-interps-separation)
+# Virtual hosts get their own interpreter and configuration. Different
+# applications running on different virtual hosts don't mix up variables
+# and namespaces, avoiding conflicts.
+# Default: no
+
+AC_DEFUN([VIRTUAL_INTERPS_SEPARATION],[
+ AC_ARG_ENABLE(
+ virtual-interps-separation,
+ [ --enable-virtual-interps-separation to turn on virtual host separation],
+ [ separate_virtual_interps=$enable_virtual_interps_separation ],
+ [ separate_virtual_interps="no"]
+ )
+
+ AC_MSG_CHECKING(whether Rivet will crate an interpreter for each virtual host)
+ if test "$separate_virtual_interps" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(SEPARATE_VIRTUAL_INTERPS,1,[virtual hosts will have their own interp])
+ else
+ AC_MSG_RESULT([no])
+ AC_DEFINE(SEPARATE_VIRTUAL_INTERPS,0,[one interpreter per child])
+ fi
+])
+
+# POST_MAX_SIZE (--with-post-max)
+# Maximum size of data posted by a form
+# Default: 0=unlimited
+
+AC_DEFUN([POST_MAX_SIZE],[
+ AC_ARG_WITH(
+ post_max,
+ [ --with-post-max=BYTES Maximum size of data to be sent with a POST],,
+ with_post_max=0
+ )
+
+ AC_MSG_CHECKING(maximum size of a POST)
+ MAX_POST=${with_post_max}
+ AC_SUBST(MAX_POST)
+ if test $with_post_max = 0; then
+ AC_MSG_RESULT([unlimited size])
+ else
+ AC_MSG_RESULT([$with_post_max])
+ fi
+])
+
+# UPLOAD_TO_VAR (--enable-upload-var)
+# Enables upload of files into Tcl variables
+# Default: 1=enabled
+
+AC_DEFUN([UPLOAD_TO_VAR],[
+ AC_ARG_ENABLE(
+ upload-var,
+ [ --enable-upload-var to enable automatic upload to variables ],
+ [ upload_var=$enable_upload_var ],
+ [ upload_var="yes"]
+ )
+
+ AC_MSG_CHECKING(if files are uploaded to Tcl variables)
+ if test "$upload_var" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(UPLOAD_FILES_TO_VAR,1,[Files are uploaded to Tcl variables])
+ else
+ AC_MSG_RESULT([no])
+ AC_DEFINE(UPLOAD_FILES_TO_VAR,0,[uploads go to files])
+ fi
+
+])
APACHE_VERSION
GET_RIVET_BASE
APACHE
@@ -458,10 +577,17 @@ APACHE_INCLUDES
APR_HANDLING
RIVET_TCL_LIB
DISPLAY_RIVET_VERSION
+UPLOAD_DIRECTORY
+HONOR_HEAD_REQUESTS
+VIRTUAL_INTERPS_SEPARATION
+POST_MAX_SIZE
+UPLOAD_TO_VAR
AC_SUBST(apache_version_dir)
AC_DEFINE_UNQUOTED(RIVETLIB_DESTDIR,"${RIVET_TCL_TARGET}",[The path to the rivet tcl library])
AC_DEFINE_UNQUOTED(NAMEOFEXECUTABLE,"${TCLSH_PROG}",[The path to a working tclsh executable])
+AC_DEFINE_UNQUOTED(UPLOAD_DIR,"${RIVET_UPLOAD_DIR}",[Path to the disk directory where uploads are saved])
+AC_DEFINE_UNQUOTED(MAX_POST,"${MAX_POST}",[Max size of data in POST operations])
# We need to use the package path for the installation procedure. On
#Debian linux TCL_PACKAGE_PATH may have more than one path in the
Modified: tcl/rivet/trunk/doc/xml/directives.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/directives.xml?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/directives.xml (original)
+++ tcl/rivet/trunk/doc/xml/directives.xml Fri Dec 3 22:01:03 2010
@@ -251,24 +251,26 @@
<varlistentry>
<term>
- <cmdsynopsis>
- <arg choice="plain">SeparateVirtualInterps</arg>
- <group choice="req">
- <arg>yes</arg>
- <arg>no</arg>
- </group>
- </cmdsynopsis>
- </term>
+ <cmdsynopsis>
+ <arg choice="plain">SeparateVirtualInterps</arg>
+ <group choice="req">
+ <arg>yes</arg>
+ <arg>no</arg>
+ </group>
+ </cmdsynopsis>
+ </term>
<listitem>
- <para>
- If on, Rivet will create a separate Tcl interpreter
- for each Apache virtual host. This is useful in an
- ISP type situation where it is desirable to separate
- clients into separate interpreters, so that they
- don't accidentally interfere with one another.
- </para>
- <para>This option is, by nature, only available at the
- global level.</para>
+ <para>
+ If on, Rivet will create a separate Tcl interpreter
+ for each Apache virtual host. This is useful in an
+ ISP type situation where it is desirable to separate
+ clients into separate interpreters, so that they
+ don't accidentally interfere with one another.
+ </para>
+ <para>
+ This option is, by nature, only available at the
+ global level.
+ </para>
</listitem>
</varlistentry>
Modified: tcl/rivet/trunk/doc/xml/install.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/install.xml?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/install.xml (original)
+++ tcl/rivet/trunk/doc/xml/install.xml Fri Dec 3 22:01:03 2010
@@ -110,7 +110,7 @@ tar -xvf rivet-X.X.X.tar.gz</programlist
</listitem>
</varlistentry>
<varlistentry>
- <term>--enable-version-display=[yes|no]</term>
+ <term>--enable-version-display=[yes|no] (default: no)</term>
<listitem>
<para>
This option enables Rivet to display its version in the logfiles when Apache is started.
@@ -119,14 +119,61 @@ tar -xvf rivet-X.X.X.tar.gz</programlist
</listitem>
</varlistentry>
<varlistentry>
- <term>--with-rivet-target-dir=DIR</term>
+ <term>--with-rivet-target-dir=DIR</term>
+ <listitem>
+ <para>
+ This option tells the install script where Rivet's Tcl packages have to be copied.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--with-rivet-target-dir=DIR</term>
+ <listitem>
+ <para>
+ This option tells the install script where Rivet's Tcl packages have to be copied.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--with-upload-dir=DIR (default: '/tmp')</term>
+ <listitem>
+ <para>
+ Sets the default directory where Rivet stores files in an upload
+ operation. (Can be changed in the conf with the parameter 'UploadDirectory',
+ see )
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--enable-head-request (default: 'no') </term>
+ <listitem>
+ If enabled returns the real headers in response to a HEAD http request. (Can
+ be changed in the configuration with the 'HonorHeaderOnlyRequests' parameter)
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--enable-virtual-interps-separation (default: 'no')</term>
+ <listitem>
+ When enabled each virtual host will have its own interpreter. (Can be changed in the
+ configuration with the 'SeparateVirtualInterps' parameter)
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--with-post-max=BYTES Maximum size of data in a POST (default: 0=unlimited)</term>
+ <listitem>
+ Form data are sent to the server in either a GET or a POST operation. Data in POST
+ can be large and you can set the default maximumx size of data that can be accepted
+ in a POST. (Can be changed in configuration with the 'UploadMaxSize' parameter)
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--enable-upload-var=[yes|no]</term>
<listitem>
- <para>
- This option tells the install script where Rivet's Tcl packages have to be copied.
- </para>
+ This sets the default for the configuration parameter 'UploadFilesToVar'. If set this
+ option allow the upload of files into Tcl variables
</listitem>
</varlistentry>
- </variablelist>
+ </variablelist>
</para>
<para>
Example: configuring the build system to compile Rivet for an apache 2.x server, using tcl8.5 and
Modified: tcl/rivet/trunk/rivet/init.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/init.tcl?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/init.tcl (original)
+++ tcl/rivet/trunk/rivet/init.tcl Fri Dec 3 22:01:03 2010
@@ -88,7 +88,7 @@ namespace eval ::Rivet {
## Likewise we have also to add to auto_path the directory containing
## this script since it holds the pkgIndex.tcl file for package Rivet.
- set auto_path [linsert $auto_path 0 [file dirname [info script]]]
+# set auto_path [linsert $auto_path 0 [file dirname [info script]]]
## This will allow users to create proc libraries and tclIndex files
## in the local directory that can be autoloaded.
Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.c?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Fri Dec 3 22:01:03 2010
@@ -72,8 +72,8 @@ static server_rec *rivet_panic_server_
#define TCL_FILE 2
/* rivet return codes */
-#define RIVET_OK 0
-#define RIVET_ERROR 1
+#define RIVET_OK 0
+#define RIVET_ERROR 1
TCL_DECLARE_MUTEX(sendMutex);
@@ -81,13 +81,13 @@ TCL_DECLARE_MUTEX(sendMutex);
#define TCL_FILE_CTYPE "application/x-rivet-tcl"
/* This snippet of code came from the mod_ruby project, which is under a BSD license. */
-
+
static int Rivet_chdir_file (const char *file)
{
const char *x;
int chdir_retval = 0;
-
char chdir_buf[HUGE_STRING_LEN];
+
x = strrchr(file, '/');
if (x == NULL) {
chdir_retval = chdir(file);
@@ -125,14 +125,15 @@ Rivet_CheckType (request_rec *req)
int ctype = CTYPE_NOT_HANDLED;
if ( req->content_type != NULL ) {
- if( STRNEQU( req->content_type, RIVET_FILE_CTYPE) ) {
- ctype = RIVET_FILE;
- } else if( STRNEQU( req->content_type, TCL_FILE_CTYPE) ) {
- ctype = TCL_FILE;
- }
+ if( STRNEQU( req->content_type, RIVET_FILE_CTYPE) ) {
+ ctype = RIVET_FILE;
+ } else if( STRNEQU( req->content_type, TCL_FILE_CTYPE) ) {
+ ctype = TCL_FILE;
+ }
}
return ctype;
}
+
/*
* Rivet_ParseFileArgString (char *szDocRoot, char *szArgs, char **file)
*
@@ -221,6 +222,7 @@ Rivet_ParseFileArgString (const char *sz
* RIVET_DIR - Rivet's Tcl source directory
* RIVET_INIT - Rivet's init.tcl file
*/
+
static void
Rivet_InitServerVariables( Tcl_Interp *interp, apr_pool_t *p )
{
@@ -355,7 +357,8 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
/* If we don't have an error script, use the default error handler. */
if (conf->rivet_error_script ) {
- errscript = Tcl_NewStringObj(conf->rivet_error_script, -1);
+// errscript = Tcl_NewStringObj(conf->rivet_error_script, -1);
+ errscript = conf->rivet_error_script;
} else {
errscript = conf->rivet_default_error_script;
}
@@ -363,8 +366,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
Tcl_IncrRefCount(errscript);
if (Tcl_EvalObjEx(interp, errscript, 0) == TCL_ERROR) {
CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
- TclWeb_PrintError("<b>Rivet ErrorScript failed!</b>", 1,
- globals->req);
+ TclWeb_PrintError("<b>Rivet ErrorScript failed!</b>",1,globals->req);
TclWeb_PrintError( errorinfo, 0, globals->req );
}
@@ -377,7 +379,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
good:
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(*(conf->outchannel));
@@ -469,15 +471,13 @@ Rivet_ParseExecFile(TclWebRequest *req,
/* We don't have a compiled version. Let's create one. */
if (isNew || *(rsc->cache_size) == 0)
{
- //char *hkCopy;
-
outbuf = Tcl_NewObj();
Tcl_IncrRefCount(outbuf);
if (toplevel) {
if (rsc->rivet_before_script) {
- Tcl_AppendObjToObj(outbuf,
- Tcl_NewStringObj(rsc->rivet_before_script, -1));
+ Tcl_AppendObjToObj(outbuf,rsc->rivet_before_script);
+// Tcl_NewStringObj(rsc->rivet_before_script, -1));
}
}
@@ -504,7 +504,8 @@ Rivet_ParseExecFile(TclWebRequest *req,
}
if (toplevel) {
if (rsc->rivet_after_script) {
- Tcl_AppendObjToObj(outbuf,Tcl_NewStringObj(rsc->rivet_after_script, -1));
+// Tcl_AppendObjToObj(outbuf,Tcl_NewStringObj(rsc->rivet_after_script, -1));
+ Tcl_AppendObjToObj(outbuf,rsc->rivet_after_script);
}
}
@@ -655,6 +656,7 @@ Rivet_CopyConfig( rivet_server_conf *old
/*
* Merge the per-directory configuration options into a new configuration.
*/
+
static void
Rivet_MergeDirConfigVars(apr_pool_t *p, rivet_server_conf *new,
rivet_server_conf *base, rivet_server_conf *add )
@@ -709,7 +711,6 @@ Rivet_GetConf( request_rec *r )
newconfig = RIVET_NEW_CONF( r->pool );
Rivet_CopyConfig( rsc, newconfig );
-
Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
return newconfig;
@@ -722,13 +723,16 @@ Rivet_CreateConfig(apr_pool_t *p, server
FILEDEBUGINFO;
- rsc->server_interp = NULL;
- rsc->rivet_global_init_script = NULL;
- rsc->rivet_child_init_script = NULL;
- rsc->rivet_child_exit_script = NULL;
- rsc->rivet_before_script = NULL;
- rsc->rivet_after_script = NULL;
- rsc->rivet_error_script = NULL;
+ rsc->server_interp = NULL;
+
+/* scripts obj pointers *must* be initialized to NULL */
+
+ rsc->rivet_global_init_script = NULL;
+ rsc->rivet_child_init_script = NULL;
+ rsc->rivet_child_exit_script = NULL;
+ rsc->rivet_before_script = NULL;
+ rsc->rivet_after_script = NULL;
+ rsc->rivet_error_script = NULL;
rsc->user_scripts_updated = 0;
@@ -738,18 +742,18 @@ Rivet_CreateConfig(apr_pool_t *p, server
/* 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->upload_max = 0;
- rsc->upload_files_to_var = 1;
- rsc->separate_virtual_interps = 0;
- rsc->honor_header_only_reqs = 0;
- rsc->server_name = NULL;
- rsc->upload_dir = "/tmp";
- rsc->objCacheList = NULL;
- rsc->objCache = NULL;
+ *(rsc->cache_size) = -1;
+ *(rsc->cache_free) = 0;
+ rsc->upload_max = RIVET_MAX_POST;
+ rsc->upload_files_to_var = RIVET_UPLOAD_FILES_TO_VAR;
+ rsc->separate_virtual_interps = RIVET_SEPARATE_VIRTUAL_INTERPS;
+ 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->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 );
@@ -775,7 +779,7 @@ Rivet_PropagatePerDirConfArrays( Tcl_Int
/* Propagate all of the DirConf variables into an array. */
t = rsc->rivet_dir_vars;
arr = (apr_array_header_t*) apr_table_elts( t );
- elts = (apr_table_entry_t *)arr->elts;
+ elts = (apr_table_entry_t *) arr->elts;
nelts = arr->nelts;
arrayName = Tcl_NewStringObj( "RivetDirConf", -1 );
Tcl_IncrRefCount(arrayName);
@@ -837,6 +841,8 @@ Rivet_PerInterpInit(server_rec *s, rivet
{
Tcl_Interp *interp = rsc->server_interp;
rivet_interp_globals *globals = NULL;
+ Tcl_Obj* auto_path = NULL;
+ Tcl_Obj* rivet_tcl = NULL;
ap_assert (interp != (Tcl_Interp *)NULL);
Tcl_Preserve (interp);
@@ -858,25 +864,30 @@ Rivet_PerInterpInit(server_rec *s, rivet
globals = apr_pcalloc(p, sizeof(rivet_interp_globals));
Tcl_SetAssocData(interp, "rivet", NULL, globals);
- /* Eval Rivet's init.tcl file to load in the Tcl-level
- commands. */
+ /* Eval Rivet's init.tcl file to load in the Tcl-level commands. */
- /* We call Tcl_EvalFile on init.tcl. This call sets up
- * some variables and adds RIVETLIB_DESTDIR to auto_path.
- *
- * This is the old call for setting up the tcl environment.
- *
- * if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL)
- *
- * We may revert to it if we can devise a mechanism that
- * links a specific installation to RivetTcl's version
+ /* We put in front the auto_path list the path to the directory where
+ * init.tcl is located (provides package RivetTcl)
*/
- if (Tcl_EvalFile(interp,RIVET_RIVETLIB_DESTDIR"/init.tcl") == TCL_ERROR) {
+
+ auto_path = Tcl_GetVar2Ex(interp,"auto_path",NULL,TCL_GLOBAL_ONLY);
+
+ rivet_tcl = Tcl_NewStringObj(RIVET_DIR,-1);
+ Tcl_IncrRefCount(rivet_tcl);
+ if (Tcl_ListObjReplace(interp,auto_path,0,0,1,&rivet_tcl) == TCL_ERROR)
+ {
+ ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ "error setting auto_path: %s",Tcl_GetStringFromObj(auto_path,NULL));
+ }
+ Tcl_DecrRefCount(rivet_tcl);
+
+ if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL)
+ {
ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
"init.tcl must be installed correctly for Apache Rivet to function: %s",
Tcl_GetStringResult(interp) );
exit(1);
- }
+ }
/* Set the output buffer size to the largest allowed value, so that we
* won't send any result packets to the browser unless the Rivet
@@ -888,6 +899,44 @@ Rivet_PerInterpInit(server_rec *s, rivet
Tcl_Release(interp);
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * Rivet_AssignStringtoConf --
+ *
+ * Assign a string to a Tcl_Obj valued configuration parameter
+ *
+ * Arguments:
+ *
+ * - objPnt: Pointer to a pointer to a Tcl_Obj. If the pointer *objPnt
+ * is NULL (configuration script obj pointers are initialized to NULL)
+ * a new Tcl_Obj is created
+ * - string_value: a string to be assigned to the Tcl_Obj
+ *
+ * Results:
+ *
+ * - Pointer to a Tcl_Obj containing the parameter value.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Tcl_Obj*
+Rivet_AssignStringToConf (Tcl_Obj** objPnt, const char* string_value)
+{
+ Tcl_Obj *objarg = NULL;
+
+ if (*objPnt == NULL)
+ {
+ objarg = Tcl_NewStringObj(string_value,-1);
+ Tcl_IncrRefCount(objarg);
+ *objPnt = objarg;
+ } else {
+ objarg = *objPnt;
+ Tcl_AppendToObj(objarg, string_value, -1);
+ }
+ Tcl_AppendToObj( objarg, "\n", 1 );
+ return objarg;
+}
/*
*----------------------------------------------------------------------
@@ -902,57 +951,31 @@ Rivet_PerInterpInit(server_rec *s, rivet
*
* Results:
*
- * Returns the string representation of the current value for the
- * directive.
+ * Returns a Tcl_Obj* pointing to the string representation of
+ * the current value for the directive.
*
*----------------------------------------------------------------------
*/
+
static const char *
-Rivet_SetScript(apr_pool_t *pool, rivet_server_conf *rsc,
- const char *script, const char *string)
+Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc,
+ const char *script, const char *string)
{
Tcl_Obj *objarg = NULL;
if( STREQU( script, "GlobalInitScript" ) ) {
- if( rsc->rivet_global_init_script == NULL ) {
- objarg = Tcl_NewStringObj( string, -1 );
- Tcl_IncrRefCount( objarg );
- Tcl_AppendToObj( objarg, "\n", 1 );
- rsc->rivet_global_init_script = objarg;
- } else {
- objarg = rsc->rivet_global_init_script;
- Tcl_AppendToObj( objarg, string, -1 );
- Tcl_AppendToObj( objarg, "\n", 1 );
- }
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_global_init_script),string);
} else if( STREQU( script, "ChildInitScript" ) ) {
- if( rsc->rivet_child_init_script == NULL ) {
- objarg = Tcl_NewStringObj( string, -1 );
- Tcl_IncrRefCount( objarg );
- Tcl_AppendToObj( objarg, "\n", 1 );
- rsc->rivet_child_init_script = objarg;
- } else {
- objarg = rsc->rivet_child_init_script;
- Tcl_AppendToObj( objarg, string, -1 );
- Tcl_AppendToObj( objarg, "\n", 1 );
- }
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_child_init_script),string);
} else if( STREQU( script, "ChildExitScript" ) ) {
- if( rsc->rivet_child_exit_script == NULL ) {
- objarg = Tcl_NewStringObj( string, -1 );
- Tcl_IncrRefCount( objarg );
- Tcl_AppendToObj( objarg, "\n", 1 );
- rsc->rivet_child_exit_script = objarg;
- } else {
- objarg = rsc->rivet_child_exit_script;
- Tcl_AppendToObj( objarg, string, -1 );
- Tcl_AppendToObj( objarg, "\n", 1 );
- }
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_child_exit_script),string);
} else if( STREQU( script, "BeforeScript" ) ) {
- rsc->rivet_before_script = apr_pstrcat(pool, string, "\n", NULL);
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_before_script),string);
} else if( STREQU( script, "AfterScript" ) ) {
- rsc->rivet_after_script = apr_pstrcat(pool, string, "\n", NULL);
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_after_script),string);
} else if( STREQU( script, "ErrorScript" ) ) {
- rsc->rivet_error_script = apr_pstrcat(pool, string, "\n", NULL);
+ objarg = Rivet_AssignStringToConf(&(rsc->rivet_error_script),string);
}
if( !objarg ) return string;
@@ -1008,7 +1031,7 @@ Rivet_ServerConf( cmd_parms *cmd, void *
string = Rivet_SetScript( cmd->pool, rsc, var, val);
}
- apr_table_set( rsc->rivet_server_vars, var, string );
+ if (string != NULL) apr_table_set( rsc->rivet_server_vars, var, string );
return( NULL );
}
@@ -1020,7 +1043,8 @@ Rivet_ServerConf( cmd_parms *cmd, void *
* RivetDirConf AfterScript <script>
* RivetDirConf ErrorScript <script>
* RivetDirConf UploadDirectory <directory>
-*/
+ */
+
static const char *
Rivet_DirConf( cmd_parms *cmd, void *vrdc,
const char *var, const char *val )
@@ -1040,7 +1064,7 @@ Rivet_DirConf( cmd_parms *cmd, void *vrd
string = Rivet_SetScript( cmd->pool, rdc, var, val );
}
- apr_table_set( rdc->rivet_dir_vars, var, string );
+ if (string != NULL) apr_table_set( rdc->rivet_dir_vars, var, string );
return NULL;
}
@@ -1051,7 +1075,8 @@ Rivet_DirConf( cmd_parms *cmd, void *vrd
* RivetUserConf BeforeScript <script>
* RivetUserConf AfterScript <script>
* RivetUserConf ErrorScript <script>
-*/
+ */
+
static const char *
Rivet_UserConf( cmd_parms *cmd, void *vrdc,
const char *var,
@@ -1065,6 +1090,7 @@ Rivet_UserConf( cmd_parms *cmd, void *vr
if ( var == NULL || val == NULL ) {
return "Rivet Error: RivetUserConf requires two arguments";
}
+
/* We have modified these scripts. */
/* This is less than ideal though, because it will get set to 1
* every time - FIXME. */
@@ -1072,7 +1098,7 @@ Rivet_UserConf( cmd_parms *cmd, void *vr
string = Rivet_SetScript( cmd->pool, rdc, var, val );
/* XXX Need to figure out what to do about setting the table. */
- apr_table_set( rdc->rivet_user_vars, var, string );
+ if (string != NULL) apr_table_set( rdc->rivet_user_vars, var, string );
return NULL;
}
@@ -1310,17 +1336,18 @@ Rivet_ChildHandlers(server_rec *s, int i
Tcl_GetVar(rsc->server_interp, "errorInfo", 0));
}
Tcl_Release (rsc->server_interp);
-
}
}
if (!init) {
+
/*
* Upon child exit we delete the master interpreter before the
* caller invokes Tcl_Finalize. Even if we're running separate
* virtual interpreters, we don't delete the slaves
- * as deleting the master implicitly deltes its slave interpreters.
+ * as deleting the master implicitly deletes its slave interpreters.
*/
+
rsc = RIVET_SERVER_CONF(s->module_config);
if (!Tcl_InterpDeleted (rsc->server_interp)) {
Tcl_DeleteInterp(rsc->server_interp);
@@ -1353,7 +1380,6 @@ Rivet_ChildExit(void *data)
return OK;
}
-
/*
*-----------------------------------------------------------------------------
*
@@ -1410,6 +1436,7 @@ Rivet_InitTclStuff(server_rec *s, apr_po
* If the cache size is 0, the user has requested not to cache
* documents.
*/
+
if(*(rsc->cache_size) < 0) {
if (ap_max_requests_per_child != 0) {
*(rsc->cache_size) = ap_max_requests_per_child / 5;
@@ -1441,9 +1468,11 @@ Rivet_InitTclStuff(server_rec *s, apr_po
for (sr = s; sr; sr = sr->next)
{
myrsc = RIVET_SERVER_CONF(sr->module_config);
+
/* We only have a different rivet_server_conf if MergeConfig
* was called. We really need a separate one for each server,
* so we go ahead and create one here, if necessary. */
+
if (sr != s && myrsc == rsc) {
myrsc = RIVET_NEW_CONF(p);
ap_set_module_config(sr->module_config, &rivet_module, myrsc);
@@ -1660,7 +1689,7 @@ Rivet_SendContent(request_rec *r)
TclWeb_PrintHeaders(globals->req);
retval = OK;
goto sendcleanup;
- }
+ }
/*
* if we are handling the request we also want to check if a charset
Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.h?rev=1042023&r1=1042022&r2=1042023&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.h (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.h Fri Dec 3 22:01:03 2010
@@ -51,13 +51,13 @@
module AP_MODULE_DECLARE_DATA rivet_module;
typedef struct _rivet_server_conf {
- Tcl_Interp *server_interp; /* per server Tcl interpreter */
+ Tcl_Interp *server_interp; /* per server Tcl interpreter */
Tcl_Obj *rivet_global_init_script; /* run once when apache is started */
Tcl_Obj *rivet_child_init_script;
Tcl_Obj *rivet_child_exit_script;
- char *rivet_before_script; /* script run before each page */
- char *rivet_after_script; /* after */
- char *rivet_error_script; /* for errors */
+ Tcl_Obj *rivet_before_script; /* script run before each page */
+ Tcl_Obj *rivet_after_script; /* after */
+ Tcl_Obj *rivet_error_script; /* for errors */
/* This flag is used with the above directives. If any of them
have changed, it gets set. */
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org