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/04/16 22:11:42 UTC

svn commit: r1588055 - in /tcl/rivet/branches/modular: ./ doc/ doc/xml/ src/ src/apache-2/ src/request/ src/rivetcmds/ tests/

Author: mxmanghi
Date: Wed Apr 16 20:11:41 2014
New Revision: 1588055

URL: http://svn.apache.org/r1588055
Log:
    * branches/modular: merging latest changes in trunk
    * trunk/src/rivetcmds/rivetInpect.c: adding is_virtual flag to values returned by '::rivet::inspect server'


Added:
    tcl/rivet/branches/modular/tests/checkfails.tcl
      - copied unchanged from r1588050, tcl/rivet/trunk/tests/checkfails.tcl
    tcl/rivet/branches/modular/tests/failtest.tcl
      - copied unchanged from r1588050, tcl/rivet/trunk/tests/failtest.tcl
    tcl/rivet/branches/modular/tests/failtest.test
      - copied unchanged from r1588050, tcl/rivet/trunk/tests/failtest.test
Removed:
    tcl/rivet/branches/modular/doc/rivet.it.xml
    tcl/rivet/branches/modular/doc/rivet.ru.xml
Modified:
    tcl/rivet/branches/modular/   (props changed)
    tcl/rivet/branches/modular/ChangeLog
    tcl/rivet/branches/modular/Makefile.in
    tcl/rivet/branches/modular/VERSION
    tcl/rivet/branches/modular/configure.ac
    tcl/rivet/branches/modular/doc/   (props changed)
    tcl/rivet/branches/modular/doc/xml/commands.xml
    tcl/rivet/branches/modular/doc/xml/intro.xml
    tcl/rivet/branches/modular/src/TclWeb.h
    tcl/rivet/branches/modular/src/apache-2/TclWebapache.c
    tcl/rivet/branches/modular/src/apache-2/mod_rivet.c
    tcl/rivet/branches/modular/src/apache-2/mod_rivet.h
    tcl/rivet/branches/modular/src/request/apache_request.c
    tcl/rivet/branches/modular/src/request/apache_request.h
    tcl/rivet/branches/modular/src/rivetcmds/rivetCore.c
    tcl/rivet/branches/modular/src/rivetcmds/rivetInspect.c
    tcl/rivet/branches/modular/tests/inspect.test
    tcl/rivet/branches/modular/tests/rivet.test

Propchange: tcl/rivet/branches/modular/
------------------------------------------------------------------------------
  Merged /tcl/rivet/trunk:r1578286-1588050

Modified: tcl/rivet/branches/modular/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/ChangeLog?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/ChangeLog (original)
+++ tcl/rivet/branches/modular/ChangeLog Wed Apr 16 20:11:41 2014
@@ -1,3 +1,45 @@
+2014-04-16 Massimo Manghi <mx...@apache.org>
+    * branches/modular: merging latest changes in trunk
+    * trunk/src/rivetcmds/rivetInpect.c: adding is_virtual flag to values returned by '::rivet::inspect server'
+
+2014-04-11 Massimo Manghi <mx...@apache.org>
+    * src/rivetcmds/rivetCore.c: misplaced check on request_rec in Rivet_InspectCmd
+    * tests/failtest.tcl,failtest.test,checkfail.tcl: adding tests for ::rivet::inspect
+
+2014-04-07 Massimo Manghi <mx...@apache.org>
+    * tests/failtest.[test|tcl],failcheck.tcl: implementing test for consistent error
+    handling by commands that are supposed to refuse execution outside of a request processing
+    * tests/inspect.tcl: implementing test of command '::rivet::inspect script'
+    * src/rivetcmds/rivetCore.c: typo in command ::rivet::apache_table
+
+2014-04-04 Massimo Manghi <mx...@apache.org>
+    * tests/failtest.tcl,failtest.test,checkfail.tcl: adding script for commands that must fail
+    outside of a request processing (to be completed)
+    * src/rivetcmds/rivetCore.c: comment rephrased
+
+2014-03-30 Massimo Manghi <mx...@apache.org>
+    * src/rivetcmds/rivetInspect.c: Add function Rivet_CurrentServerRec returning a dictionary of
+    some field values stored in the server_rec object
+    * src/rivetcmds/rivetCore.c: Add support for 'server' argument returning the dictionary built
+    by Rivet_CurrentServerRec
+    * src/TclWeb.h: adding declaration of function constructor of a TclWebRequest object
+    * src/apache-2/TclWebapache.c: Add functions TclWeb_NewRequestObject and TclWeb_InitRequest to
+    reinitialize a TclWebRequest object on each request
+    * src/apache-2/apache_request.[c|h]: API change for ApacheRequest_new taking now an apr_pool_t
+    object instance for creating an ApacheRequest oject pointer. Task to reset this object
+    to initial values is now delegated to ApacheRequest_init.
+    * src/apache-2/mod_rivet.[c|h]: new field in globals stores the current server_rec object pointer.
+    This pointer is used in RivetInspect.c to access to field of the object for introspection
+    
+2014-03-26 Massimo Manghi <mx...@apache.org>
+    * doc/xml/commands.xml: wrong example for lassign_array corrected
+    * src/apache-2/mod_rivet.c: Adding comment explaining the meaning of setting/resetting globals->r as
+    a way to detect if a script is running in the context of a request processing
+    * src/rivetcmds/rivetCore.c,rivetInspect.c: Tcl object handling improved. Code simplified and
+    ap_assert call added in Rivet_CurrentConfDict if there is no handling of a configuration parameter
+    by Rivet_ReadConfParameter (which should never happen)
+    * configure.ac, VERSION: version number bumped to 2.1.5
+
 2014-03-16 Massimo Manghi <mx...@apache.org>
     * doc/images/Rivetlogo_small.png: removed because already in doc/ and dupicate to home.png
 

Modified: tcl/rivet/branches/modular/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/Makefile.in?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/Makefile.in (original)
+++ tcl/rivet/branches/modular/Makefile.in Wed Apr 16 20:11:41 2014
@@ -94,6 +94,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(sr
 	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 \
@@ -450,8 +451,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@if test ! -f $@; then rm -f stamp-h1; else :; fi
-	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+	@test -f $@ || rm -f stamp-h1
+	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -660,10 +661,16 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
 

Modified: tcl/rivet/branches/modular/VERSION
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/VERSION?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/VERSION (original)
+++ tcl/rivet/branches/modular/VERSION Wed Apr 16 20:11:41 2014
@@ -1 +1 @@
-2.1.2
+2.1.5

Modified: tcl/rivet/branches/modular/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/configure.ac?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/configure.ac (original)
+++ tcl/rivet/branches/modular/configure.ac Wed Apr 16 20:11:41 2014
@@ -22,7 +22,7 @@ dnl
 # so you can encode the package version directly into the source files.
 #-----------------------------------------------------------------------
 
-AC_INIT([Rivet],[2.1.4])
+AC_INIT([Rivet],[2.1.5])
 TEA_INIT([3.9])
 
 AC_CONFIG_AUX_DIR(tclconfig)

Propchange: tcl/rivet/branches/modular/doc/
------------------------------------------------------------------------------
  Merged /tcl/rivet/trunk/doc:r1578286-1588050

Modified: tcl/rivet/branches/modular/doc/xml/commands.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/doc/xml/commands.xml?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/doc/xml/commands.xml (original)
+++ tcl/rivet/branches/modular/doc/xml/commands.xml Wed Apr 16 20:11:41 2014
@@ -862,7 +862,7 @@ keyvalue_map(args) = 1 2 3 4 5</programl
 
 	    <refsynopsisdiv>
 		<cmdsynopsis>
-		    <command>inspect</command>
+		    <command>::rivet::inspect</command>
 		    <arg><replaceable>configuration_section</replaceable></arg>
 		    <arg><replaceable>configuration_parameter</replaceable></arg>
 		</cmdsynopsis>
@@ -983,11 +983,11 @@ keyvalue_map(args) = 1 2 3 4 5</programl
 	       </para>
 	       <programlisting>::rivet::lassign_array {1 2 3 4} assigned_array a b c d
 parray assigned_array
-<emphasis role="strong">assigned_list</emphasis>
-assigned_list(a) = 1
-assigned_list(b) = 2
-assigned_list(c) = 3
-assigned_list(d) = 4
+<emphasis role="strong">assigned_array</emphasis>
+assigned_array(a) = 1
+assigned_array(b) = 2
+assigned_array(c) = 3
+assigned_array(d) = 4
 
 set rem [::rivet::lassign_array {1 2 3 4 5 6 7} assigned_array a b c d]
 puts $rem

Modified: tcl/rivet/branches/modular/doc/xml/intro.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/doc/xml/intro.xml?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/doc/xml/intro.xml (original)
+++ tcl/rivet/branches/modular/doc/xml/intro.xml Wed Apr 16 20:11:41 2014
@@ -30,7 +30,7 @@
     <simplesect>
         <title>Acknowledgements</title>
         <para>
-            Rivet 2.1.0 comes with relevant contributions provided by 
+            Rivet 2.1 comes with relevant contributions provided by 
             <emphasis>Harald Oehlmann</emphasis> (page RivetEntitites, 
             new command ::rivet::http_accept and bugfixes), 
             <emphasis>Cyril Shtumf</emphasis> (important bugfixes) and

Modified: tcl/rivet/branches/modular/src/TclWeb.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/TclWeb.h?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/TclWeb.h (original)
+++ tcl/rivet/branches/modular/src/TclWeb.h Wed Apr 16 20:11:41 2014
@@ -24,17 +24,21 @@
 #define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
 
 typedef struct TclWebRequest {
-    Tcl_Interp *interp;
-    request_rec *req;
-    ApacheRequest *apachereq;
-    ApacheUpload *upload;
-    int headers_printed;	/* has the header been printed yet? */
-    int headers_set;		/* has the header been set yet? */
-    int content_sent;
-    int environment_set;	/* have we setup the environment variables? */
-    char* charset;
+    Tcl_Interp*     interp;
+    request_rec*    req;
+    ApacheRequest*  apachereq;
+    ApacheUpload*   upload;
+    int             headers_printed;	/* has the header been printed yet? */
+    int             headers_set;		/* has the header been set yet? */
+    int             content_sent;
+    int             environment_set;	/* have we setup the environment variables? */
+    char*           charset;
 } TclWebRequest;
 
+/* Creates a TclWebRequest object */
+
+TclWebRequest* TclWeb_NewRequestObject (apr_pool_t *p);
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -46,7 +50,6 @@ typedef struct TclWebRequest {
 
 int TclWeb_InitRequest(TclWebRequest *req, Tcl_Interp *interp, void *arg);
 
-
 /*
  *-----------------------------------------------------------------------------
  *

Modified: tcl/rivet/branches/modular/src/apache-2/TclWebapache.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/apache-2/TclWebapache.c?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/apache-2/TclWebapache.c (original)
+++ tcl/rivet/branches/modular/src/apache-2/TclWebapache.c Wed Apr 16 20:11:41 2014
@@ -52,20 +52,56 @@ extern module rivet_module;
 if (source == VAR_SRC_QUERYSTRING) { j = req->apachereq->nargs; } \
 else if (source == VAR_SRC_POST) { i = req->apachereq->nargs; }
 
+/* 
+ * -- TclWeb_NewRequestObject
+ *
+ *
+ */
+
+TclWebRequest*
+TclWeb_NewRequestObject (apr_pool_t *p)
+{
+    TclWebRequest*  req = (TclWebRequest *)apr_pcalloc(p, sizeof(TclWebRequest));
+
+    req->interp     = NULL;
+    req->req        = NULL;
+    req->apachereq  = ApacheRequest_new(p);
+    req->headers_printed    = 0;
+    req->headers_set        = 0;
+    req->environment_set    = 0;
+    req->charset    = NULL;  /* we will test against NULL to check if a charset */
+                             /* was specified in the conf */
+    return req;
+}
+
+
+/*
+ * -- TclWeb_InitRequest
+ *
+ * called once on every HTTP request initializes fields and
+ * objects referenced in a TclWebRequest object
+ *
+ * Arguments:
+ *
+ *  *req:    a pointer to a TclWebRequest object to be intialized
+ *  *interp: current Tcl_Interp object serving the request
+ *  *arg:    generic pointer. Current implementation passes the
+ *           request_rec object pointer 
+ *
+ */
+
 int
 TclWeb_InitRequest(TclWebRequest *req, Tcl_Interp *interp, void *arg)
 {
     request_rec *r = (request_rec *)arg;
 
-    req->interp = interp;
-    req->req = r;
-    req->apachereq = ApacheRequest_new(r);
-    req->headers_printed = 0;
-    req->headers_set = 0;
-    req->environment_set = 0;
+    req->interp             = interp;
+    req->req                = r;
+    req->apachereq          = ApacheRequest_init(req->apachereq,r);
+    req->headers_printed    = 0;
+    req->headers_set        = 0;
+    req->environment_set    = 0;
 
-    /* we will test against NULL to check if a charset 
-       was specified in the conf */
 
     req->charset = NULL;
     return TCL_OK;

Modified: tcl/rivet/branches/modular/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/apache-2/mod_rivet.c?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/modular/src/apache-2/mod_rivet.c Wed Apr 16 20:11:41 2014
@@ -90,6 +90,7 @@ TCL_DECLARE_MUTEX(sendMutex);
 
 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);
 
 /*
  * -- Rivet_chdir_file (const char* filename)
@@ -713,7 +714,8 @@ Rivet_PerInterpInit(server_rec *s, rivet
                                             (Tcl_NamespaceDeleteProc *)NULL);
     globals->page_aborting  = 0;
     globals->abort_code     = NULL;
-    globals->req            = (TclWebRequest *)apr_pcalloc(p, sizeof(TclWebRequest));;
+    globals->req            = TclWeb_NewRequestObject (p); 
+    globals->srec           = s;
     globals->r              = NULL;
 
     /* Eval Rivet's init.tcl file to load in the Tcl-level commands. */
@@ -875,122 +877,6 @@ Rivet_Panic TCL_VARARGS_DEF(CONST char *
     abort();
 }
 
-
-/*
- *-----------------------------------------------------------------------------
- *
- * Rivet_ChildHandlers --
- *
- *  Handles, depending on the situation, the scripts for the init
- *  and exit handlers.
- *
- * Results:
- *  None.
- *
- * Side Effects:
- *  Runs the rivet_child_init/exit_script scripts.
- *
- *-----------------------------------------------------------------------------
- */
-static void
-Rivet_ChildHandlers(server_rec *s, int init)
-{
-    server_rec *sr;
-    rivet_server_conf *rsc;
-    rivet_server_conf *top;
-    void *function;
-    void *parentfunction;
-    char *errmsg;
-
-    top = RIVET_SERVER_CONF(s->module_config);
-    if (init == 1) {
-        parentfunction = top->rivet_child_init_script;
-        errmsg = MODNAME ": Error in Child init script: %s";
-        //errmsg = (char *) apr_pstrdup(p, "Error in child init script: %s");
-    } else {
-        parentfunction = top->rivet_child_exit_script;
-        errmsg = MODNAME ": Error in Child exit script: %s";
-        //errmsg = (char *) apr_pstrdup(p, "Error in child exit script: %s");
-    }
-
-    for (sr = s; sr; sr = sr->next)
-    {
-        rsc = RIVET_SERVER_CONF(sr->module_config);
-        function = init ? rsc->rivet_child_init_script : rsc->rivet_child_exit_script;
-
-        if (!init && sr == s) {
-            Tcl_Preserve(rsc->server_interp);
-        }
-
-        /* Execute it if it exists and it's the top level, separate
-         * virtual interps are turned on, or it's different than the
-         * main script. 
-         */
-
-        if  (function &&
-             ( sr == s || rsc->separate_virtual_interps || function != parentfunction))
-        {
-            Tcl_Preserve (rsc->server_interp);
-            if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
-                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
-                             errmsg, Tcl_GetString(function));
-                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 
-                             "errorCode: %s",
-                        Tcl_GetVar(rsc->server_interp, "errorCode", 0));
-                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 
-                             "errorInfo: %s",
-                        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 deletes its slave interpreters.
-     */
-
-        rsc = RIVET_SERVER_CONF(s->module_config);
-        if (!Tcl_InterpDeleted (rsc->server_interp)) {
-            Tcl_DeleteInterp(rsc->server_interp);
-        }
-        Tcl_Release (rsc->server_interp);
-    }
-}
-/*
- *-----------------------------------------------------------------------------
- *
- * Rivet_ChildExit --
- *
- *  Run when each Apache child process is about to exit.
- *
- * Results:
- *  None.
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------------
- */
-
-static apr_status_t
-Rivet_ChildExit(void *data)
-{
-    server_rec *s = (server_rec*) data;
-
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, s, MODNAME ": Running ChildExit handler");
-    Rivet_ChildHandlers(s, 0);
-
-    /* Tcl_Finalize removed to meet requirement of coexistence with mod_websh (Bug #54162) */
-
-    //Tcl_Finalize();
-
-    return OK;
-}
-
 /*
  *-----------------------------------------------------------------------------
  * Rivet_CreateTclInterp --
@@ -1159,7 +1045,8 @@ Rivet_InitTclStuff(server_rec *s, apr_po
                         interpCount++);
 
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, 
-                            MODNAME ": Rivet_InitTclStuff: creating slave interpreter '%s', hostname '%s', port '%d', separate interpreters %d",
+                            MODNAME 
+": Rivet_InitTclStuff: creating slave interpreter '%s', hostname '%s', port '%d', separate interpreters %d",
                             slavename, sr->server_hostname, sr->port, 
                             rsc->separate_virtual_interps);
 
@@ -1190,6 +1077,95 @@ Rivet_InitTclStuff(server_rec *s, apr_po
 /*
  *-----------------------------------------------------------------------------
  *
+ * Rivet_ChildHandlers --
+ *
+ *  Handles, depending on the situation, the scripts for the init
+ *  and exit handlers.
+ *
+ * Results:
+ *  None.
+ *
+ * Side Effects:
+ *  Runs the rivet_child_init/exit_script scripts.
+ *
+ *-----------------------------------------------------------------------------
+ */
+static void
+Rivet_ChildHandlers(server_rec *s, int init)
+{
+    server_rec *sr;
+    rivet_server_conf *rsc;
+    rivet_server_conf *top;
+    void *function;
+    void *parentfunction;
+    char *errmsg;
+
+    top = RIVET_SERVER_CONF(s->module_config);
+    if (init == 1) {
+        parentfunction = top->rivet_child_init_script;
+        errmsg = MODNAME ": Error in Child init script: %s";
+        //errmsg = (char *) apr_pstrdup(p, "Error in child init script: %s");
+    } else {
+        parentfunction = top->rivet_child_exit_script;
+        errmsg = MODNAME ": Error in Child exit script: %s";
+        //errmsg = (char *) apr_pstrdup(p, "Error in child exit script: %s");
+    }
+
+    for (sr = s; sr; sr = sr->next)
+    {
+        rsc = RIVET_SERVER_CONF(sr->module_config);
+        function = init ? rsc->rivet_child_init_script : rsc->rivet_child_exit_script;
+
+        if (!init && sr == s) {
+            Tcl_Preserve(rsc->server_interp);
+        }
+
+        /* Execute it if it exists and it's the top level, separate
+         * virtual interps are turned on, or it's different than the
+         * main script. 
+         */
+
+        if  (function &&
+             ( sr == s || rsc->separate_virtual_interps || function != parentfunction))
+        {
+            rivet_interp_globals* globals = Tcl_GetAssocData( rsc->server_interp, "rivet", NULL );
+            Tcl_Preserve (rsc->server_interp);
+
+            globals->srec = sr;
+            if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+                             errmsg, Tcl_GetString(function));
+                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 
+                             "errorCode: %s",
+                        Tcl_GetVar(rsc->server_interp, "errorCode", 0));
+                ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 
+                             "errorInfo: %s",
+                        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 deletes its slave interpreters.
+     */
+
+        rsc = RIVET_SERVER_CONF(s->module_config);
+        if (!Tcl_InterpDeleted (rsc->server_interp)) {
+            Tcl_DeleteInterp(rsc->server_interp);
+        }
+        Tcl_Release (rsc->server_interp);
+    }
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
  * Rivet_ChildInit --
  *
  *  This function is run when each individual Apache child process
@@ -1217,6 +1193,32 @@ Rivet_ChildInit(apr_pool_t *pChild, serv
     apr_pool_cleanup_register (pChild, s, Rivet_ChildExit, Rivet_ChildExit);
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Rivet_ChildExit --
+ *
+ *  Run when each Apache child process is about to exit.
+ *
+ * Results:
+ *  None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static apr_status_t
+Rivet_ChildExit(void *data)
+{
+    server_rec *s = (server_rec*) data;
+    ap_assert (s != (server_rec *)NULL);
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, s, MODNAME ": Running ChildExit handler");
+    Rivet_ChildHandlers(s, 0);
+
+    return OK;
+}
 
 //TODO: clarify whether rsc or rdc
 
@@ -1254,7 +1256,16 @@ Rivet_SendContent(request_rec *r)
     rsc = Rivet_GetConf(r);
     interp = rsc->server_interp;
     globals = Tcl_GetAssocData(interp, "rivet", NULL);
+
+    /* Setting this pointer in globals is crucial as by assigning it
+     * we signal to Rivet commands we are processing an HTTP request.
+     * This pointer gets set to NULL just before we leave this function
+     * making possible to invalidate command execution that could depend
+     * on a valid request_rec
+     */
+
     globals->r = r;
+    globals->srec = r->server;
 
 #ifndef USE_APACHE_RSC
     if (r->per_dir_config != NULL)
@@ -1344,7 +1355,6 @@ Rivet_SendContent(request_rec *r)
 
     /* Apache Request stuff */
 
-    //globals->req = (TclWebRequest *)apr_pcalloc(r->pool, sizeof(TclWebRequest));
     TclWeb_InitRequest(globals->req, interp, r);
     ApacheRequest_set_post_max(globals->req->apachereq, rsc->upload_max);
     ApacheRequest_set_temp_dir(globals->req->apachereq, rsc->upload_dir);

Modified: tcl/rivet/branches/modular/src/apache-2/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/apache-2/mod_rivet.h?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/apache-2/mod_rivet.h (original)
+++ tcl/rivet/branches/modular/src/apache-2/mod_rivet.h Wed Apr 16 20:11:41 2014
@@ -110,9 +110,10 @@ typedef struct _rivet_interp_globals {
     Tcl_Namespace   *rivet_ns;          /* Rivet commands namespace */
     int             page_aborting;	    /* set by abort_page.       */
     Tcl_Obj*        abort_code;			/* To be reset by Rivet_SendContent */
+    server_rec*     srec;               /* pointer to the current server rec obj */
 } rivet_interp_globals;
 
-int Rivet_ParseExecFile(TclWebRequest *req, char *filename, int toplevel);
+int Rivet_ParseExecFile   (TclWebRequest *req, char *filename, int toplevel);
 int Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf);
 
 rivet_server_conf *Rivet_GetConf(request_rec *r);
@@ -140,6 +141,8 @@ Tcl_Obj* Rivet_ReadConfParameter (  Tcl_
 Tcl_Obj* Rivet_CurrentConfDict (    Tcl_Interp*           interp,
                                     rivet_server_conf*    rivet_conf);
 
+Tcl_Obj* Rivet_CurrentServerRec (   Tcl_Interp*         interp, server_rec* s );
+
 /* error code set by command 'abort_page' */
 
 #define ABORTPAGE_CODE "ABORTPAGE"

Modified: tcl/rivet/branches/modular/src/request/apache_request.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/request/apache_request.c?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/request/apache_request.c (original)
+++ tcl/rivet/branches/modular/src/request/apache_request.c Wed Apr 16 20:11:41 2014
@@ -184,34 +184,55 @@ ApacheUpload *ApacheUpload_find(ApacheUp
     ApacheUpload *uptr;
 
     for (uptr = upload; uptr; uptr = uptr->next) {
-	if (strEQ(uptr->name, name)) {
-	    return uptr;
-	}
+        if (strEQ(uptr->name, name)) {
+            return uptr;
+        }
     }
 
     return NULL;
 }
 
-ApacheRequest *ApacheRequest_new(request_rec *r)
+ApacheRequest *ApacheRequest_new(apr_pool_t *pool)
 {
     ApacheRequest *req = (ApacheRequest *)
-	apr_pcalloc(r->pool, sizeof(ApacheRequest));
+	apr_pcalloc(pool, sizeof(ApacheRequest));
 
-    req->status = OK;
-    req->parms = apr_table_make(r->pool, DEFAULT_TABLE_NELTS);
-    req->upload = NULL;
-    req->post_max = -1;
+    req->status         = OK;
+    req->parms          = apr_table_make(pool, DEFAULT_TABLE_NELTS);
+    req->upload         = NULL;
+    req->post_max       = -1;
     req->disable_uploads = 0;
-    req->upload_hook = NULL;
-    req->hook_data = NULL;
-    req->temp_dir = NULL;
-    req->raw_post = NULL;
-    req->parsed = 0;
-    req->r = r;
-    req->nargs = 0;
+    req->upload_hook    = NULL;
+    req->hook_data      = NULL;
+    req->temp_dir       = NULL;
+    req->raw_post       = NULL;
+    req->parsed         = 0;
+    req->r              = NULL;
+    req->nargs          = 0;
 
     return req;
 }
+
+ApacheRequest *ApacheRequest_init(ApacheRequest* req, request_rec *r)
+{
+
+    req->status         = OK;
+    apr_table_clear(req->parms);
+    req->upload         = NULL;
+    req->post_max       = -1;
+    req->disable_uploads = 0;
+    req->upload_hook    = NULL;
+    req->hook_data      = NULL;
+    req->temp_dir       = NULL;
+    req->raw_post       = NULL;
+    req->parsed         = 0;
+    req->r              = r;
+    req->nargs          = 0;
+
+    return req;
+}
+
+
 static char x2c(const char *what)
 {
     register char digit;

Modified: tcl/rivet/branches/modular/src/request/apache_request.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/request/apache_request.h?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/request/apache_request.h (original)
+++ tcl/rivet/branches/modular/src/request/apache_request.h Wed Apr 16 20:11:41 2014
@@ -92,7 +92,8 @@ struct ApacheUpload {
  extern "C" {
 #endif 
 
-ApacheRequest *ApacheRequest_new(request_rec *r);
+ApacheRequest*  ApacheRequest_new(apr_pool_t *);
+ApacheRequest*  ApacheRequest_init(ApacheRequest* req, request_rec *r);
 /* int ApacheRequest_save_post_data(request_rec *r, int flag);
 char *ApacheRequest_fetch_post_data(request_rec *r);  */
 int ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct);

Modified: tcl/rivet/branches/modular/src/rivetcmds/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/rivetcmds/rivetCore.c?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/rivetcmds/rivetCore.c (original)
+++ tcl/rivet/branches/modular/src/rivetcmds/rivetCore.c Wed Apr 16 20:11:41 2014
@@ -56,6 +56,43 @@ extern char* TclWeb_GetRawPost (TclWebRe
 
 #define POOL (globals->r->pool)
 
+#define CHECK_REQUEST_REC(r,cmd_name) \
+if (r == NULL)\
+{\
+    Rivet_NoRequestRec(interp,Tcl_NewStringObj(cmd_name,-1));\
+    return TCL_ERROR;\
+}
+   
+
+/*
+ * -- Rivet_NoRequestRec
+ *
+ * Adds standard error information to the interpreter. This procedure makes 
+ * sense only when called by C functions implementing Tcl commands that
+ * are meaningful only if a valid requiest_rec object is defined. These
+ * procedures must return TCL_ERROR right away after Rivet_NoRequestRecord
+ * returns
+ *
+ * Arguments:
+ *
+ *  Tcl_Interp*: current Tcl interpreter
+ *  Tcl_Obj*: Tcl string object with the command name
+ *
+ * Results:
+ *
+ *  None
+ *
+ */
+
+static void
+Rivet_NoRequestRec (Tcl_Interp* interp, Tcl_Obj* command)
+{
+    Tcl_AddErrorInfo(interp, "Cannot call ");
+    Tcl_AppendObjToErrorInfo(interp,command);
+    Tcl_AppendObjToErrorInfo(interp,Tcl_NewStringObj(" outside a request processing",-1));
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -79,6 +116,8 @@ TCL_CMD_HEADER( Rivet_MakeURL )
     char*                   url_target_name;
     int                     target_length;
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::makeurl");
+
     if (objc > 2)
     {
         Tcl_WrongNumArgs(interp, 1, objv, "filename");
@@ -156,9 +195,10 @@ TCL_CMD_HEADER( Rivet_Parse )
     char            *filename;
     apr_status_t    stat_s;
     apr_finfo_t     finfo_b;
-
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::parse");
+
     if( objc < 2 || objc > 3 )
     {
         Tcl_WrongNumArgs(interp, 1, objv, "?-virtual? filename");
@@ -223,7 +263,6 @@ TCL_CMD_HEADER( Rivet_Include )
     char *filename;
     Tcl_DString transoptions;
     Tcl_DString encoptions;
-
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
     if( objc < 2 || objc > 3 )
@@ -239,6 +278,8 @@ TCL_CMD_HEADER( Rivet_Include )
             Tcl_WrongNumArgs( interp, 1, objv, "?-virtual? filename" );
             return TCL_ERROR;
         }
+
+        CHECK_REQUEST_REC(globals->r,"::rivet::include -virtual");
         filename = TclWeb_GetVirtualFile( globals->req,
                                           Tcl_GetStringFromObj(objv[2], (int *)NULL) );
     }
@@ -300,6 +341,8 @@ TCL_CMD_HEADER( Rivet_Headers )
     char *opt;
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::headers");
+
     if (objc < 2)
     {
         Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
@@ -404,6 +447,7 @@ TCL_CMD_HEADER( Rivet_LoadEnv )
     Tcl_Obj *ArrayObj;
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::load_env");
     if( objc > 2 ) {
         Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
         return TCL_ERROR;
@@ -441,6 +485,7 @@ TCL_CMD_HEADER ( Rivet_LoadHeaders )
     Tcl_Obj *ArrayObj;
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::load_headers");
     if( objc > 2 ) {
         Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
         return TCL_ERROR;
@@ -490,6 +535,7 @@ TCL_CMD_HEADER ( Rivet_Var )
     int source;
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::var,var_post,var_qs");
     if (objc < 2 || objc > 4)
     {
         Tcl_WrongNumArgs(interp, 1, objv,
@@ -687,6 +733,7 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
 
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::apache_table");
     if ((objc < 3) || (objc > 5)) {
         Tcl_WrongNumArgs(interp, 1, objv, "option tablename ?args?");
         return TCL_ERROR;
@@ -902,6 +949,7 @@ TCL_CMD_HEADER( Rivet_Upload )
     };
 
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+    CHECK_REQUEST_REC(globals->r,"::rivet::upload");
     if (Tcl_GetIndexFromObj(interp, objv[1], SubCommand,
                         "channel|save|data|exists|size|type|filename|names|tempname"
                         "|tempname|names",
@@ -945,65 +993,65 @@ TCL_CMD_HEADER( Rivet_Upload )
 
     switch ((enum subcommand)subcommandindex)
     {
-    case CHANNEL: {
-        Tcl_Channel chan;
-        char *channelname = NULL;
+        case CHANNEL: {
+            Tcl_Channel chan;
+            char *channelname = NULL;
 
-        if (TclWeb_UploadChannel(varname, &chan, globals->req) != TCL_OK) {
-            return TCL_ERROR;
-        }
-        channelname = (char *)Tcl_GetChannelName(chan);
-        Tcl_SetStringObj(result, channelname, -1);
-        break;
-    }
-    case SAVE:
-        /* save data to a specified filename  */
-        if (objc != 4) {
-            Tcl_WrongNumArgs(interp, 2, objv, "uploadname filename");
-            return TCL_ERROR;
+            if (TclWeb_UploadChannel(varname, &chan, globals->req) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            channelname = (char *)Tcl_GetChannelName(chan);
+            Tcl_SetStringObj(result, channelname, -1);
+            break;
         }
+        case SAVE:
+            /* save data to a specified filename  */
+            if (objc != 4) {
+                Tcl_WrongNumArgs(interp, 2, objv, "uploadname filename");
+                return TCL_ERROR;
+            }
 
-        if (TclWeb_UploadSave(varname, objv[3], globals->req) != TCL_OK)
-        {
-            return TCL_ERROR;
-        }
-        break;
-    case DATA:
-        if (TclWeb_UploadData(varname, result, globals->req) != TCL_OK) {
-            return TCL_ERROR;
-        }
-        break;
-    case EXISTS:
-        if (TclWeb_PrepareUpload(varname, globals->req) != TCL_OK)
-        {
-            Tcl_SetIntObj(result, 0);
-        } else {
-            Tcl_SetIntObj(result, 1);
-        }
-        break;
-    case SIZE:
-        TclWeb_UploadSize(result, globals->req);
-        break;
-    case TYPE:
-        TclWeb_UploadType(result, globals->req);
-        break;
-    case FILENAME:
-        TclWeb_UploadFilename(result, globals->req);
-        break;
-    case TEMPNAME:
-        TclWeb_UploadTempname(result,globals->req);
-        break;
-    case NAMES:
-        if (objc != 2)
-        {
-            Tcl_WrongNumArgs(interp, 1, objv, "names");
-            return TCL_ERROR;
-        }
-        TclWeb_UploadNames(result, globals->req);
-        break;
-    default:
-        Tcl_WrongNumArgs(interp, 1, objv,
-                         "channel|save ?name?|data|exists|size|type|filename|names|tempname");
+            if (TclWeb_UploadSave(varname, objv[3], globals->req) != TCL_OK)
+            {
+                return TCL_ERROR;
+            }
+            break;
+        case DATA:
+            if (TclWeb_UploadData(varname, result, globals->req) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            break;
+        case EXISTS:
+            if (TclWeb_PrepareUpload(varname, globals->req) != TCL_OK)
+            {
+                Tcl_SetIntObj(result, 0);
+            } else {
+                Tcl_SetIntObj(result, 1);
+            }
+            break;
+        case SIZE:
+            TclWeb_UploadSize(result, globals->req);
+            break;
+        case TYPE:
+            TclWeb_UploadType(result, globals->req);
+            break;
+        case FILENAME:
+            TclWeb_UploadFilename(result, globals->req);
+            break;
+        case TEMPNAME:
+            TclWeb_UploadTempname(result,globals->req);
+            break;
+        case NAMES:
+            if (objc != 2)
+            {
+                Tcl_WrongNumArgs(interp, 1, objv, "names");
+                return TCL_ERROR;
+            }
+            TclWeb_UploadNames(result, globals->req);
+            break;
+        default:
+            Tcl_WrongNumArgs(interp, 1, objv,
+                             "channel|save ?name?|data|exists|size|type|filename|names|tempname");
     }
     Tcl_SetObjResult(interp, result);
     return TCL_OK;
@@ -1031,6 +1079,7 @@ TCL_CMD_HEADER ( Rivet_RawPost )
     Tcl_Obj *retval;
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::raw_post");
     data = TclWeb_GetRawPost(globals->req);
 
     if (!data) {
@@ -1062,6 +1111,7 @@ TCL_CMD_HEADER( Rivet_NoBody )
 {
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::no_body");
     if (globals->req->content_sent == 1) {
         Tcl_AddErrorInfo(interp, "Content already sent");
         return TCL_ERROR;
@@ -1188,6 +1238,7 @@ TCL_CMD_HEADER( Rivet_EnvCmd )
     char *key;
     char *val;
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::env");
     if( objc != 2 ) {
         Tcl_WrongNumArgs( interp, 1, objv, "variable" );
         return TCL_ERROR;
@@ -1224,6 +1275,7 @@ TCL_CMD_HEADER( Rivet_VirtualFilenameCmd
     char *filename;
     char *virtual;
 
+    CHECK_REQUEST_REC(globals->r,"::rivet::virtual_filename");
     if( objc != 2 ) {
         Tcl_WrongNumArgs( interp, 1, objv, "filename" );
         return TCL_ERROR;
@@ -1278,19 +1330,15 @@ TCL_CMD_HEADER( Rivet_InspectCmd )
         }
     }
 
-    if (globals->r == NULL)
-    {
-
-        Tcl_SetObjResult(interp,Tcl_NewStringObj("",-1));            
-
-    } 
-    else if (objc == 1)
+    if (objc == 1)
     {
         Tcl_Obj* dictObj;
 
+        CHECK_REQUEST_REC(globals->r,"::rivet::inspect");
         rsc = Rivet_GetConf(globals->r); 
         dictObj = Rivet_BuildConfDictionary(interp,rsc);
         if (dictObj != NULL) {
+            Tcl_IncrRefCount(dictObj);
             Tcl_SetObjResult(interp,dictObj);
             Tcl_DecrRefCount(dictObj);
         } else {
@@ -1301,38 +1349,54 @@ TCL_CMD_HEADER( Rivet_InspectCmd )
     else if (objc == 2)
     {
         Tcl_Obj* par_name = objv[1];
+        char*    cmd_arg  = Tcl_GetStringFromObj(par_name,NULL);
 
         Tcl_IncrRefCount(par_name);
-        if (STRNEQU(Tcl_GetStringFromObj(par_name,NULL),"-all"))
+        if (STRNEQU(cmd_arg,"-all"))
         {
             Tcl_Obj* dictObj;
             
+            CHECK_REQUEST_REC(globals->r,"::rivet::inspect -all");
             rsc = Rivet_GetConf(globals->r); 
             dictObj = Rivet_CurrentConfDict(interp,rsc);
-            if (dictObj == NULL)
-            {
-                status = TCL_ERROR;
-            }
-            else
-            {
-                Tcl_SetObjResult(interp,dictObj);            
-                Tcl_DecrRefCount(dictObj);
-            }
+            Tcl_IncrRefCount(dictObj);
+            Tcl_SetObjResult(interp,dictObj);            
+            Tcl_DecrRefCount(dictObj);
+
+        }
+        else if (STRNEQU(cmd_arg,"server"))
+        {
+            /* we read data from the server_rec */
+            Tcl_Obj* dictObj;
+
+            dictObj = Rivet_CurrentServerRec(interp,globals->srec);
+            Tcl_IncrRefCount(dictObj);
+            Tcl_SetObjResult(interp,dictObj);            
+            Tcl_DecrRefCount(dictObj);
 
         }
         else
         {
             Tcl_Obj* par_value = NULL;
 
+            CHECK_REQUEST_REC(globals->r,"::rivet::inspect");
             rsc = Rivet_GetConf(globals->r); 
             par_value = Rivet_ReadConfParameter(interp,rsc,par_name);
             if (par_value == NULL)
             {
+                Tcl_Obj* errorinfo = Tcl_NewStringObj("mod_rivet internal error invalid argument: ",-1);
+
+                Tcl_IncrRefCount(errorinfo);
+                Tcl_AppendObjToObj(errorinfo,par_name);
+                Tcl_AppendObjToErrorInfo(interp,errorinfo);
+                Tcl_DecrRefCount(errorinfo);
                 status = TCL_ERROR;
             }
             else
             {
+                Tcl_IncrRefCount(par_value);
                 Tcl_SetObjResult(interp,par_value);
+                Tcl_DecrRefCount(par_value);
             }
 
         }

Modified: tcl/rivet/branches/modular/src/rivetcmds/rivetInspect.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/src/rivetcmds/rivetInspect.c?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/src/rivetcmds/rivetInspect.c (original)
+++ tcl/rivet/branches/modular/src/rivetcmds/rivetInspect.c Wed Apr 16 20:11:41 2014
@@ -312,7 +312,7 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl
     conf_tables[1] = rivet_conf->rivet_user_vars;
     conf_tables[2] = rivet_conf->rivet_server_vars;
 
-    Tcl_IncrRefCount(conf_dict);
+    // Tcl_IncrRefCount(conf_dict);
 
     for (it=0; it < 3; it++)
     {
@@ -372,8 +372,9 @@ Tcl_Obj* Rivet_BuildConfDictionary ( Tcl
  *
  * Returned value_
  *
- * - a Tcl_Obj* pointer to a dictionary. The dictionary object
- *  refCount is set to 1
+ * - a Tcl_Obj* pointer to a dictionary. The function is guaranteed to
+ *  return a Tcl_Obj pointer
+ *   
  */
 
 Tcl_Obj* Rivet_CurrentConfDict ( Tcl_Interp*           interp,
@@ -383,8 +384,6 @@ Tcl_Obj* Rivet_CurrentConfDict ( Tcl_Int
     Tcl_Obj* par_name; 
     static const char** p;
 
-    Tcl_IncrRefCount(dictObj);
-
     for (p = confDirectives; (*p) != NULL; p++)
     {
         Tcl_Obj* par_value;
@@ -393,29 +392,84 @@ Tcl_Obj* Rivet_CurrentConfDict ( Tcl_Int
         Tcl_IncrRefCount(par_name);
 
         par_value = Rivet_ReadConfParameter(interp,rivet_conf,par_name);
-        if (par_value != NULL)
-        {
-            Tcl_IncrRefCount(par_value);
-            Tcl_DictObjPut(interp,dictObj,par_name,par_value);
-            Tcl_DecrRefCount(par_value);
-        }
-        else
-        {
-            Tcl_Obj* message = Tcl_NewStringObj("Invalid configuration option: ",-1);
-            
-            Tcl_IncrRefCount(message);
-            Tcl_AppendObjToObj(message,par_name);
-            Tcl_AddErrorInfo(interp, Tcl_GetStringFromObj(message,NULL));
-
-            Tcl_DecrRefCount(message);
-            Tcl_DecrRefCount(par_name);
-            Tcl_DecrRefCount(dictObj);
-            dictObj = NULL;
-            break;
-        }
-        Tcl_DecrRefCount(par_name);
+        ap_assert(par_value != NULL);
+
+        Tcl_IncrRefCount(par_value);
+        Tcl_DictObjPut(interp,dictObj,par_name,par_value);
+        Tcl_DecrRefCount(par_value);
 
+        Tcl_DecrRefCount(par_name);
     }
 
     return dictObj;
 }
+
+/*
+ * -- Rivet_CurrentServerRec
+ *
+ * ::rivet::inspect provides also some basic access to 
+ * fields of the server_rec object.
+ *
+ * 
+ */
+
+Tcl_Obj* 
+Rivet_CurrentServerRec (Tcl_Interp* interp, server_rec* s )
+{
+    Tcl_Obj* dictObj; 
+    Tcl_Obj* field_name;
+    Tcl_Obj* field_value;
+    
+    dictObj = Tcl_NewObj();
+
+    field_value = Tcl_NewStringObj(s->server_hostname,-1);
+    field_name  = Tcl_NewStringObj("hostname",-1);
+    Tcl_IncrRefCount(field_value);
+    Tcl_IncrRefCount(field_name);
+
+    Tcl_DictObjPut(interp,dictObj,field_name,field_value);
+
+    Tcl_DecrRefCount(field_value);
+    Tcl_DecrRefCount(field_name);
+
+    field_value = Tcl_NewStringObj(s->error_fname,-1);
+    field_name  = Tcl_NewStringObj("errorlog",-1);
+    Tcl_IncrRefCount(field_value);
+    Tcl_IncrRefCount(field_name);
+
+    Tcl_DictObjPut(interp,dictObj,field_name,field_value);
+
+    Tcl_DecrRefCount(field_value);
+    Tcl_DecrRefCount(field_name);
+
+    field_value = Tcl_NewStringObj(s->server_admin,-1);
+    field_name  = Tcl_NewStringObj("admin",-1);
+    Tcl_IncrRefCount(field_value);
+    Tcl_IncrRefCount(field_name);
+
+    Tcl_DictObjPut(interp,dictObj,field_name,field_value);
+
+    Tcl_DecrRefCount(field_value);
+    Tcl_DecrRefCount(field_name);
+
+    field_value = Tcl_NewStringObj(s->path,-1);
+    field_name  = Tcl_NewStringObj("server_path",-1);
+    Tcl_IncrRefCount(field_value);
+    Tcl_IncrRefCount(field_name);
+
+    Tcl_DictObjPut(interp,dictObj,field_name,field_value);
+
+    Tcl_DecrRefCount(field_value);
+    Tcl_DecrRefCount(field_name);
+
+    field_value = Tcl_NewIntObj(s->is_virtual);
+    field_name  = Tcl_NewStringObj("virtual",-1);
+    Tcl_IncrRefCount(field_value);
+    Tcl_IncrRefCount(field_name);
+
+    Tcl_DictObjPut(interp,dictObj,field_name,field_value);
+
+    Tcl_DecrRefCount(field_value);
+    Tcl_DecrRefCount(field_name);
+    return dictObj;
+}

Modified: tcl/rivet/branches/modular/tests/inspect.test
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/tests/inspect.test?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/tests/inspect.test (original)
+++ tcl/rivet/branches/modular/tests/inspect.test Wed Apr 16 20:11:41 2014
@@ -25,3 +25,16 @@
 } {server {ChildInitScript {set init 1
 }}}
 
+::tcltest::test inspect-1.2 {basic introspection} {
+    file copy -force inspect.tcl /tmp/
+    apachetest::start {
+        -c "DocumentRoot /tmp" } {} {
+        catch {
+            set inspect_page [::http::geturl "${urlbase}inspect.tcl?p=script"]
+            set match [::http::data $inspect_page]
+            ::http::cleanup $inspect_page
+        }
+    }
+    file delete /tmp/inspect.tcl
+    set match
+} {/tmp/inspect.tcl}

Modified: tcl/rivet/branches/modular/tests/rivet.test
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/modular/tests/rivet.test?rev=1588055&r1=1588054&r2=1588055&view=diff
==============================================================================
--- tcl/rivet/branches/modular/tests/rivet.test (original)
+++ tcl/rivet/branches/modular/tests/rivet.test Wed Apr 16 20:11:41 2014
@@ -61,6 +61,7 @@ if { $testgroup2 } {
 
 if { $testgroup3 } {
     foreach Test {
+        failtest.test
         broken.test
         config.test
         lang.test



---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org