You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2014/08/04 19:39:47 UTC
svn commit: r1615701 - in /tcl/rivet/branches/2.2: ./ m4/ rivet/ src/
src/apache-2/ src/channel/ src/config/ src/experimental/
Author: mxmanghi
Date: Mon Aug 4 17:39:46 2014
New Revision: 1615701
URL: http://svn.apache.org/r1615701
Log:
* configure.ac: adding support for --with-rivet-channel switch for alternate implementations
of a Rivet Tcl channel
* src/: further modularized to make refactoring a bit easier. But it's still the code
we released as 2.2.0
Added:
tcl/rivet/branches/2.2/m4/ax_split_version.m4
- copied unchanged from r1615699, tcl/rivet/trunk/m4/ax_split_version.m4
tcl/rivet/branches/2.2/rivet/init.tcl.in
- copied unchanged from r1615699, tcl/rivet/trunk/rivet/init.tcl.in
tcl/rivet/branches/2.2/src/config/
- copied from r1615699, tcl/rivet/trunk/src/config/
tcl/rivet/branches/2.2/src/experimental/
- copied from r1615699, tcl/rivet/trunk/src/experimental/
Removed:
tcl/rivet/branches/2.2/src/apache-2/TclWebapache.c
tcl/rivet/branches/2.2/src/apache-2/apache_config.c
tcl/rivet/branches/2.2/src/apache-2/apache_config.h
tcl/rivet/branches/2.2/src/apache-2/configure.in.tcl
tcl/rivet/branches/2.2/src/apache-2/configure.tcl
tcl/rivet/branches/2.2/src/apache-2/make.tcl
Modified:
tcl/rivet/branches/2.2/ (props changed)
tcl/rivet/branches/2.2/ChangeLog
tcl/rivet/branches/2.2/Makefile.in
tcl/rivet/branches/2.2/VERSION
tcl/rivet/branches/2.2/configure.ac
tcl/rivet/branches/2.2/rivet/init.tcl
tcl/rivet/branches/2.2/src/Makefile.am
tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
tcl/rivet/branches/2.2/src/apache-2/mod_rivet.h
tcl/rivet/branches/2.2/src/channel/rivetChannel.c
tcl/rivet/branches/2.2/src/channel/rivetChannel.h
Propchange: tcl/rivet/branches/2.2/
------------------------------------------------------------------------------
Merged /tcl/rivet/trunk:r1601659-1615699
Modified: tcl/rivet/branches/2.2/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/ChangeLog?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/ChangeLog (original)
+++ tcl/rivet/branches/2.2/ChangeLog Mon Aug 4 17:39:46 2014
@@ -1,3 +1,42 @@
+2014-08-04 Massimo Manghi <mx...@apache.org>
+ * configure.ac: adding support for --with-rivet-channel switch for alternate implementations
+ of a Rivet Tcl channel
+ * src/: further modularized to make refactoring a bit easier. But it's still the code
+ we released as 2.2.0
+
+2014-07-14 Massimo Manghi <mx...@apache.org>
+ * src/experimental/mod_rivet.c: working toy module capable of running Tcl scripts with a worker MPM
+ * src/experimental/rivetChannel.c: now depending on the thread private data
+
+2014-07-17 Massimo Manghi <mx...@apache.org>
+ * src/channel/rivetChannel.[c|h]: add preprocessor symbol to prevent multiple includes
+
+2014-07-16 Massimo Manghi <mx...@apache.org>
+ * src/experimental: add experimental code for threaded module
+
+2014-07-10 Massimo Manghi <mx...@apache.org>
+ * src/apache-2/apache_config.[h|c]: moved to src/config
+ * src/apache-2/TclWebapache.c: this file moved temporarily into src/config to separate it from
+ the specific module implementation
+ * src/experimental: making room to a new implementation of mod_rivet
+ * src/channel/rivetChannel.c: the request_rec pointer is passed through another pointer
+ as this channel is now the only channel handled by mod_rivet and it's shared across virutal hosts
+ * src/apache-2/mod_rivet.c: now creating only one Rivet channel instance and storing a pointer
+ to the current request_rec in the structure mod_rivet_globals, as the running the prefork MPM
+ we can only handle a request at a time.
+ * src/apache-2/*.tcl: removing obsolete tcl files
+
+2014-07-09 Massimo Manghi <mx...@apache.org>
+ * m4/ax_split_version.m4: adding macro for version number manipulation
+
+2014-06-22 Massimo Manghi <mx...@apache.org>
+ * configure.ac: new macros MOD_RIVET_CORE and RIVET_CHANNEL. Macro APACHE_VERSION preserved but not
+ called anymore
+ * rivet/init.tcl.in: Add template for rivet/init.tcl
+ * src/Makefile.am: building mod_rivet with code entirely selected by autoconf defined symbols
+ * src/apache-2/mod_rivet.c: comments added. Rivet package version depends now on preprocessor
+ symbol RIVET_TCL_PACKAGE_VERSION
+
2014-06-10 Massimo Manghi <mx...@apache.org>
* tests/rivet.test: removed lang.test as it was testing just a tautology
Modified: tcl/rivet/branches/2.2/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/Makefile.in?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/Makefile.in (original)
+++ tcl/rivet/branches/2.2/Makefile.in Mon Aug 4 17:39:46 2014
@@ -90,11 +90,11 @@ host_triplet = @host@
subdir = .
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
- $(srcdir)/config.h.in ChangeLog tclconfig/ChangeLog INSTALL \
- README TODO tclconfig/compile tclconfig/config.guess \
- tclconfig/config.sub tclconfig/depcomp tclconfig/install-sh \
- tclconfig/missing tclconfig/ltmain.sh \
- $(top_srcdir)/tclconfig/compile \
+ $(srcdir)/config.h.in $(top_srcdir)/rivet/init.tcl.in \
+ ChangeLog tclconfig/ChangeLog INSTALL README TODO \
+ tclconfig/compile tclconfig/config.guess tclconfig/config.sub \
+ tclconfig/depcomp tclconfig/install-sh tclconfig/missing \
+ tclconfig/ltmain.sh $(top_srcdir)/tclconfig/compile \
$(top_srcdir)/tclconfig/config.guess \
$(top_srcdir)/tclconfig/config.sub \
$(top_srcdir)/tclconfig/install-sh \
@@ -102,6 +102,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(sr
$(top_srcdir)/tclconfig/missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
+ $(top_srcdir)/m4/ax_split_version.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/tclconfig/tcl.m4 \
$(top_srcdir)/tclconfig/libtool.m4 \
$(top_srcdir)/m4/ax_prefix_config_h.m4 \
@@ -112,7 +113,7 @@ am__CONFIG_DISTCLEAN_FILES = config.stat
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = rivet/init.tcl
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -391,6 +392,8 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+rivet_channel = @rivet_channel@
+rivet_core = @rivet_core@
rivet_core_cmds = @rivet_core_cmds@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
@@ -464,6 +467,8 @@ $(srcdir)/config.h.in: $(am__configure_
distclean-hdr:
-rm -f config.h stamp-h1
+rivet/init.tcl: $(top_builddir)/config.status $(top_srcdir)/rivet/init.tcl.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
Modified: tcl/rivet/branches/2.2/VERSION
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/VERSION?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/VERSION (original)
+++ tcl/rivet/branches/2.2/VERSION Mon Aug 4 17:39:46 2014
@@ -1 +1 @@
-2.2.0
+2.2.1
Modified: tcl/rivet/branches/2.2/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/configure.ac?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/configure.ac (original)
+++ tcl/rivet/branches/2.2/configure.ac Mon Aug 4 17:39:46 2014
@@ -22,7 +22,7 @@ dnl
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------
-AC_INIT([Rivet],[2.2.0])
+AC_INIT([Rivet],[2.2.1])
TEA_INIT([3.9])
AC_CONFIG_AUX_DIR(tclconfig)
@@ -422,6 +422,24 @@ AC_DEFUN([APACHE_VERSION],[
MOD_RIVET_INCLUDES="-I${apache_version_dir}"
])
+# MOD_RIVET_CORE
+#
+
+AC_DEFUN([MOD_RIVET_CORE],[
+ AC_ARG_WITH(
+ rivet_core,
+ [ --with-rivet-core[=path] mod_rivet core directory],,
+ [with_rivet_core="apache-2"]
+ )
+
+ rivet_core=${with_rivet_core}
+ AC_MSG_CHECKING(mod_rivet core)
+ AC_SUBST(rivet_core)
+ AC_MSG_RESULT([$with_rivet_core])
+])
+
+#
+
AC_DEFUN([HANDLE_TCL_PACKAGE_PATH],[
# shamelessly stolen from TEA_LOAD_TCLCONFIG
AC_MSG_CHECKING([Debian TCL_PACKAGE_PATH workaround])
@@ -483,11 +501,28 @@ AC_DEFUN([RIVET_CORE_CMDS],[
])
+# RIVET_CHANNEL
+#
+# selecting the Rivet channel code directory
+
+AC_DEFUN([RIVET_CHANNEL],[
+ AC_ARG_WITH(
+ rivet_channel,
+ [ --with-rivet-channel=DIR Rivet channel code path ],,
+ [with_rivet_channel="channel"]
+ )
+
+ AC_MSG_CHECKING(for Rivet channel code path)
+ rivet_channel=${with_rivet_channel}
+ AC_SUBST(rivet_channel)
+ AC_MSG_RESULT([$with_rivet_channel])
+])
+
AC_DEFUN([RIVET_TCL_LIB],[
AC_ARG_WITH(
rivet_target_dir,
- [ --with-rivet-target-dir=DIR Rivet tcl library target dir ],,
+ [ --with-rivet-target-dir=DIR Rivet tcl library target dir ],,
with_rivet_target_dir="${apache_base}/lib/rivet${PACKAGE_VERSION}"
)
AC_MSG_CHECKING(for Rivet tcl library target)
@@ -534,7 +569,7 @@ AC_DEFUN([DISPLAY_RIVET_VERSION],[
AC_DEFUN([UPLOAD_DIRECTORY],[
AC_ARG_WITH(
upload_dir,
- [ --with-upload-dir=DIR Default directory for uploads],,
+ [ --with-upload-dir=DIR Default directory for uploads],,
with_upload_dir="/tmp"
)
AC_MSG_CHECKING(where Rivet will save uploads)
@@ -601,7 +636,7 @@ AC_DEFUN([RIVET_COMMANDS_EXPORT],[
AC_DEFUN([IMPORT_RIVET_COMMANDS],[
AC_ARG_ENABLE(
import-rivet-commands,
- [ --disable-import-rivet-commands requires explicit namespace import],
+ [ --disable-import-rivet-commands requires explicit namespace import],
[ import_rivet_commands=$enable_import_rivet_commands],
[ import_rivet_commands="yes"]
)
@@ -685,7 +720,8 @@ AC_DEFUN([UPLOAD_TO_VAR],[
])
-APACHE_VERSION
+#APACHE_VERSION
+MOD_RIVET_CORE
GET_RIVET_BASE
APACHE
CHECK_APXS
@@ -701,6 +737,16 @@ UPLOAD_TO_VAR
IMPORT_RIVET_COMMANDS
APACHE_REQUEST
RIVET_CORE_CMDS
+RIVET_CHANNEL
+
+# Let's separate the point version from the major and minor version
+# to build a Rivet version to be substituted as basic version for
+# package Rivet, central initialization of the Tcl environment
+
+VERSION=${PACKAGE_VERSION}
+AX_SPLIT_VERSION
+AC_DEFINE_UNQUOTED(TCL_PACKAGE_VERSION,"${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}",[Rivet Tcl package version])
+AC_MSG_NOTICE([Rivet package version is ${AX_MAJOR_VERSION}.${AX_MINOR_VERSION}])
if test $import_rivet_commands = "yes"; then
AC_MSG_NOTICE([forcing Rivet to export commands from ::rivet namespace])
@@ -728,7 +774,7 @@ AC_SUBST(TCL_PACKAGE_PATH)
# You may alternatively have a special pkgIndex.tcl.in or other files
# which require substituting the AC variables in. Include these here.
#--------------------------------------------------------------------
-AC_CONFIG_FILES([Makefile src/Makefile src/librivet/Makefile src/parser/Makefile doc/Makefile doc/convert_examples.tcl])
+AC_CONFIG_FILES([Makefile src/Makefile rivet/init.tcl src/parser/Makefile doc/Makefile doc/convert_examples.tcl])
#case $apache_version_dir in
# apache-1) AC_CONFIG_FILES([Makefile src/Makefile src/apache-1/Makefile doc/Makefile]) ;;
@@ -737,7 +783,7 @@ AC_CONFIG_FILES([Makefile src/Makefile s
AC_OUTPUT
if test "$print_fileevent_msg" = "1"; then
- AC_MSG_NOTICE([=======================================================================])
+ AC_MSG_NOTICE([========================================================================])
AC_MSG_NOTICE([ WARNING!])
AC_MSG_NOTICE([========================================================================])
AC_MSG_NOTICE([The Tcl notifier (and consequently the event loop) does not work with])
Modified: tcl/rivet/branches/2.2/rivet/init.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/rivet/init.tcl?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/rivet/init.tcl (original)
+++ tcl/rivet/branches/2.2/rivet/init.tcl Mon Aug 4 17:39:46 2014
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-package provide Rivet 2.1
+package provide Rivet 2.2
namespace eval ::Rivet {
Modified: tcl/rivet/branches/2.2/src/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/Makefile.am?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/Makefile.am (original)
+++ tcl/rivet/branches/2.2/src/Makefile.am Mon Aug 4 17:39:46 2014
@@ -25,7 +25,7 @@ lib_libexec_LTLIBRARIES = librivetparser
librivetparser_la_SOURCES = parser/rivetParser.c parser/parserPkgInit.c
librivetparser_la_LDFLAGS = @TCL_STUB_LIB_SPEC@ @APXS_LDFLAGS@ -module -avoid-version
librivetparser_la_LIBADD = @APXS_LIBS@
-librivetparser_la_CPPFLAGS = @apache_include@ -I@apache_version_dir@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS
+librivetparser_la_CPPFLAGS = @apache_include@ -I@rivet_core@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS
#
# Rivet Library
@@ -33,7 +33,7 @@ librivetparser_la_CPPFLAGS = @apache_inc
librivetlib_la_SOURCES = librivet/rivetList.c librivet/rivetCrypt.c librivet/rivetWWW.c librivet/rivetPkgInit.c
librivetlib_la_LDFLAGS = @TCL_STUB_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
librivetlib_la_LIBADD = @APXS_LIBS@
-librivetlib_la_CPPFLAGS = -I@apache_version_dir@ -I@apache_request@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_INCLUDES@ @APR_CPPFLAGS@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS
+librivetlib_la_CPPFLAGS = -I@rivet_core@ -I@apache_request@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_INCLUDES@ @APR_CPPFLAGS@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS
#
# mod_rivet
@@ -43,18 +43,16 @@ apxs_libexec_LTLIBRARIES = mod_rivet.la
mod_rivet_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
mod_rivet_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@
-mod_rivet_la_CPPFLAGS = -I@apache_version_dir@ -Ichannel -Iparser -I@apache_request@ @apache_include@ -I@RIVET_BASE_INCLUDE@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_CPPFLAGS@ @APR_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
+mod_rivet_la_CPPFLAGS = -I@rivet_core@ -I@rivet_channel@ -Iconfig -Iparser -I@apache_request@ @apache_include@ -I@RIVET_BASE_INCLUDE@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_CPPFLAGS@ @APR_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
-
-mod_rivet_la_SOURCES = \
- @apache_request@/apache_multipart_buffer.c \
- @apache_request@/apache_request.c \
- @apache_version_dir@/mod_rivet.c \
- @apache_version_dir@/TclWebapache.c \
- @apache_version_dir@/apache_config.c \
- @rivet_core_cmds@/rivetCore.c \
+mod_rivet_la_SOURCES = @apache_request@/apache_multipart_buffer.c \
+ @apache_request@/apache_request.c \
+ @rivet_core@/mod_rivet.c \
+ @rivet_core_cmds@/rivetCore.c \
@rivet_core_cmds@/rivetInspect.c \
- channel/rivetChannel.c \
+ @rivet_channel@/rivetChannel.c \
+ config/TclWebapache.c \
+ config/apache_config.c \
parser/rivetParser.c
# Removing libtool .la files from installation
Modified: tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c Mon Aug 4 17:39:46 2014
@@ -88,10 +88,19 @@ TCL_DECLARE_MUTEX(sendMutex);
#define RIVET_TEMPLATE_CTYPE "application/x-httpd-rivet"
#define RIVET_TCLFILE_CTYPE "application/x-rivet-tcl"
+/*
+ * for some reason the max buffer size definition is not exported by Tcl
+ * we steal and reproduce it here prepending the name with TCL
+ */
+
+#define TCL_MAX_CHANNEL_BUFFER_SIZE (1024*1024)
+
static Tcl_Interp* Rivet_CreateTclInterp (server_rec* s);
static void Rivet_CreateCache (server_rec *s, apr_pool_t *p);
static apr_status_t Rivet_ChildExit(void *data);
+mod_rivet_globals* rivet_module_globals = NULL;
+
/*
* -- Rivet_chdir_file (const char* filename)
*
@@ -176,8 +185,8 @@ Rivet_CheckType (request_rec *req)
*
* Arguments:
*
- * Tcl_Interp*: pointer to the Tcl interpreter
- * apr_pool_t*: pool used for calling Apache framework functions
+ * Tcl_Interp* interp: pointer to the Tcl interpreter
+ * apr_pool_t* pool: pool used for calling Apache framework functions
*
* Returned value:
* none
@@ -290,18 +299,40 @@ Rivet_InitServerVariables( Tcl_Interp *i
}
}
-
-/* Calls Tcl_EvalObjEx() and checks for errors
- * Prints the error buffer if any.
+/* -- Rivet_ExecuteAndCheck
+ *
+ * Tcl script execution central procedure. The script stored
+ * outbuf is evaluated and in case an error occurs in the execution
+ * an error handler is executed. In case the error code returned
+ * is RIVET then the error was caused by the invocation of a
+ * abort_page command and the script stored in conf->abort_script
+ * is run istead. The default error script prints the error buffer
+ *
+ * Arguments:
+ *
+ * - Tcl_Interp* interp: the Tcl interpreter
+ * - Tcl_Obj* tcl_script_obj: a pointer to the Tcl_Obj holding the script
+ * - request_rec* req: the current request_rec object pointer
+ *
+ * Returned value:
+ *
+ * - invariably TCL_OK
+ *
+ * Side effects:
+ *
+ * The Tcl interpreter internal status is changed by the execution
+ * of the script
+ *
*/
+
static int
-Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec *req)
+Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *tcl_script_obj, request_rec *req)
{
rivet_server_conf *conf = Rivet_GetConf(req);
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
Tcl_Preserve (interp);
- if ( Tcl_EvalObjEx(interp, outbuf, 0) == TCL_ERROR ) {
+ if ( Tcl_EvalObjEx(interp, tcl_script_obj, 0) == TCL_ERROR ) {
Tcl_Obj *errscript;
Tcl_Obj *errorCodeListObj;
Tcl_Obj *errorCodeElementObj;
@@ -352,7 +383,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
}
}
- Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( outbuf, NULL ),TCL_GLOBAL_ONLY );
+ Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( tcl_script_obj, NULL ),TCL_GLOBAL_ONLY );
/* If we don't have an error script, use the default error handler. */
if (conf->rivet_error_script ) {
@@ -406,13 +437,12 @@ good:
*
* Arguments:
*
- * - TclWebRequest: pointer to the structure collecting Tcl and Apache
- * data
- * - filename: pointer to a string storing the path to the template or
- * Tcl script
- * - toplevel: integer to be interpreted as a boolean meaning the
- * file is pointed by the request. When 0 that's a subtemplate being
- * parsed and executed from another template
+ * - TclWebRequest: pointer to the structure collecting Tcl and Apache data
+ * - filename: pointer to a string storing the path to the template or
+ * Tcl script
+ * - toplevel: integer to be interpreted as a boolean meaning the
+ * file is pointed by the request. When 0 that's a subtemplate
+ * to be parsed and executed from another template
*/
int
@@ -478,8 +508,6 @@ Rivet_ParseExecFile(TclWebRequest *req,
ctime = buf.st_ctime;
mtime = buf.st_mtime;
} else {
- //ctime = req->req->finfo.st_ctime;
- //mtime = req->req->finfo.st_mtime;
ctime = req->req->finfo.ctime;
mtime = req->req->finfo.mtime;
}
@@ -692,16 +720,14 @@ Rivet_PerInterpInit(server_rec *s, rivet
ap_assert (interp != (Tcl_Interp *)NULL);
Tcl_Preserve (interp);
- /* Create TCL commands to deal with Apache's BUFFs. */
- rsc->outchannel = apr_pcalloc(p, sizeof(Tcl_Channel));
- *(rsc->outchannel) = Tcl_CreateChannel(&RivetChan, "apacheout", rsc, TCL_WRITABLE);
+ /* We register the Tcl channel to the interpreter */
- Tcl_SetStdChannel(*(rsc->outchannel), TCL_STDOUT);
+ Tcl_RegisterChannel(interp, *(rsc->outchannel));
/* Set up interpreter associated data */
- globals = apr_pcalloc(p, sizeof(rivet_interp_globals));
- Tcl_SetAssocData(interp,"rivet",NULL,globals);
+ globals = apr_pcalloc (p, sizeof(rivet_interp_globals));
+ Tcl_SetAssocData (interp,"rivet",NULL,globals);
/*
* abort_page status variables in globals are set here and then
@@ -744,7 +770,7 @@ Rivet_PerInterpInit(server_rec *s, rivet
Rivet_InitServerVariables(interp, p );
// Rivet_PropagateServerConfArray( interp, rsc );
- /* Loading into the interpreter the commands provided by librivet.so */
+ /* Loading into the interpreter commands in librivet.so */
/* Tcl Bug #3216070 has been solved with 8.5.10 and commands shipped with
* Rivetlib can be mapped at this stage
*/
@@ -769,9 +795,13 @@ Rivet_PerInterpInit(server_rec *s, rivet
/* Watch out! Calling Tcl_PkgRequire with a version number binds this module to
* the Rivet package revision number in rivet/init.tcl
+ *
+ * RIVET_TCL_PACKAGE_VERSION is defined by configure.ac as the combination
+ * "MAJOR_VERSION.MINOR_VERSION". We don't expect to change rivet/init.tcl
+ * across patchlevel releases
*/
- if (Tcl_PkgRequire(interp, "Rivet", "2.1", 1) == NULL)
+ if (Tcl_PkgRequire(interp, "Rivet", RIVET_TCL_PACKAGE_VERSION, 1) == NULL)
{
ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
MODNAME ": init.tcl must be installed correctly for Apache Rivet to function: %s (%s)",
@@ -779,26 +809,18 @@ Rivet_PerInterpInit(server_rec *s, rivet
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
- * programmer does a "flush stdout" or the page is completed.
- */
-
- Tcl_SetChannelBufferSize (*(rsc->outchannel), 1000000);
- Tcl_RegisterChannel(interp, *(rsc->outchannel));
Tcl_Release(interp);
}
static int
-Rivet_InitHandler(apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp,
- server_rec *s)
+Rivet_InitHandler(apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp, server_rec *s)
{
rivet_server_conf *rsc = RIVET_SERVER_CONF( s->module_config );
- rivet_panic_pool = pPool;
+ rivet_panic_pool = pPool;
rivet_panic_server_rec = s;
+ rivet_module_globals = apr_palloc(pPool,sizeof(mod_rivet_globals));
+ rivet_module_globals->rsc_p = rsc;
#if RIVET_DISPLAY_VERSION
ap_add_version_component(pPool, RIVET_PACKAGE_NAME"/"RIVET_VERSION);
#else
@@ -807,15 +829,36 @@ Rivet_InitHandler(apr_pool_t *pPool, apr
FILEDEBUGINFO;
+ /* we create and initialize a master (server) interpreter */
+
rsc->server_interp = Rivet_CreateTclInterp(s) ; /* root interpreter */
- Rivet_PerInterpInit(s, rsc, pPool);
- Rivet_CreateCache(s,pPool);
+ /* Create TCL channel and store a pointer in the rivet_server_conf object */
+
+ rsc->outchannel = apr_pcalloc (pPool, sizeof(Tcl_Channel));
+ *(rsc->outchannel) = Tcl_CreateChannel(&RivetChan, "apacheout", rivet_module_globals, TCL_WRITABLE);
- /* we create and initialize a master (server) interpreter
- * Rivet_InitTclStuff(s,pPool);
+ /* The channel we have just created replaces Tcl's stdout */
+
+ Tcl_SetStdChannel (*(rsc->outchannel), TCL_STDOUT);
+
+ /* 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
+ * programmer does a "flush stdout" or the page is completed.
*/
+ Tcl_SetChannelBufferSize (*(rsc->outchannel), TCL_MAX_CHANNEL_BUFFER_SIZE);
+
+ /* We register the Tcl channel to the interpreter */
+
+ Tcl_RegisterChannel(rsc->server_interp, *(rsc->outchannel));
+
+ Rivet_PerInterpInit(s, rsc, pPool);
+
+ /* we create also the cache */
+
+ Rivet_CreateCache(s,pPool);
+
if (rsc->rivet_server_init_script != NULL) {
Tcl_Interp* interp = rsc->server_interp;
@@ -862,7 +905,7 @@ Rivet_Panic TCL_VARARGS_DEF(CONST char *
char *format;
format = (char *) TCL_VARARGS_START(char *,arg1,argList);
- buf = (char *) apr_pvsprintf(rivet_panic_pool, format, argList);
+ buf = (char *) apr_pvsprintf(rivet_panic_pool, format, argList);
if (rivet_panic_request_rec != NULL) {
ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL,
@@ -883,8 +926,10 @@ Rivet_Panic TCL_VARARGS_DEF(CONST char *
*
* Arguments:
* server_rec* s: pointer to a server_rec structure
+ *
* Results:
* pointer to a Tcl_Interp structure
+ *
* Side Effects:
*
*-----------------------------------------------------------------------------
@@ -1035,6 +1080,7 @@ Rivet_InitTclStuff(server_rec *s, apr_po
}
myrsc->outchannel = rsc->outchannel;
+
/* This sets up slave interpreters for other virtual hosts. */
if (sr != s) /* not the first one */
{
@@ -1144,6 +1190,12 @@ Rivet_ChildHandlers(server_rec *s, int i
}
Tcl_Release (rsc->server_interp);
}
+
+ if (!init)
+ {
+ Tcl_UnregisterChannel(rsc->server_interp,*(rsc->outchannel));
+ }
+
}
if (!init) {
@@ -1209,7 +1261,7 @@ Rivet_ChildInit(apr_pool_t *pChild, serv
*/
static apr_status_t
-Rivet_ChildExit(void *data)
+Rivet_ChildExit (void *data)
{
server_rec *s = (server_rec*) data;
ap_assert (s != (server_rec *)NULL);
@@ -1254,6 +1306,7 @@ Rivet_SendContent(request_rec *r)
rivet_panic_request_rec = r;
rsc = Rivet_GetConf(r);
+ rivet_module_globals->rsc_p = rsc;
interp = rsc->server_interp;
globals = Tcl_GetAssocData(interp, "rivet", NULL);
@@ -1331,28 +1384,6 @@ Rivet_SendContent(request_rec *r)
goto sendcleanup;
}
- /* Set the script name. */
- {
-#if 1
- /*
- Tcl_Obj *infoscript = Tcl_NewStringObj("info script ", -1);
- Tcl_IncrRefCount(infoscript);
- Tcl_AppendToObj(infoscript, r->filename, -1);
- Tcl_EvalObjEx(interp, infoscript, TCL_EVAL_DIRECT);
- Tcl_DecrRefCount(infoscript);
- */
-#else
- /* This speeds things up, but you have to use Tcl internal
- * declerations, which is not so great... */
- Interp *iPtr = (Interp *) interp;
- if (iPtr->scriptFile != NULL) {
- Tcl_DecrRefCount(iPtr->scriptFile);
- }
- iPtr->scriptFile = Tcl_NewStringObj(r->filename, -1);
- Tcl_IncrRefCount(iPtr->scriptFile);
-#endif
- }
-
/* Apache Request stuff */
TclWeb_InitRequest(globals->req, interp, r);
@@ -1470,16 +1501,14 @@ rivet_register_hooks (apr_pool_t *p)
ap_hook_child_init (Rivet_ChildInit, NULL, NULL, APR_HOOK_LAST);
}
+/* mod_rivet basic structures */
const command_rec rivet_cmds[] =
{
- AP_INIT_TAKE2("RivetServerConf", Rivet_ServerConf,
- NULL, RSRC_CONF, NULL),
- AP_INIT_TAKE2("RivetDirConf", Rivet_DirConf,
- NULL, ACCESS_CONF, NULL),
- AP_INIT_TAKE2("RivetUserConf", Rivet_UserConf,
- NULL, ACCESS_CONF|OR_FILEINFO,
- "RivetUserConf key value: sets RivetUserConf(key) = value"),
+ AP_INIT_TAKE2 ("RivetServerConf", Rivet_ServerConf, NULL, RSRC_CONF, NULL),
+ AP_INIT_TAKE2 ("RivetDirConf", Rivet_DirConf, NULL, ACCESS_CONF, NULL),
+ AP_INIT_TAKE2 ("RivetUserConf", Rivet_UserConf, NULL, ACCESS_CONF|OR_FILEINFO,
+ "RivetUserConf key value: sets RivetUserConf(key) = value"),
{NULL}
};
Modified: tcl/rivet/branches/2.2/src/apache-2/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/apache-2/mod_rivet.h?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/apache-2/mod_rivet.h (original)
+++ tcl/rivet/branches/2.2/src/apache-2/mod_rivet.h Mon Aug 4 17:39:46 2014
@@ -113,6 +113,14 @@ typedef struct _rivet_interp_globals {
server_rec* srec; /* pointer to the current server rec obj */
} rivet_interp_globals;
+/*
+ * we need also a place where to store module wide globals
+ */
+
+typedef struct _mod_rivet_globals {
+ rivet_server_conf* rsc_p;
+} mod_rivet_globals;
+
int Rivet_ParseExecFile (TclWebRequest *req, char *filename, int toplevel);
int Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf);
@@ -125,11 +133,8 @@ rivet_server_conf *Rivet_GetConf(request
#undef ap_set_module_config
#endif
-#define RIVET_SERVER_CONF(module) \
- (rivet_server_conf *)ap_get_module_config(module, &rivet_module)
-
-#define RIVET_NEW_CONF(p) \
- (rivet_server_conf *)apr_pcalloc(p, sizeof(rivet_server_conf))
+#define RIVET_SERVER_CONF(module) (rivet_server_conf *)ap_get_module_config(module, &rivet_module)
+#define RIVET_NEW_CONF(p) (rivet_server_conf *)apr_pcalloc(p, sizeof(rivet_server_conf))
Tcl_Obj* Rivet_BuildConfDictionary ( Tcl_Interp* interp,
rivet_server_conf* rivet_conf);
Modified: tcl/rivet/branches/2.2/src/channel/rivetChannel.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/channel/rivetChannel.c?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/channel/rivetChannel.c (original)
+++ tcl/rivet/branches/2.2/src/channel/rivetChannel.c Mon Aug 4 17:39:46 2014
@@ -41,10 +41,11 @@ inputproc(ClientData instancedata, char
Channel that we create to divert stdout to. */
static int
-outputproc(ClientData instancedata, CONST84 char *buf,
- int toWrite, int *errorCodePtr)
+outputproc(ClientData instancedata, CONST84 char *buf, int toWrite, int *errorCodePtr)
{
- rivet_server_conf *rsc = (rivet_server_conf *)instancedata;
+ mod_rivet_globals* rivet_module_globals = (mod_rivet_globals *)instancedata;
+
+ rivet_server_conf *rsc = rivet_module_globals->rsc_p;
rivet_interp_globals *globals =
Tcl_GetAssocData(rsc->server_interp, "rivet", NULL);
@@ -65,7 +66,7 @@ closeproc(ClientData instancedata, Tcl_I
static int
setoptionproc(ClientData instancedata, Tcl_Interp *interp,
- CONST84 char *optionname, CONST84 char *value)
+ CONST84 char *optionname, CONST84 char *value)
{
return TCL_OK;
}
Modified: tcl/rivet/branches/2.2/src/channel/rivetChannel.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/channel/rivetChannel.h?rev=1615701&r1=1615700&r2=1615701&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/channel/rivetChannel.h (original)
+++ tcl/rivet/branches/2.2/src/channel/rivetChannel.h Mon Aug 4 17:39:46 2014
@@ -1,3 +1,8 @@
+
+
+#ifndef _RIVET_CHANNEL_H_
+#define _RIVET_CHANNEL_H_
+
/* Functions for mod_dtcl Tcl output channel .*/
#include "mod_rivet.h"
@@ -11,4 +16,4 @@ extern void watchproc(ClientData, int);
extern int gethandleproc(ClientData, int, ClientData *);
extern Tcl_ChannelType RivetChan;
-
+#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org