You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/06/01 10:15:12 UTC

[tcl-rivet] branch quattuor updated (2d9bfb7 -> afc9a03)

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

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


    from 2d9bfb7  introducing handling of single thread exit
     new a7a7e30  better wording in introduction
     new ddf2e9b  removed reference to no more existing cohexistence problem with CGI scripts
     new 0707530  add reference to new SingleThreadExit directive
     new 5fd624f  add RivetCache_Destroy, more efficient cache regeneration by clearing the interpreter pool, instead of destroying to recreate it
     new afc9a03  handling single thread exit

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md                                |   7 +-
 cvsversion.tcl                           | 124 -------------------------------
 doc/xml/intro.xml                        |   9 ++-
 src/mod_rivet_ng/apache_config.c         |   1 +
 src/mod_rivet_ng/mod_rivet.h             |   6 +-
 src/mod_rivet_ng/mod_rivet_cache.c       |  56 +++++++++-----
 src/mod_rivet_ng/mod_rivet_cache.h       |   3 +-
 src/mod_rivet_ng/mod_rivet_common.c      |  27 +++----
 src/mod_rivet_ng/mod_rivet_generator.c   |  16 +---
 src/mod_rivet_ng/rivetInspect.c          |   3 +
 src/mod_rivet_ng/rivet_lazy_mpm.c        |  10 ++-
 src/mod_rivet_ng/rivet_worker_mpm.c      |  46 +++++++-----
 src/mod_rivet_ng/worker_prefork_common.c |   4 +-
 13 files changed, 103 insertions(+), 209 deletions(-)
 delete mode 100755 cvsversion.tcl


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


[tcl-rivet] 01/05: better wording in introduction

Posted by mx...@apache.org.
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

commit a7a7e303dd03db5c010a6fdd0bb4b69d8585afb9
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 11:55:13 2019 +0200

    better wording in introduction
---
 doc/xml/intro.xml | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/doc/xml/intro.xml b/doc/xml/intro.xml
index b1cdc4d..f79f3c2 100644
--- a/doc/xml/intro.xml
+++ b/doc/xml/intro.xml
@@ -75,11 +75,12 @@
 		
 		<para>
 			Rivet &version; implements a new <link linkend="request">request processing scheme</link> 
-			entirely based on Tcl. By default rivet &version; provides compatiblity with the 
-			version &version2-generic; scheme to handle a request but this can be entirely overridden by
-			the developer replacing the central request handling procedure. See the 
-			<link linkend="request">request processing</link> page.
+			entirely based on Tcl. By default rivet &version; provides compatiblity with the
+			way version &version2-generic; and &version30; handle a request but this can
+			be entirely overridden by the developer replacing the central request handling procedure.
+			See the <link linkend="request">request processing</link> page.
 		</para>
+
     </simplesect>
     <simplesect>
     	<title>Acknowledgements</title>


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


[tcl-rivet] 04/05: add RivetCache_Destroy, more efficient cache regeneration by clearing the interpreter pool, instead of destroying to recreate it

Posted by mx...@apache.org.
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

commit 5fd624fd549d4d77f31a3d067bd4c8522e142b2b
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 12:00:06 2019 +0200

    add RivetCache_Destroy, more efficient cache regeneration by clearing the interpreter pool, instead of destroying to recreate it
---
 src/mod_rivet_ng/mod_rivet_cache.c | 56 ++++++++++++++++++++++++--------------
 src/mod_rivet_ng/mod_rivet_cache.h |  3 +-
 2 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/src/mod_rivet_ng/mod_rivet_cache.c b/src/mod_rivet_ng/mod_rivet_cache.c
index 721c8d9..732e31e 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.c
+++ b/src/mod_rivet_ng/mod_rivet_cache.c
@@ -51,17 +51,45 @@ extern mod_rivet_globals* module_globals;
  *
  */
 
-void RivetCache_Create (apr_pool_t *p, rivet_thread_interp* interp_obj)
+void RivetCache_Create (rivet_thread_interp* interp_obj)
 {
-    interp_obj->objCacheList = 
-                apr_pcalloc(p,(signed)((interp_obj->cache_size)*sizeof(char *)));
-    interp_obj->objCache    = 
-                apr_pcalloc(p,sizeof(Tcl_HashTable));
+    interp_obj->objCacheList = apr_pcalloc(interp_obj->pool,(signed)((interp_obj->cache_size)*sizeof(char *)));
+    interp_obj->objCache = apr_pcalloc(interp_obj->pool,sizeof(Tcl_HashTable));
 
     Tcl_InitHashTable(interp_obj->objCache,TCL_STRING_KEYS);
 }
 
 /*
+ * -- RivetCache_Destroy
+ *
+ *
+ */
+
+void RivetCache_Destroy (rivet_thread_private* private,rivet_thread_interp* rivet_interp)
+{
+    int ct;
+    Tcl_HashEntry *delEntry;
+
+    /* Clean out the list. */
+    ct = rivet_interp->cache_free;
+    while (ct < rivet_interp->cache_size) {
+        /* Free the corresponding hash entry. */
+        delEntry = Tcl_FindHashEntry(rivet_interp->objCache,
+                                     rivet_interp->objCacheList[ct]);
+
+        if (delEntry != NULL) {
+            Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
+            Tcl_DeleteHashEntry(delEntry);
+            rivet_interp->objCacheList[ct] = NULL;
+        }
+
+        ct++;
+    }
+    apr_pool_destroy(rivet_interp->pool);
+}
+
+
+/*
  * -- RivetCache_Cleanup
  *
  * Cache clean-up. This function is called when a user configuration
@@ -99,23 +127,11 @@ void RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rive
 
         ct++;
     }
-    apr_pool_destroy(rivet_interp->pool);
+    apr_pool_clear(rivet_interp->pool);
     
-    /* let's recreate the cache list */
+    rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool,(signed)(rivet_interp->cache_size*sizeof(char *)));
+    rivet_interp->cache_free = rivet_interp->cache_size;
 
-    if (apr_pool_create(&rivet_interp->pool, private->pool) != APR_SUCCESS)
-    {
-        ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, 
-                     MODNAME ": could not recreate cache private pool. Cache disabled");
-        rivet_interp->cache_free = rivet_interp->cache_size = 0;
-    }
-    else
-    {
-        rivet_interp->objCacheList = apr_pcalloc (rivet_interp->pool, 
-                                                (signed)(rivet_interp->cache_size*sizeof(char *)));
-        rivet_interp->cache_free = rivet_interp->cache_size;
-    }
-    
 }
 
 /* 
diff --git a/src/mod_rivet_ng/mod_rivet_cache.h b/src/mod_rivet_ng/mod_rivet_cache.h
index 2f54827..4e830d4 100644
--- a/src/mod_rivet_ng/mod_rivet_cache.h
+++ b/src/mod_rivet_ng/mod_rivet_cache.h
@@ -21,7 +21,8 @@
 #ifndef __mod_rivet_cache_h__
 #define __mod_rivet_cache_h__
 
-EXTERN void  RivetCache_Create  (apr_pool_t *p, rivet_thread_interp* interp_obj);
+EXTERN void  RivetCache_Create  (rivet_thread_interp* interp_obj);
+EXTERN void  RivetCache_Destroy (rivet_thread_private* private,rivet_thread_interp* rivet_interp);
 EXTERN void  RivetCache_Cleanup (rivet_thread_private* private,rivet_thread_interp* rivet_interp);
 EXTERN char* RivetCache_MakeKey (apr_pool_t* pool, char*         filename,
                                                    time_t        ctime, 


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


[tcl-rivet] 02/05: removed reference to no more existing cohexistence problem with CGI scripts

Posted by mx...@apache.org.
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

commit ddf2e9bac39e72fe589fb2d45fe5ccc90b9b28b8
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 11:56:05 2019 +0200

    removed reference to no more existing cohexistence problem with CGI scripts
---
 README.md | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 5bdfeea..b848fe2 100644
--- a/README.md
+++ b/README.md
@@ -18,12 +18,7 @@ See [LICENSE](LICENSE) for licensing terms.
 | macOS 64 (Darwin), Apache 2.4.37, Tcl/Tk 8.5 |  | | |
 
 
-## KNOWN PROBLEMS
-
- - Rivet is reported to conflict with cgi scripts on some Linux machines. Symptom of the problem is when cgi scripts hang forever and don't send contents to the client
-
 ## RIVET NAMESPACE
 
- - With the intruduction of the ::rivet namespace the command set has been moved into it and each command should now be fully qualified. Building rivet you can choose in case to place the commands on the export 
- list or even automatically import them into the global namespace. This is a deprecated option though unless you have a compatibility issue with existing legacy Rivet based code.
+ - With the intruduction of the ::rivet namespace the command set has been moved into it and each command should now be fully qualified. Building rivet you can choose in case to place the commands on the export list or even automatically import them into the global namespace. This is a deprecated option though unless you have a compatibility issue with existing legacy Rivet based code.
 


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


[tcl-rivet] 03/05: add reference to new SingleThreadExit directive

Posted by mx...@apache.org.
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

commit 0707530649e8d2a3c7270ee6409a14664a2832b7
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 11:57:11 2019 +0200

    add reference to new SingleThreadExit directive
---
 src/mod_rivet_ng/apache_config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mod_rivet_ng/apache_config.c b/src/mod_rivet_ng/apache_config.c
index 9a263e9..ede7db6 100644
--- a/src/mod_rivet_ng/apache_config.c
+++ b/src/mod_rivet_ng/apache_config.c
@@ -619,6 +619,7 @@ Rivet_DirConf(cmd_parms *cmd,void *vrdc,const char *var,const char *val)
  *  RivetServerConf SeparateVirtualInterps <yes|no>
  *  RivetServerConf HonorHeaderOnlyRequests <yes|no> (2008-06-20: mm)
  *  RivetServerConf MpmBridge <path-to-mpm-bridge>|<bridge-label> (2015-12-14: mm)
+ *  RivetServerConf SingleThreadExit <On|Off> (2019-05-23: mm)
  */
 
 const char *


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


[tcl-rivet] 05/05: handling single thread exit

Posted by mx...@apache.org.
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

commit afc9a0338f77ab2252cdb705f591bcf05dd5d626
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Sat Jun 1 12:14:59 2019 +0200

    handling single thread exit
---
 cvsversion.tcl                           | 124 -------------------------------
 src/mod_rivet_ng/mod_rivet.h             |   6 +-
 src/mod_rivet_ng/mod_rivet_common.c      |  27 +++----
 src/mod_rivet_ng/mod_rivet_generator.c   |  16 +---
 src/mod_rivet_ng/rivetInspect.c          |   3 +
 src/mod_rivet_ng/rivet_lazy_mpm.c        |  10 ++-
 src/mod_rivet_ng/rivet_worker_mpm.c      |  46 +++++++-----
 src/mod_rivet_ng/worker_prefork_common.c |   4 +-
 8 files changed, 58 insertions(+), 178 deletions(-)

diff --git a/cvsversion.tcl b/cvsversion.tcl
deleted file mode 100755
index f73196c..0000000
--- a/cvsversion.tcl
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/bin/sh
-# the next line restarts using tclsh \
-    exec tclsh "$0" "$@"
-
-# By David N. Welton <da...@dedasys.com>
-# $Id$
-
-# This is to generate new versions based on CVS information.
-
-set newversionvar 0
-
-proc newversion { } {
-    global newversionvar
-    puts stderr "New version"
-    set newversionvar 1
-}
-
-proc diffentries { {dir .} } {
-    global newversionvar
-
-    set CVSEntries [file join . CVS Entries]
-    set OldEntries [file join . .OLDEntries]
-
-    puts stderr "Diffentries for $dir"
-    set currentdir [pwd]
-    cd $dir
-    if { ! [file exists $CVSEntries] } {
-	puts stderr "You must be in a directory with a path to ./CVS/Entries."
-    }
-
-    if { ! [file exists $OldEntries] } {
-	puts stderr "No OLDEntries file.  It will be created."
-	set fl [open $OldEntries w]
-	close $fl
-    }
-
-    set entries [open $CVSEntries]
-    set blob ""
-    while { [gets $entries ln] != -1 } {
-	lappend blob $ln
-    }
-    close $entries
-
-    set oldentries [open $OldEntries]
-    set blob2 ""
-    while { [gets $oldentries ln] != -1 } {
-	lappend blob2 $ln
-    }
-    close $oldentries
-
-    if { $blob != $blob2 } {
-	newversion
-    }
-    foreach ln $blob {
-	# the regexp below scans for directories in CVS Entries files
-	if { [regexp {^D/(.*)////$} "$ln" match dir] } {
-	    diffentries $dir
-	}
-    }
-
-    file copy -force $CVSEntries $OldEntries
-    cd $currentdir
-}
-
-proc main {} {
-    global newversionvar
-
-    diffentries
-
-    if { $newversionvar == 0 } {
-	puts stderr "No changes, exiting."
-    } else {
-	if { [file exists VERSION] } {
-	    set versionfile [open VERSION "r"]
-	    gets $versionfile versionstring
-	    close $versionfile
-	} else {
-	    set versionstring "0.0.0"
-	}
-
-	if { ! [regexp {([0-9]+)\.([0-9]+)\.([0-9]+)} $versionstring match major minor point] } {
-	    puts stderr "Problem with versionstring '$versionstring', exiting"
-	    exit 1
-	}
-
-	set versionfile [ open VERSION "w" ]
-	if { [catch {
-	while { 1 } {
-	    puts -nonewline "Current version: $major.$minor.$point.  "
-	    puts -nonewline {Increment [M]ajor, m[I]nor, [P]oint release, or [A]bort? >>> }
-	    flush stdout
-	    gets stdin answer
-	    switch [string tolower $answer] {
-		m {
-		    incr major
-		    set minor 0
-		    set point 0
-		    break
-		}
-		i {
-		    incr minor
-		    set point 0
-		    break
-		}
-		p {
-		    incr point
-		    break
-		}
-		a {
-		    puts "Aborted"
-		    break
-		}
-	    }
-	}
-	puts $versionfile "$major.$minor.$point"
-	} err] } {
-	    puts stderr "Problem writing VERSION file: $err"
-	    puts $versionfile "$major.$minor.$point"
-	}
-	close $versionfile
-	puts "Done, version is $major.$minor.$point"
-    }
-}
-main
\ No newline at end of file
diff --git a/src/mod_rivet_ng/mod_rivet.h b/src/mod_rivet_ng/mod_rivet.h
index ce4c0f4..58e3d16 100644
--- a/src/mod_rivet_ng/mod_rivet.h
+++ b/src/mod_rivet_ng/mod_rivet.h
@@ -138,9 +138,9 @@ typedef struct _rivet_server_conf {
     apr_table_t*    rivet_server_vars;
     apr_table_t*    rivet_dir_vars;
     apr_table_t*    rivet_user_vars;
-    int             idx;                /* server record index (to be used for the interps db)      */
-    char*           path;               /* copy of the path field of a cmd_parms structure:         
-                                         * should enable us to tell if a conf record comes from a
+    int             idx;                /* server record index (to be used for the interps db)          */
+    char*           path;               /* copy of the path field of a cmd_parms structure:             *
+                                         * should enable us to tell if a conf record comes from a       *
                                          * Directory section */
     const char*     mpm_bridge;         /* MPM bridge. if not null the module will try to load the      * 
                                          * file name in this field. The string should be either a full  *
diff --git a/src/mod_rivet_ng/mod_rivet_common.c b/src/mod_rivet_ng/mod_rivet_common.c
index 3ed47be..59d3ff4 100644
--- a/src/mod_rivet_ng/mod_rivet_common.c
+++ b/src/mod_rivet_ng/mod_rivet_common.c
@@ -79,7 +79,7 @@ Rivet_DuplicateVHostInterp(apr_pool_t* pool, rivet_thread_interp* source_obj)
     /* An intepreter must have its own cache */
 
     if (interp_obj->cache_size) {
-        RivetCache_Create(pool,interp_obj); 
+        RivetCache_Create(interp_obj); 
     }
 
     interp_obj->pool            = source_obj->pool;
@@ -357,8 +357,7 @@ void Rivet_PerInterpInit(rivet_thread_interp* interp_obj,
 
 rivet_thread_interp* Rivet_NewVHostInterp(rivet_thread_private* private,server_rec* server)
 {
-    apr_pool_t*             pool = private->pool;
-    rivet_thread_interp*    interp_obj = apr_pcalloc(pool,sizeof(rivet_thread_interp));
+    rivet_thread_interp*    interp_obj = apr_pcalloc(private->pool,sizeof(rivet_thread_interp));
     rivet_server_conf*      rsc;
 
     /* The cache size is global so we take it from here */
@@ -385,25 +384,27 @@ rivet_thread_interp* Rivet_NewVHostInterp(rivet_thread_private* private,server_r
         interp_obj->cache_free = interp_obj->cache_size;
     }
 
-    /* we now create memory from the cache pool as subpool of the thread private pool */
+    /* we now create memory for the cache as subpool of the thread private pool */
  
-    if (apr_pool_create(&interp_obj->pool, pool) != APR_SUCCESS)
+    if (apr_pool_create(&interp_obj->pool, private->pool) != APR_SUCCESS)
     {
         ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, server, 
                      MODNAME ": could not initialize cache private pool");
         return NULL;
     }
 
-    // Initialize cache structures
+    ap_assert(interp_obj->pool != private->pool);
+
+    /* Initialize cache structures */
 
     if (interp_obj->cache_size) {
-        RivetCache_Create(pool,interp_obj); 
+        RivetCache_Create(interp_obj); 
     }
 
     interp_obj->channel         = NULL;
     interp_obj->flags           = 0;
-    interp_obj->scripts         = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts));
-    interp_obj->per_dir_scripts = apr_hash_make(pool); 
+    interp_obj->scripts         = (running_scripts *) apr_pcalloc(private->pool,sizeof(running_scripts));
+    interp_obj->per_dir_scripts = apr_hash_make(private->pool); 
 
     return interp_obj;
 }
@@ -507,14 +508,14 @@ Rivet_ReleaseRivetChannel (Tcl_Interp* interp, Tcl_Channel* channel)
  *-----------------------------------------------------------------------------
  */
 
-rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* pPool,bool create_request_obj)
+rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* tPool,bool create_request_obj)
 {
     rivet_thread_private*   private;
 
     ap_assert (apr_threadkey_private_get ((void **)&private,rivet_thread_key) == APR_SUCCESS);
 
     //apr_thread_mutex_lock(module_globals->pool_mutex);
-    private = apr_pcalloc (pPool,sizeof(*private));
+    private = apr_pcalloc (tPool,sizeof(*private));
     //apr_thread_mutex_unlock(module_globals->pool_mutex);
 
     /*
@@ -529,14 +530,14 @@ rivet_thread_private* Rivet_CreatePrivateData (apr_pool_t* pPool,bool create_req
     }
     */
 
-    private->pool           = pPool;
+    // ap_assert (apr_pool_create (&private->pool, NULL) == APR_SUCCESS);
+    private->pool           = tPool;
     private->req_cnt        = 0;
     private->r              = NULL;
     private->page_aborting  = 0;
     private->thread_exit    = 0;
     private->exit_status    = 0;
     private->abort_code     = NULL;
-    //private->channel        = NULL;
     private->req            = NULL;
 
     if (create_request_obj)
diff --git a/src/mod_rivet_ng/mod_rivet_generator.c b/src/mod_rivet_ng/mod_rivet_generator.c
index 56d4fc3..9ec8469 100644
--- a/src/mod_rivet_ng/mod_rivet_generator.c
+++ b/src/mod_rivet_ng/mod_rivet_generator.c
@@ -313,8 +313,6 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r)
     /* URL referenced script execution and exception handling */
 
     if (Tcl_EvalObjEx(interp, private->running->request_processing,0) == TCL_ERROR) 
-    //if (Rivet_ParseExecFile (private, private->r->filename, 1) != TCL_OK)
-    //if (Rivet_ExecuteAndCheck(private,private->request_processing) == TCL_ERROR)
     {
         /* we don't report errors coming from abort_page execution */
 
@@ -323,7 +321,7 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r)
             request_rec* r = private->r;
 
             ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, 
-                         MODNAME ": Error parsing exec file '%s': %s",
+                         MODNAME ": Error evaluating exec file '%s': %s",
                          r->filename, Tcl_GetVar(interp, "errorInfo", 0));
         }
     }
@@ -336,16 +334,6 @@ Rivet_SendContent(rivet_thread_private *private,request_rec* r)
         private->running_conf->user_scripts_status &= ~(unsigned int)USER_SCRIPTS_UPDATED;
     }
 
-    /* and finally we run the request_cleanup procedure (always set) */
-    
-    //if (Tcl_EvalObjEx(interp, private->request_cleanup, 0) == TCL_ERROR) {
-    //
-    //    ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, private->r, 
-    //                 MODNAME ": Error evaluating cleanup request: %s",
-    //                 Tcl_GetVar(interp, "errorInfo", 0));
-    //
-    //}
-
     /* We finalize the request processing by printing the headers and flushing
        the rivet channel internal buffer */
 
@@ -369,7 +357,7 @@ sendcleanup:
     if (private->thread_exit)
     {
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, private->r, 
-                                  "process terminating with code %d",private->exit_status);
+                                  "thread terminating with code %d",private->exit_status);
         RIVET_MPM_BRIDGE_CALL(exit_handler,private);
         //Tcl_Exit(private->exit_status);
         //exit(private->exit_status);
diff --git a/src/mod_rivet_ng/rivetInspect.c b/src/mod_rivet_ng/rivetInspect.c
index 5424ea8..7a4c231 100644
--- a/src/mod_rivet_ng/rivetInspect.c
+++ b/src/mod_rivet_ng/rivetInspect.c
@@ -62,6 +62,7 @@ static const char* confDirectives[] =
                     "RequestHandler",
                     "ExportRivetNS",
                     "ImportRivetNS",
+                    "SingleThreadExit",
                     NULL 
 };
 
@@ -85,6 +86,7 @@ enum confIndices {
                     request_handler,
                     export_rivet_ns,
                     import_rivet_ns,
+                    single_thread_exit,
                     conf_index_terminator 
 };
 
@@ -147,6 +149,7 @@ Rivet_ReadConfParameter ( Tcl_Interp*        interp,
         case honor_header_only_requests: int_value = Tcl_NewIntObj(rsc->honor_header_only_reqs); break;
         case export_rivet_ns:           int_value = Tcl_NewIntObj(rsc->export_rivet_ns); break;
         case import_rivet_ns:           int_value = Tcl_NewIntObj(rsc->import_rivet_ns); break;
+        case single_thread_exit:        int_value = Tcl_NewIntObj(rsc->single_thread_exit); break;
         default: return NULL;
     }
 
diff --git a/src/mod_rivet_ng/rivet_lazy_mpm.c b/src/mod_rivet_ng/rivet_lazy_mpm.c
index a84c32e..44ae7f5 100644
--- a/src/mod_rivet_ng/rivet_lazy_mpm.c
+++ b/src/mod_rivet_ng/rivet_lazy_mpm.c
@@ -206,6 +206,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
 
     idx = w->conf->idx;
     apr_thread_mutex_lock(w->mutex);
+    ap_log_error(APLOG_MARK,APLOG_DEBUG,APR_SUCCESS,w->server,"processor thread startup completed");
     do 
     {
         module_globals->mpm->vhosts[idx].idle_threads_cnt++;
@@ -237,9 +238,12 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
  
         /* rescheduling itself in the array of idle threads */
        
-        apr_thread_mutex_lock(module_globals->mpm->vhosts[idx].mutex);
-        *(lazy_tcl_worker **) apr_array_push(module_globals->mpm->vhosts[idx].array) = w;
-        apr_thread_mutex_unlock(module_globals->mpm->vhosts[idx].mutex);
+        if (private->ext->keep_going)
+        {
+            apr_thread_mutex_lock(module_globals->mpm->vhosts[idx].mutex);
+            *(lazy_tcl_worker **) apr_array_push(module_globals->mpm->vhosts[idx].array) = w;
+            apr_thread_mutex_unlock(module_globals->mpm->vhosts[idx].mutex);
+        }
 
     } while (private->ext->keep_going);
     apr_thread_mutex_unlock(w->mutex);
diff --git a/src/mod_rivet_ng/rivet_worker_mpm.c b/src/mod_rivet_ng/rivet_worker_mpm.c
index 1f2773e..c588d7d 100644
--- a/src/mod_rivet_ng/rivet_worker_mpm.c
+++ b/src/mod_rivet_ng/rivet_worker_mpm.c
@@ -203,7 +203,7 @@ static void Worker_CreateInterps (rivet_thread_private* private,rivet_thread_int
 
 }
 
-/*-- request_processor_ng
+/*-- request_processor
  *
  */
 
@@ -211,10 +211,14 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
 {
     rivet_thread_private*   private;
     handler_private*        thread_obj;
+    apr_pool_t*             tPool;
 
     apr_thread_mutex_lock(module_globals->mpm->job_mutex);
 
-    private = Rivet_CreatePrivateData(apr_thread_pool_get(thd),true);
+    //tPool = apr_thread_pool_get(thd);
+    ap_assert (apr_pool_create(&tPool,apr_thread_pool_get(thd)) == APR_SUCCESS);
+
+    private = Rivet_CreatePrivateData(tPool,true);
     ap_assert(private != NULL);
 
     //private->channel = Rivet_CreateRivetChannel(private->pool,rivet_thread_key);
@@ -287,7 +291,7 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
             continue;
         }
 
-        /* we set the status to request_processing  */
+        /* we set the status to request_processing */
 
         thread_obj->status = request_processing;
 
@@ -296,15 +300,14 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
         apr_atomic_inc32(module_globals->mpm->running_threads_count);
 
         /* these assignements are crucial for both calling Rivet_SendContent and
-         * for telling the channel where stuff must be sent to */
+         * for telling the channel where stuff must be sent to
+         */
 
         private->ctype = thread_obj->ctype;
         private->req_cnt++;
 
         HTTP_REQUESTS_PROC(thread_obj->code = Rivet_SendContent(private,thread_obj->r));
-
         thread_obj->status = done;
-        if (private->thread_exit) thread_obj->status = child_exit;
 
         apr_thread_cond_signal(thread_obj->cond);
 
@@ -314,30 +317,38 @@ static void* APR_THREAD_FUNC request_processor (apr_thread_t *thd, void *data)
         }
         apr_atomic_dec32(module_globals->mpm->running_threads_count);
 
-    } while (private->ext->keep_going > 0);
+    } while (private->ext->keep_going);
 
+    thread_obj->status = child_exit;
     apr_thread_mutex_unlock(thread_obj->mutex);
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, module_globals->server, "processor thread orderly exit");
 
     {
-        rivet_server_conf*  rsc = RIVET_SERVER_CONF(module_globals->server->module_config);
+        rivet_server_conf* rsc = RIVET_SERVER_CONF(module_globals->server->module_config);
 
         if (rsc->single_thread_exit)
         {
-            Rivet_ProcessorCleanup(private);
+            //Rivet_ProcessorCleanup(private);
         }
     }
 
-    apr_thread_mutex_lock(module_globals->mpm->job_mutex);
-    *(apr_thread_t **) apr_array_push(module_globals->mpm->exiting) = thd;
-    apr_thread_cond_signal(module_globals->mpm->job_cond);
-    apr_thread_mutex_unlock(module_globals->mpm->job_mutex);
+    /* Deleting the condition variable and related mutex */
+
+    apr_thread_mutex_destroy(thread_obj->mutex);
+    apr_thread_cond_destroy(thread_obj->cond);
 
     /* the counter of active threads has to be decremented */
 
     apr_atomic_dec32(module_globals->mpm->threads_count);
 
-    /* this call triggers thread private stuff clean up by calling processor_cleanup */
+    /* Notifying the supervisor this thread is about to exit */
+
+    apr_thread_mutex_lock(module_globals->mpm->job_mutex);
+    *(apr_thread_t **) apr_array_push(module_globals->mpm->exiting) = thd;
+    apr_thread_cond_signal(module_globals->mpm->job_cond);
+    apr_thread_mutex_unlock(module_globals->mpm->job_mutex);
+
+    apr_pool_destroy(tPool);
 
     apr_thread_exit(thd,APR_SUCCESS);
     return NULL;
@@ -366,7 +377,7 @@ static void start_thread_pool (int nthreads)
 
         if (rv != APR_SUCCESS) 
         {
-            char    errorbuf[RIVET_MSG_BUFFER_SIZE];
+            char errorbuf[RIVET_MSG_BUFFER_SIZE];
 
             apr_strerror(rv, errorbuf,RIVET_MSG_BUFFER_SIZE);
             ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, module_globals->server, 
@@ -437,8 +448,6 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void
 
     do
     {
-        apr_thread_t* p;
-      
         apr_thread_mutex_lock(mpm->job_mutex);
         while (apr_is_empty_array(mpm->exiting) && !mpm->server_shutdown)
         {
@@ -448,6 +457,8 @@ static void* APR_THREAD_FUNC threaded_bridge_supervisor (apr_thread_t *thd, void
         while (!apr_is_empty_array(mpm->exiting) && !mpm->server_shutdown)
         {
             int i;
+            apr_thread_t* p;
+
             p = *(apr_thread_t **)apr_array_pop(mpm->exiting);
             
             for (i = 0; (i < module_globals->mpm->max_threads) && !mpm->server_shutdown; i++)
@@ -816,7 +827,6 @@ int Worker_MPM_ExitHandler(rivet_thread_private* private)
          * and is sequence the whole process to shutdown by calling exit() */
      
         Worker_MPM_Finalize (private->r->server);
-        exit(private->exit_status);
 
     } 
 
diff --git a/src/mod_rivet_ng/worker_prefork_common.c b/src/mod_rivet_ng/worker_prefork_common.c
index 9f3eae9..1aff536 100644
--- a/src/mod_rivet_ng/worker_prefork_common.c
+++ b/src/mod_rivet_ng/worker_prefork_common.c
@@ -196,7 +196,7 @@ void Rivet_ProcessorCleanup (rivet_thread_private* private)
 
         if ((i == 0) || rsc->separate_virtual_interps)
         {
-            RivetCache_Cleanup(private,private->ext->interps[i]);
+            RivetCache_Destroy(private,private->ext->interps[i]);
             Tcl_DeleteInterp(private->ext->interps[i]->interp);
             Rivet_ReleaseRivetChannel(private->ext->interps[i]->interp,private->ext->interps[i]->channel);
         }
@@ -208,6 +208,4 @@ void Rivet_ProcessorCleanup (rivet_thread_private* private)
 
         i++;
     } 
-
-    apr_pool_destroy(private->pool);
 }


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