This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch quattuor
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git


The following commit(s) were added to refs/heads/quattuor by this push:
     new 4e59f08  new cherry-pick from master
4e59f08 is described below

commit 4e59f0830add30001dbd42effaacc137bb3cfbd4
Author: Massimo Manghi <mxman...@apache.org>
AuthorDate: Tue Nov 2 00:23:23 2021 +0100

    new cherry-pick from master
---
 ChangeLog                       | 93 ++++++++++++++++++++++-------------------
 doc/xml/commands.xml            | 10 ++---
 src/mod_rivet_ng/TclWebapache.c | 79 +++++++++++++++++++++++++++++++---
 3 files changed, 130 insertions(+), 52 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e431eea..d71c8ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-11-01 Massimo Manghi <mxman...@apache.org>
+       * src/mod_rivet_ng/Tclwebapache.c: expanded comments to newly
+       introduced functions
+
 2021-10-25 Massimo Manghi <mxman...@apache.org>
        * src/mod_rivet_ng/Tclwebapache.c: extended comments
        * src/rivet.h: new macro MINSTRLEN
@@ -11,24 +15,23 @@
 
 2021-09-06 Massimo Manghi <mxman...@apache.org>
        * rivet/packages/session/session-create-*.sql: making cache fields 
larger
-       * rivet/packages/session/session-create-*.sql: making cache fields 
larger
 
 2021-04-13 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/rivetInspect.c: add server current loglevel. Removed
-    unneeded ref count management in the server array construction
+       * src/mod_rivet_ng/rivetInspect.c: add server current loglevel. Removed
+       unneeded ref count management in the server array construction
 
 2021-03-12 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/mod_rivet.c: Rivet_SeekMPMBridge aligned with new 
implementation
-    made for 3.2.0. Removed call to Tcl_InitNotifier
+       * src/mod_rivet_ng/mod_rivet.c: Rivet_SeekMPMBridge aligned with new 
implementation
+       made for 3.2.0. Removed call to Tcl_InitNotifier
 
 2021-03-07 Massimo Manghi <mxman...@apache.org>
-    * VERSION: bumped version as 3.2.1
-    * src/mod_rivet_ng/mod_rivet.c: more linear determination of the bridge 
name
-    * rivet/packages/formbroker.tcl: introduced key maxlength
+       * VERSION: bumped version as 3.2.1
+       * src/mod_rivet_ng/mod_rivet.c: more linear determination of the bridge 
name
+       * rivet/packages/formbroker.tcl: introduced key maxlength
 
 2021-03-11 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/rivetInspect.c: add SingleThreadExit introspection
-    * src7mod_rivet_ng/rivet_lazy_mpm.c: fixed lazy bridge that did not build 
anymore
+       * src/mod_rivet_ng/rivetInspect.c: add SingleThreadExit introspection
+       * src7mod_rivet_ng/rivet_lazy_mpm.c: fixed lazy bridge that did not 
build anymore
 
 2020-10-01 Massimo Manghi <mxman...@apache.org>
        * src/mod_rivet_ng/rivet_prefork_mpm.c: Fixed trivial bug in checking 
the
@@ -63,67 +66,73 @@
        * test/apachetest/apachetest.tcl,test/runtests.tcl: add support for 
testing with various MPMs and bridges 
 
 2020-02-03 Massimo Manghi <mxman...@apache.org>
-    * src/request/: Update obsolete copyright statements
-    * src/mod_rivet_ng/rivetCore.c: update comments to upload command
-    * tests: changed upload file test
+       * src/request/: Update obsolete copyright statements
+       * src/mod_rivet_ng/rivetCore.c: update comments to upload command
+       * tests: changed upload file test
 
 2020-04-16 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/mod_rivet.[c|h]: add ap_child_shutdown flag
+       * src/mod_rivet_ng/mod_rivet.[c|h]: add ap_child_shutdown flag
        * src/mod_rivet_ng/rivet_lazy_mpm.c: adding mutex protection on thread 
count
-    * src/mod_rivet_ng/rivet_worker_mpm.c: removed old code
+       * src/mod_rivet_ng/rivet_worker_mpm.c: removed old code
 
 2020-04-02 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/formbroker.xml: fixed examples
-    * src/mod_rivet_ng/rivet_lazy_mpm.c: resolved access to shared counter
-    that was causing segfaults when child process was terminated
+       * doc/xml/formbroker.xml: fixed examples
+       * src/mod_rivet_ng/rivet_lazy_mpm.c: resolved access to shared counter
+       that was causing segfaults when child process was terminated
 
 2020-01-19 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/commands.xml: remove entry for command incr0 (dropped in 3.0)
+       * doc/xml/commands.xml: remove entry for command incr0 (dropped in 3.0)
 
 2019-12-21 Massimo Manghi <mxman...@apache.org>
-    * INSTALL: update install directions
+       * INSTALL: update install directions
 
 2019-12-12 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/apache_config.c: copying also upload_files_to_var in
-    Rivet_MergeConfig
+       * src/mod_rivet_ng/apache_config.c: copying also upload_files_to_var in
+       Rivet_MergeConfig
 
 2019-12-06 Massimo Manghi <mxman...@apache.org>
-    * doc/rivet.css: new color scheme for docbook manual
+       * doc/rivet.css: new color scheme for docbook manual
+       * src/mod_rivet_ng/rivetCore.c: expanded error info data in Rivet_Upload
+       * doc/rivet.css: new color scheme for docbook manual
+
+2019-12-04 Massimo Manghi <mxman...@apache.org>
+       * src/mod_rivet_ng/rivetCore.c: new branch uploadcmdfix with improved
+       argument checking in Rivet_Upload that was the cause of random crashes
 
 2019-11-29 Brice Hamon <bh...@apache.org>
-   * src/mod_rivet_ng/mod_rivet_cache.h: added RivetCache_DeleteEntry
-   * src/mod_rivet_ng/mod_rivet_cache.c: 
-   * src/mod_rivet_ng/rivetCore.c: fixed crash when rvt file not readable
+       * src/mod_rivet_ng/mod_rivet_cache.h: added RivetCache_DeleteEntry
+       * src/mod_rivet_ng/mod_rivet_cache.c: 
+       * src/mod_rivet_ng/rivetCore.c: fixed crash when rvt file not readable
 
 2019-10-13 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/directives.xml: configuration directives table expanded
-    * doc/xml/internals.xml: documenting the changes in the bridge API
+       * doc/xml/internals.xml: documenting the changes in the bridge API
+       * doc/xml/directives.xml: configuration directives table expanded
+       * doc/examples/
 
 2019-09-30 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/rivetCore.c: revised argument checking
+       * src/mod_rivet_ng/rivetCore.c: revised argument checking
 
 2019-09-29 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/commands.xml: Completed manual page for command 
::rivet::thread_id
-    * src/mod_rivet_ng/rivetCore.c: Rivet_GetThreadId rewritten. Now the
-    command accepts an optional argument to select decimal or hexadecimal 
(default)
-    output 
+       * doc/xml/commands.xml: Completed manual page for command 
::rivet::thread_id
+       * src/mod_rivet_ng/rivetCore.c: Rivet_GetThreadId rewritten. Now the
+       command accepts an optional argument to select decimal or hexadecimal 
(default)
+       output 
 
 2019-08-05 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/directives.xml: Documenting SingleThreadExit directive
+       * doc/xml/directives.xml: Documenting SingleThreadExit directive
 
 2019-07-27 Massimo Manghi <mxman...@apache.org>
-    * doc/xml/commands.xml,src/mod_rivet_ng/rivetCore.c: Add ::rivet::thread_id
-    manual page
+       * doc/xml/commands.xml,src/mod_rivet_ng/rivetCore.c: Add 
::rivet::thread_id manual page
 
 2019-06-30 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/rivet_worker_mpm.c: Removed unnecessary access to 
thread private data
-    in WorkerBridge_Finalize
+       * src/mod_rivet_ng/rivet_worker_mpm.c: Removed unnecessary access to 
thread private data
+       in WorkerBridge_Finalize
 
 2019-06-25 Massimo Manghi <mxman...@apache.org>
-    * src/mod_rivet_ng/rivet_worker_mpm.c: Better handling of exit signal, 
assigning tasks
-    to functions in a more consistent way. Worker_Shutdown declared as 'static'
-    * src/mod_rivet_ng/rivet_[prefork|lazy]_mpm.c: New scheme for bridge 
function names 
-    * src/mod_rivet_ng/rivet_lazy_mpm.c: Removed redundant exit command 
handling flags
+       * src/mod_rivet_ng/rivet_worker_mpm.c: Better handling of exit signal, 
assigning tasks
+       to functions in a more consistent way. Worker_Shutdown declared as 
'static'
+       * src/mod_rivet_ng/rivet_[prefork|lazy]_mpm.c: New scheme for bridge 
function names 
+       * src/mod_rivet_ng/rivet_lazy_mpm.c: Removed redundant exit command 
handling flags
 
 2019-05-29 Massimo Manghi <mxman...@apache.org>
     * src/mod_rivet_ng/apache_config.c: Now handling the directive 
SingleThreadExit 
diff --git a/doc/xml/commands.xml b/doc/xml/commands.xml
index d3104fe..b4fdd12 100644
--- a/doc/xml/commands.xml
+++ b/doc/xml/commands.xml
@@ -509,12 +509,12 @@
           <refsect1>
                        <title>Description</title>
                        <para>
-                           If just one environmental variable is needed 
<command>::rivet::env</command>
-                           returns the variable value or an empty string if 
the environment
+                           <command>::rivet::env</command> resolves a single 
environment
+                           variable and returns its value or an empty string 
if the environment
                            variable name in the argument is not defined.
-                           This command has some performance advantages with 
respect to
-                           <command>::rivet::load_env</command> since it 
avoids the
-                           loading of the whole set of environment and header 
variables.
+                           This command is the recommended way to resolve an 
environment
+                           variable leaving 
<command>::rivet::load_env</command> to debugging
+                           and development operations.
                        </para>
           </refsect1>
        </refentry>
diff --git a/src/mod_rivet_ng/TclWebapache.c b/src/mod_rivet_ng/TclWebapache.c
index fba67b7..febed9f 100644
--- a/src/mod_rivet_ng/TclWebapache.c
+++ b/src/mod_rivet_ng/TclWebapache.c
@@ -53,7 +53,7 @@ extern mod_rivet_globals* module_globals;
 #define ENV_COMMON_VARS(env) env |= ENV_COMMON_VARS_M;
 #define ENV_CGI_VARS(env)    env |= ENV_CGI_VARS_M;
 #define ENV_VARS(env)        env |= ENV_VARS_M;
-
+#define ENV_LOADED(env)      env |= ENV_COMMON_VARS_M | ENV_CGI_VARS_M | 
ENV_VARS_M;
 #define ENV_IS_LOADED(env)          (env == (ENV_COMMON_VARS_M | 
ENV_CGI_VARS_M | ENV_VARS_M))
 #define ENV_COMMON_VARS_LOADED(env) (env & ENV_COMMON_VARS_M) != 0
 #define ENV_CGI_VARS_LOADED(env)    (env & ENV_CGI_VARS_M) != 0
@@ -459,7 +459,13 @@ TclWeb_VarNumber(Tcl_Obj *result, int source, 
TclWebRequest *req)
 }
 
 /* These 2 array must be aligned and a one-to-one correspondence preserved 
- * The enum include_vars_idx must be terminated by 'invalid_env_var'
+ * The enum include_vars_idx *must* be terminated by 'invalid_env_var'
+ * Adding a new env variable requires 
+ *    + the name of the variable be listed in include_env_vars
+ *    + a new value in the enumerator include_vars_idx must be added in the 
+ *      corresponding position of the variable names array
+ *    + the switch construct in function TclWeb_SelectEnvIncludeVar must
+ *      be expanded to handle the new case identified by the new enumerator 
value
  */
 
 static const char* include_env_vars[] =
@@ -474,6 +480,27 @@ enum include_vars_idx {
     invalid_env_var
 };
 
+/*  -- TclWeb_SelectEnvIncludeVar 
+ *
+ *  Depending on the value idx of the enumerator a method is selected
+ *  to return a string of a specific environment variable methods
+ *  Adding new environment variables need new cases of the switch 
+ *  construct to be added, provided the data can be obtained from
+ *  the rivet_thread_private structure
+ *
+ *   Arguments:
+ *
+ *      + rivet_thread_private* private: pointer to a thread private data 
structure
+ *      + int idx: an integer value listed in the enumerator include_vars_idx
+ *
+ *   Results:
+ *
+ *      A character string pointer to the value of the environment variable or
+ *      NULL if the enumerator value idx was invalid or resolving the 
environment
+ *      variable was impossible
+ * 
+ */
+
 static char*
 TclWeb_SelectEnvIncludeVar (rivet_thread_private* private,int idx)
 {
@@ -591,12 +618,10 @@ TclWeb_InitEnvVars (rivet_thread_private* private)
     if (!ENV_CGI_VARS_LOADED(req->environment_set))
     {
         ap_add_cgi_vars(req->req);
-        ENV_CGI_VARS(req->environment_set);
     }
     if (!ENV_COMMON_VARS_LOADED(req->environment_set))
     {
         ap_add_common_vars(req->req);
-        ENV_COMMON_VARS(req->environment_set)
     }
 
     /* Loading into 'table' the include vars */
@@ -614,11 +639,24 @@ TclWeb_InitEnvVars (rivet_thread_private* private)
         {
             
apr_table_set(table,include_env_vars[idx],TclWeb_SelectEnvIncludeVar(private,idx));
         }
-        ENV_VARS(req->environment_set)
     }
 
+    ENV_LOADED(req->environment_set)
 }
 
+/* -- TclWeb_GetEnvIncludeVar
+ *
+ *  the environment variable named in key is searched among the include
+ *  variables and then resolved by calling TclWeb_SelectEnvIncludeVar
+ *
+ *  Result:
+ *
+ *    a character string pointer to the environment variable value or
+ *    NULL if the environment variable name in invalid or the variable
+ *    could not be resolved
+ *      
+ */
+
 static char*
 TclWeb_GetEnvIncludeVar (rivet_thread_private* private,char* key)
 {
@@ -912,6 +950,31 @@ int TclWeb_UploadNames(TclWebRequest *req)
     return TCL_OK;
 }
 
+/*
+ * -- TclWeb_GetEnvVar
+ *
+ * basically is the core of the ::rivet::env rivet command. The argument to
+ * the command is stored in 'key' and the function starts a search in various
+ * tables following the following order
+ *
+ *  + though undocumented in the manual the first table checked is HTTP
+ *    headers table. ::rivet::env is actually like ::rivet::headers but for
+ *    the *request_rec->headers_in table
+ *  + the common CGI variables table is checked
+ *  + the CGI 1.1 headers table is checked
+ *  + the include variables list is checked calling TclWeb_GetEnvIncludeVar
+ *
+ *  Arguments:
+ *
+ *   - key: a string with the environment variable name
+ *
+ *  Results:
+ *
+ *    - a string pointer to the string with the variable translation or
+ *    NULL if the environment variable is not found
+ *
+ */
+
 char *
 TclWeb_GetEnvVar(rivet_thread_private* private,char *key)
 {
@@ -942,6 +1005,12 @@ TclWeb_GetEnvVar(rivet_thread_private* private,char *key)
     }
     val = (char *)apr_table_get(req->req->subprocess_env,key);
     if (val) { return val; }
+
+    /* If everything failed we assumed the variable is one of
+     * the 'include variables' and we try to resolve it calling
+     * TclWeb_GetEnvIncludeVar, which returns NULL if the variable
+     * is undefined */
+
     return TclWeb_GetEnvIncludeVar(private,key);
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@tcl.apache.org
For additional commands, e-mail: commits-h...@tcl.apache.org

Reply via email to