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 2015/11/25 15:20:05 UTC
svn commit: r1716424 - in /tcl/rivet/trunk: ./ doc/xml/ rivet/
rivet/rivet-tcl/ src/ src/librivet/ src/mod_rivet/ tests/
Author: mxmanghi
Date: Wed Nov 25 14:20:05 2015
New Revision: 1716424
URL: http://svn.apache.org/viewvc?rev=1716424&view=rev
Log:
* src/rivet.h: defined RIVET_CMD_EXPORT as wrapper to Tcl_Export
* tests/bailout.test: redirect.test renamed as bailout.test. It's meant
to gather all the tests concerning exceptions like abort_page and ::rivet::exit
* src/librivet/rivet[Crypt|WWW|List].c: command export mechanism changed
as we are now explicitly exporting commands
* rivet/rivet-tcl/catch.tcl: new (non-exported) command ::rivet::catch
* rivet/init.tcl[.in]: command export mechanics changed
* src/mod_rivet/rivetCore.c: command export made explicit through RIVET_CMD_EXPORT.
Abort page command now handling also [::rivet::abort_page -exiting] test
Added:
tcl/rivet/trunk/rivet/rivet-tcl/catch.tcl
tcl/rivet/trunk/tests/bailout.test
- copied, changed from r1715023, tcl/rivet/trunk/tests/redirect.test
tcl/rivet/trunk/tests/exit.tcl
Removed:
tcl/rivet/trunk/tests/redirect.test
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/doc/xml/commands.xml
tcl/rivet/trunk/rivet/init.tcl
tcl/rivet/trunk/rivet/init.tcl.in
tcl/rivet/trunk/rivet/rivet-tcl/tclIndex
tcl/rivet/trunk/src/librivet/rivetCrypt.c
tcl/rivet/trunk/src/librivet/rivetList.c
tcl/rivet/trunk/src/librivet/rivetPkgInit.c
tcl/rivet/trunk/src/librivet/rivetWWW.c
tcl/rivet/trunk/src/mod_rivet/rivetCore.c
tcl/rivet/trunk/src/rivet.h
tcl/rivet/trunk/tests/rivet.test
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Wed Nov 25 14:20:05 2015
@@ -1,3 +1,14 @@
+2015-11-25 Massimo Manghi <mx...@apache.org>
+ * src/rivet.h: defined RIVET_CMD_EXPORT as wrapper to Tcl_Export
+ * tests/bailout.test: redirect.test renamed as bailout.test. It's meant
+ to gather all the tests concerning exceptions like abort_page and ::rivet::exit
+ * src/librivet/rivet[Crypt|WWW|List].c: command export mechanism changed
+ as we are now explicitly exporting commands
+ * rivet/rivet-tcl/catch.tcl: new (non-exported) command ::rivet::catch
+ * rivet/init.tcl[.in]: command export mechanics changed
+ * src/mod_rivet/rivetCore.c: command export made explicit through RIVET_CMD_EXPORT.
+ Abort page command now handling also [::rivet::abort_page -exiting] test
+
2015-10-27 Massimo Manghi <mx...@apache.org>
* rivet/init.tcl.in: actually was this file that had to be changed
Modified: tcl/rivet/trunk/doc/xml/commands.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/commands.xml?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/commands.xml (original)
+++ tcl/rivet/trunk/doc/xml/commands.xml Wed Nov 25 14:20:05 2015
@@ -569,6 +569,56 @@
</refsect1>
</refentry>
+ <refentry id="exit">
+ <refnamediv>
+ <refname>exit</refname>
+ <refpurpose>terminate execution and child process</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>::rivet::exit</command>
+ <arg>code</arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Description</title>
+ <para>
+ Replaces Tcl's <command>exit</command> core command. <command>::rivet::exit</command>
+ interrupts execution of the current script and passes execution to AbortScript if
+ such script is set. After AbortScript has finished and request processing completed
+ the child process is forced to exit by calling Tcl_Exit producing the same final
+ effect of the core command. During an <command>AbortScript</command> execution the
+ exit condition can be detected
+ <programlisting>if {[<command>::rivet::abort_page -exiting</command>]} {
+...handle exit condition
+}</programlisting>
+ </para>
+ <para>
+ <command>::rivet::exit</command> has a single optional argument <arg>code</arg>. This
+ value must be a positive integer number to be passed to Tcl_Exit. If any other value is
+ given <arg>code</arg> is set to 0. The exit code can be obtained from the dictionary
+ returned by <command>::rivet::abort_code</command>
+ </para>
+ <programlisting>[::rivet::abort_code]
+<== return_code <arg>code</arg> error_code exit</programlisting>
+ <para>
+ We support this command in order to have a gentle way to terminate a request processing
+ before actually exit the child process and avoid an abrupt interruption of a request that
+ might leave an application in a inconsistent state. In some cases <command>::rivet::exit</command>
+ could be the only way to exit a process and force the Apache HTTP web server to start
+ a fresh one. Moreover the core <command>exit</command> could be called from third parties
+ software and you may not be aware of it. We thus decided to trap this command and give it
+ the most gentle behavior still preserving the its basic purpose.
+ </para>
+ <note>
+ Nonetheless we discourage the programmer to use such command, and suggest to focus on proper
+ application design and avoid such a drastic way to bail out.
+ If you need to restart the child processes from time to time we recommend to check the
+ MaxRequests parameter in the
+ <ulink url="https://httpd.apache.org/docs/2.4/mod/prefork.html">prefork MPM documentation</ulink>
+ </note>
+ </refsect1>
+ </refentry>
<refentry id="headers">
<refnamediv>
Modified: tcl/rivet/trunk/rivet/init.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/init.tcl?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/init.tcl (original)
+++ tcl/rivet/trunk/rivet/init.tcl Wed Nov 25 14:20:05 2015
@@ -40,25 +40,19 @@ namespace eval ::Rivet {
set dir $tclpath
source [file join $tclpath tclIndex]
- }
-
- set command_list [namespace eval ::rivet_temp {array names auto_index}]
- # commands in 'command_list' are prefixed with ::rivet, so we have to
- # remove it to build an export list
-
- set export_list {}
- foreach c $command_list {
- if {[regexp {::rivet::(.*)} $c m cmd]} {
- lappend export_list $cmd
-# namespace eval ::rivet [list namespace export $cmd]
- }
+ # Rivet Tcl commands not meant to go onto the export list must
+ # be unset from auto_index here
+
+ unset auto_index(::rivet::catch)
}
+ set command_list [namespace eval ::rivet_temp {array names auto_index}]
+
# we won't left anything behind
namespace delete ::rivet_temp
- return $export_list
+ return $command_list
}
###
@@ -125,7 +119,7 @@ namespace eval ::Rivet {
## we keep in ::rivet::export_list a list of importable commands
- namespace eval ::rivet [list set export_list [tcl_commands_export_list $tclpath]]
+ namespace eval ::rivet [list set cmd_export_list [tcl_commands_export_list $tclpath]]
namespace eval ::rivet {
## init.tcl is run by mod_rivet (which creates the ::rivet namespace) but it gets run
@@ -135,9 +129,18 @@ namespace eval ::Rivet {
if {[info exists module_conf(export_namespace_commands)] && \
$module_conf(export_namespace_commands)} {
+ # commands in 'command_list' are prefixed with ::rivet, so we have to
+ # remove it to build an export list
+
+ set export_list {}
+ foreach c $cmd_export_list {
+ lappend export_list [namespace tail $c]
+ }
+
+ #puts stderr "exporting $export_list"
eval namespace export $export_list
- }
+ }
}
## Add the packages directory to the auto_path.
## If we have a packages$tcl_version directory
@@ -166,16 +169,15 @@ namespace eval ::Rivet {
} ;## namespace eval ::Rivet
-
-## eventually we have to divert Tcl ::exit to ::rivet::exit_thread
+## eventually we have to divert Tcl ::exit to ::rivet::exit
rename ::exit ::Rivet::tclcore_exit
proc ::exit {code} {
if {[string is integer $code]} {
- eval ::rivet::exit_thread $code
+ eval ::rivet::exit $code
} else {
- eval ::rivet::exit_thread 0
+ eval ::rivet::exit 0
}
}
@@ -192,15 +194,15 @@ interp alias {} ::incr0 {} incr
::Rivet::init
## And now we get to the import of the whole ::rivet namespace.
-## Some commands (namely lassign) replace the native lassign command
-## so we have to use the -force switch
# Do we actually want to import everything? If Rivet was configured
# to import the ::rivet namespace for compatibility we do it right away.
# This option is not guaranteed to be supported in future versions.
if {[info exists module_conf(import_rivet_commands)] && $module_conf(import_rivet_commands)} {
- namespace eval :: { namespace import -force ::rivet::* }
+
+ namespace eval :: { namespace import ::rivet::* }
+
}
array unset module_conf
Modified: tcl/rivet/trunk/rivet/init.tcl.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/init.tcl.in?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/init.tcl.in (original)
+++ tcl/rivet/trunk/rivet/init.tcl.in Wed Nov 25 14:20:05 2015
@@ -40,25 +40,19 @@ namespace eval ::Rivet {
set dir $tclpath
source [file join $tclpath tclIndex]
- }
-
- set command_list [namespace eval ::rivet_temp {array names auto_index}]
- # commands in 'command_list' are prefixed with ::rivet, so we have to
- # remove it to build an export list
-
- set export_list {}
- foreach c $command_list {
- if {[regexp {::rivet::(.*)} $c m cmd]} {
- lappend export_list $cmd
-# namespace eval ::rivet [list namespace export $cmd]
- }
+ # Rivet Tcl commands not meant to go onto the export list must
+ # be unset from auto_index here
+
+ unset auto_index(::rivet::catch)
}
+ set command_list [namespace eval ::rivet_temp {array names auto_index}]
+
# we won't left anything behind
namespace delete ::rivet_temp
- return $export_list
+ return $command_list
}
###
@@ -125,7 +119,7 @@ namespace eval ::Rivet {
## we keep in ::rivet::export_list a list of importable commands
- namespace eval ::rivet [list set export_list [tcl_commands_export_list $tclpath]]
+ namespace eval ::rivet [list set cmd_export_list [tcl_commands_export_list $tclpath]]
namespace eval ::rivet {
## init.tcl is run by mod_rivet (which creates the ::rivet namespace) but it gets run
@@ -135,9 +129,18 @@ namespace eval ::Rivet {
if {[info exists module_conf(export_namespace_commands)] && \
$module_conf(export_namespace_commands)} {
+ # commands in 'command_list' are prefixed with ::rivet, so we have to
+ # remove it to build an export list
+
+ set export_list {}
+ foreach c $cmd_export_list {
+ lappend export_list [namespace tail $c]
+ }
+
+ #puts stderr "exporting $export_list"
eval namespace export $export_list
- }
+ }
}
## Add the packages directory to the auto_path.
## If we have a packages$tcl_version directory
@@ -166,15 +169,15 @@ namespace eval ::Rivet {
} ;## namespace eval ::Rivet
-## eventually we have to divert Tcl ::exit to ::rivet::exit_thread
+## eventually we have to divert Tcl ::exit to ::rivet::exit
rename ::exit ::Rivet::tclcore_exit
proc ::exit {code} {
if {[string is integer $code]} {
- eval ::rivet::exit_thread $code
+ eval ::rivet::exit $code
} else {
- eval ::rivet::exit_thread 0
+ eval ::rivet::exit 0
}
}
@@ -191,15 +194,15 @@ interp alias {} ::incr0 {} incr
::Rivet::init
## And now we get to the import of the whole ::rivet namespace.
-## Some commands (namely lassign) replace the native lassign command
-## so we have to use the -force switch
# Do we actually want to import everything? If Rivet was configured
# to import the ::rivet namespace for compatibility we do it right away.
# This option is not guaranteed to be supported in future versions.
if {[info exists module_conf(import_rivet_commands)] && $module_conf(import_rivet_commands)} {
- namespace eval :: { namespace import -force ::rivet::* }
+
+ namespace eval :: { namespace import ::rivet::* }
+
}
array unset module_conf
Added: tcl/rivet/trunk/rivet/rivet-tcl/catch.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/rivet-tcl/catch.tcl?rev=1716424&view=auto
==============================================================================
--- tcl/rivet/trunk/rivet/rivet-tcl/catch.tcl (added)
+++ tcl/rivet/trunk/rivet/rivet-tcl/catch.tcl Wed Nov 25 14:20:05 2015
@@ -0,0 +1,44 @@
+# -- catch.tcl
+#
+# Wrapper of the core [::catch] command that checks whether
+# an error condition is actually raised by [::rivet::abort_page]
+# or [::rivet::exit]. In case the error is thrown again to allow
+# the interpreter to interrupt and pass execution to AbortScript
+#
+# $Id$
+#
+
+namespace eval ::rivet {
+
+ proc catch {script args} {
+
+ set catch_cmd [list ::catch $script]
+ if {[llength $args] >= 1} {
+ upvar [lindex $args 0] errvar
+
+ lappend catch_cmd errvar
+ }
+ if {[llength $args] == 2} {
+ upvar [lindex $args 1] catchopt
+
+ lappend catch_cmd catchopt
+ }
+
+ set catch_ret [eval $catch_cmd]
+
+ if {$catch_ret && [::rivet::abort_page -aborting]} {
+
+ return -code error -errorcode ABORTPAGE
+
+ } elseif {$catch_ret && [::rivet::abort_page -exiting]} {
+
+ return -code error -errorcode EXITPAGE
+
+ } else {
+
+ return $catch_ret
+
+ }
+
+ }
+}
Modified: tcl/rivet/trunk/rivet/rivet-tcl/tclIndex
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/rivet-tcl/tclIndex?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/rivet-tcl/tclIndex (original)
+++ tcl/rivet/trunk/rivet/rivet-tcl/tclIndex Wed Nov 25 14:20:05 2015
@@ -28,3 +28,4 @@ set auto_index(::rivet::load_cookies) [l
set auto_index(::rivet::http_accept) [list source [file join $dir http_accept.tcl]]
set auto_index(::rivet::xml) [list source [file join $dir xml.tcl]]
set auto_index(::rivet::redirect) [list source [file join $dir redirect.tcl]]
+set auto_index(::rivet::catch) [list source [file join $dir catch.tcl]]
Modified: tcl/rivet/trunk/src/librivet/rivetCrypt.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/librivet/rivetCrypt.c?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/librivet/rivetCrypt.c (original)
+++ tcl/rivet/trunk/src/librivet/rivetCrypt.c Wed Nov 25 14:20:05 2015
@@ -148,9 +148,9 @@ TCL_CMD_HEADER( Rivet_CryptCmd )
#endif /* ! crypt */
}
-
/*-----------------------------------------------------------------------------
* Rivet_initCrypt --
+ *
* Initialize the encrypt, decrypt and crypt commands in an interpreter.
*
* These routines have been examined and are believed to be safe in a safe
@@ -160,11 +160,26 @@ TCL_CMD_HEADER( Rivet_CryptCmd )
* o interp - Interpreter to add commands to.
*-----------------------------------------------------------------------------
*/
+
+#if RIVET_NAMESPACE_EXPORT == 1
+extern Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp);
+#endif
+
int
Rivet_InitCrypt( Tcl_Interp *interp)
{
RIVET_OBJ_CMD("encrypt", Rivet_EncryptCmd,NULL);
RIVET_OBJ_CMD("decrypt", Rivet_DecryptCmd,NULL);
RIVET_OBJ_CMD("crypt", Rivet_CryptCmd,NULL);
+
+#if RIVET_NAMESPACE_EXPORT == 1
+ {
+ Tcl_Namespace* rivet_ns = Rivet_GetNamespace(interp);
+
+ RIVET_EXPORT_CMD(interp,rivet_ns,"encrypt");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"decrypt");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"crypt");
+ }
+#endif
return TCL_OK;
}
Modified: tcl/rivet/trunk/src/librivet/rivetList.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/librivet/rivetList.c?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/librivet/rivetList.c (original)
+++ tcl/rivet/trunk/src/librivet/rivetList.c Wed Nov 25 14:20:05 2015
@@ -500,31 +500,31 @@ TCL_CMD_HEADER( Rivet_LassignArrayObjCmd
varValue = (listIdx < listObjc) ?
listObjv[listIdx] : Tcl_NewStringObj("", -1);
- if( Tcl_ObjSetVar2( interp, objv[2], objv[idx],
- varValue, TCL_LEAVE_ERR_MSG ) == NULL ) {
- return TCL_ERROR;
+ if (Tcl_ObjSetVar2( interp, objv[2], objv[idx],
+ varValue, TCL_LEAVE_ERR_MSG ) == NULL) {
+ return TCL_ERROR;
}
}
/* We have some left over items. Return them in a list. */
if( listIdx < listObjc ) {
- Tcl_Obj *list = Tcl_NewListObj( 0, NULL );
- int i;
+ Tcl_Obj *list = Tcl_NewListObj( 0, NULL );
+ int i;
- for( i = listIdx; i < listObjc; ++i )
- {
- if (Tcl_ListObjAppendElement(interp, list, listObjv[i]) != TCL_OK) {
- return TCL_ERROR;
+ for( i = listIdx; i < listObjc; ++i )
+ {
+ if (Tcl_ListObjAppendElement(interp, list, listObjv[i]) != TCL_OK) {
+ return TCL_ERROR;
+ }
}
- }
- Tcl_SetObjResult( interp, list );
+ Tcl_SetObjResult( interp, list );
}
return TCL_OK;
}
-
/*-----------------------------------------------------------------------------
* Rivet_initList --
+ *
* Initialize the list commands in an interpreter.
*
* These routines have been examined and are believed to be safe in a safe
@@ -537,6 +537,10 @@ TCL_CMD_HEADER( Rivet_LassignArrayObjCmd
*-----------------------------------------------------------------------------
*/
+#if RIVET_NAMESPACE_EXPORT == 1
+extern Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp);
+#endif
+
int
Rivet_InitList( Tcl_Interp *interp)
{
@@ -545,5 +549,15 @@ Rivet_InitList( Tcl_Interp *interp)
RIVET_OBJ_CMD("comma_join",Rivet_CommaJoinObjCmd,NULL);
RIVET_OBJ_CMD("lassign_array",Rivet_LassignArrayObjCmd,NULL);
+#if RIVET_NAMESPACE_EXPORT == 1
+ {
+ Tcl_Namespace* rivet_ns = Rivet_GetNamespace(interp);
+ RIVET_EXPORT_CMD(interp,rivet_ns,"lremove");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"comma_split");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"comma_join");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"lassign_array");
+ }
+#endif
+
return TCL_OK;
}
Modified: tcl/rivet/trunk/src/librivet/rivetPkgInit.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/librivet/rivetPkgInit.c?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/librivet/rivetPkgInit.c (original)
+++ tcl/rivet/trunk/src/librivet/rivetPkgInit.c Wed Nov 25 14:20:05 2015
@@ -49,7 +49,7 @@
#if RIVET_NAMESPACE_EXPORT == 1
-static Tcl_Namespace*
+Tcl_Namespace*
Rivet_GetNamespace( Tcl_Interp* interp)
{
rivet_interp_globals *globals;
@@ -91,7 +91,7 @@ int
Rivetlib_Init( Tcl_Interp *interp )
{
#if RIVET_NAMESPACE_EXPORT == 1
- Tcl_Namespace *rivet_ns;
+// Tcl_Namespace *rivet_ns;
#endif
#ifdef USE_TCL_STUBS
@@ -106,8 +106,8 @@ Rivetlib_Init( Tcl_Interp *interp )
Rivet_InitCrypt(interp);
Rivet_InitWWW (interp);
#if RIVET_NAMESPACE_EXPORT == 1
- rivet_ns = Rivet_GetNamespace(interp);
- Tcl_Export(interp,rivet_ns,"*",0);
+// rivet_ns = Rivet_GetNamespace(interp);
+// Tcl_Export(interp,rivet_ns,"*",0);
#endif
return Tcl_PkgProvide( interp, RIVETLIB_TCL_PACKAGE, RIVET_VERSION );
@@ -115,6 +115,7 @@ Rivetlib_Init( Tcl_Interp *interp )
/*-----------------------------------------------------------------------------
* Rivetlib_SafeInit --
+ *
* Install the commands provided by librivet that are believed to be
* safe for use in safe interpreters, into a safe interpreter.
*
@@ -129,7 +130,7 @@ int
Rivetlib_SafeInit( Tcl_Interp *interp )
{
#if RIVET_NAMESPACE_EXPORT == 1
- Tcl_Namespace *rivet_ns;
+ //Tcl_Namespace *rivet_ns;
#endif
#ifdef USE_TCL_STUBS
@@ -145,8 +146,8 @@ Rivetlib_SafeInit( Tcl_Interp *interp )
Rivet_InitWWW(interp);
#if RIVET_NAMESPACE_EXPORT == 1
- rivet_ns = Rivet_GetNamespace(interp);
- Tcl_Export(interp,rivet_ns,"*",0);
+ //rivet_ns = Rivet_GetNamespace(interp);
+ //Tcl_Export(interp,rivet_ns,"*",0);
#endif
return Tcl_PkgProvide( interp, RIVETLIB_TCL_PACKAGE, RIVET_VERSION );
}
Modified: tcl/rivet/trunk/src/librivet/rivetWWW.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/librivet/rivetWWW.c?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/librivet/rivetWWW.c (original)
+++ tcl/rivet/trunk/src/librivet/rivetWWW.c Wed Nov 25 14:20:05 2015
@@ -351,6 +351,10 @@ TCL_CMD_HEADER( Rivet_EscapeShellCommand
*-----------------------------------------------------------------------------
*/
+#if RIVET_NAMESPACE_EXPORT == 1
+extern Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp);
+#endif
+
int
Rivet_InitWWW( Tcl_Interp *interp)
{
@@ -358,5 +362,16 @@ Rivet_InitWWW( Tcl_Interp *interp)
RIVET_OBJ_CMD ("escape_string",Rivet_EscapeStringCmd,NULL);
RIVET_OBJ_CMD ("escape_sgml_chars",Rivet_EscapeSgmlCharsCmd,NULL);
RIVET_OBJ_CMD ("escape_shell_command",Rivet_EscapeShellCommandCmd,NULL);
+
+#if RIVET_NAMESPACE_EXPORT == 1
+ {
+ Tcl_Namespace* rivet_ns = Rivet_GetNamespace(interp);
+
+ RIVET_EXPORT_CMD(interp,rivet_ns,"unescape_string");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"escape_string");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"escape_sgml_chars");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"escape_shell_command");
+ }
+#endif
return TCL_OK;
}
Modified: tcl/rivet/trunk/src/mod_rivet/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet/rivetCore.c?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet/rivetCore.c (original)
+++ tcl/rivet/trunk/src/mod_rivet/rivetCore.c Wed Nov 25 14:20:05 2015
@@ -1208,6 +1208,12 @@ TCL_CMD_HEADER( Rivet_AbortPageCmd )
Tcl_SetObjResult (interp,Tcl_NewBooleanObj(private->page_aborting));
return TCL_OK;
}
+
+ if (strcmp(cmd_arg,"-exiting") == 0)
+ {
+ Tcl_SetObjResult (interp,Tcl_NewBooleanObj(private->thread_exit));
+ return TCL_OK;
+ }
/*
* we assume abort_code to be null, as abort_page shouldn't run twice while
@@ -1324,15 +1330,13 @@ TCL_CMD_HEADER( Rivet_EnvCmd )
*
* Result:
*
- * TCL_ERROR when running a threaded MPM, it should never return
- * if a non threaded MPM is run, because Tcl_Exit will be called
- * by the MPM specific function of the corresponding bridge
+ * TCL_ERROR
*
* Side Effects:
*
* - non threaded MPMs: the child process exits for good
- * - threaded MPMs: the logical variable controlling a bridge thread
- * is set to zero and the request processing is interrupted
+ * - threaded MPMs: the child process exits after all Tcl threads
+ * are told to exit
*
*-----------------------------------------------------------------------------
*/
@@ -1386,7 +1390,6 @@ TCL_CMD_HEADER( Rivet_ExitCmd )
Tcl_AddErrorInfo (interp, errorMessage);
Tcl_SetErrorCode (interp, "RIVET", THREAD_EXIT_CODE, errorMessage, (char *)NULL);
- //return (*RIVET_MPM_BRIDGE_FUNCTION(mpm_exit_handler))(value);
return TCL_ERROR;
}
/*
@@ -1738,11 +1741,6 @@ Rivet_InitCore(Tcl_Interp *interp,rivet_
{
#if RIVET_NAMESPACE_EXPORT == 1
- rivet_interp_globals *globals = NULL;
- Tcl_Namespace *rivet_ns;
-
- globals = Tcl_GetAssocData(interp, "rivet", NULL);
- rivet_ns = globals->rivet_ns;
#endif
RIVET_OBJ_CMD ("makeurl",Rivet_MakeURL,private);
@@ -1764,14 +1762,42 @@ Rivet_InitCore(Tcl_Interp *interp,rivet_
RIVET_OBJ_CMD ("env",Rivet_EnvCmd,private);
RIVET_OBJ_CMD ("apache_log_error",Rivet_LogErrorCmd,private);
RIVET_OBJ_CMD ("inspect",Rivet_InspectCmd,private);
- RIVET_OBJ_CMD ("exit_thread",Rivet_ExitCmd,private);
+ RIVET_OBJ_CMD ("exit",Rivet_ExitCmd,private);
#ifdef TESTPANIC
RIVET_OBJ_CMD ("testpanic",TestpanicCmd,private);
#endif
#if RIVET_NAMESPACE_EXPORT == 1
- Tcl_Export(interp,rivet_ns,"*",0);
+ {
+ rivet_interp_globals *globals = NULL;
+ Tcl_Namespace *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");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"load_env");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"load_headers");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"var");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"abort_page");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"abort_code");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"virtual_filename");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"apache_table");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"var_qs");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"var_post");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"raw_post");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"upload");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"include");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"parse");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"no_body");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"env");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"apache_log_error");
+ RIVET_EXPORT_CMD(interp,rivet_ns,"inspect");
+ // ::rivet::exit is not exported
+ //Tcl_Export(interp,rivet_ns,"*",0);
+ }
#endif
return TCL_OK;
Modified: tcl/rivet/trunk/src/rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/rivet.h?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/src/rivet.h (original)
+++ tcl/rivet/trunk/src/rivet.h Wed Nov 25 14:20:05 2015
@@ -88,6 +88,9 @@ Tcl_CreateObjCommand( interp,
private_p, /* Client Data */\
(Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */);
+
+#define RIVET_EXPORT_CMD(interp,ns,cmdname) Tcl_Export(interp,ns,cmdname,0);
+
/*
* Pointer in r is checked and in case Rivet_NoRequestRec is
* called returning TCL_ERROR. This macro is used (and often
Copied: tcl/rivet/trunk/tests/bailout.test (from r1715023, tcl/rivet/trunk/tests/redirect.test)
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/bailout.test?p2=tcl/rivet/trunk/tests/bailout.test&p1=tcl/rivet/trunk/tests/redirect.test&r1=1715023&r2=1716424&rev=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/redirect.test (original)
+++ tcl/rivet/trunk/tests/bailout.test Wed Nov 25 14:20:05 2015
@@ -5,7 +5,7 @@
# $Id: $
-::tcltest::test redirect-1.1 {redirect command} {
+::tcltest::test bailout-1.1 {redirect command} {
apachetest::start {} {
RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching redirect\\\""
RivetServerConf AbortScript "set tmpfp \[open redirect_code.txt w+\]"
@@ -24,3 +24,22 @@
}
list $r1 $r2
} {1 1}
+
+::tcltest::test bailout-1.2 {exit command} {
+ apachetest::start {} {
+ RivetServerConf AbortScript "::rivet::apache_log_error err \\\"catching exit\\\""
+ RivetServerConf AbortScript "set abcode \[::rivet::abort_code\]"
+ RivetServerConf AbortScript "puts -nonewline \[::rivet::abort_page -exiting\]"
+ RivetServerConf AbortScript "puts -nonewline \\\" \[dict get \$abcode error_code\] \[dict get \$abcode return_code\]\\\""
+ } {
+ puts "test exit command"
+ set url "${urlbase}exit.tcl"
+ set page [::http::geturl $url]
+ set r [::http::data $page]
+ ::http::cleanup $page
+ }
+ set r
+} {1 exit 100}
+
+
+
Added: tcl/rivet/trunk/tests/exit.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/exit.tcl?rev=1716424&view=auto
==============================================================================
--- tcl/rivet/trunk/tests/exit.tcl (added)
+++ tcl/rivet/trunk/tests/exit.tcl Wed Nov 25 14:20:05 2015
@@ -0,0 +1,8 @@
+# -- exit.tcl
+#
+# testing effects of calling the core exit command which
+# actually should have been trapped by ::rivet::exit
+#
+# $Id: $
+
+::exit 100
Modified: tcl/rivet/trunk/tests/rivet.test
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/rivet.test?rev=1716424&r1=1716423&r2=1716424&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/rivet.test (original)
+++ tcl/rivet/trunk/tests/rivet.test Wed Nov 25 14:20:05 2015
@@ -66,7 +66,7 @@ set group3 {
parsepackage.test
virtualhost.test
inspect.test
- redirect.test
+ bailout.test
channel.test
}
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org