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 2016/11/07 11:55:04 UTC

svn commit: r1768503 - in /tcl/rivet/trunk: ./ rivet/ src/mod_rivet_ng/

Author: mxmanghi
Date: Mon Nov  7 11:55:03 2016
New Revision: 1768503

URL: http://svn.apache.org/viewvc?rev=1768503&view=rev
Log:

    highly experimental code with the new request processing model

    * src/mod_rivet/rivetCore.c: changed also code
    of command ::rivet::parse, now handling the
    cache and calling directly Tcl
    * src/mod_rivet/mod_rivet_generator.c: now
    calling Tcl_EvalObjEx instead of Rivet_ParseExec
    * src/mod_rivet/mod_rivet_common.c: now initializing
    the thread interpreter private cache with
    the new calls to the cache handler
    * rivet/init.tcl.in: tested also call to AbortScript



Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/rivet/init.tcl
    tcl/rivet/trunk/rivet/init.tcl.in
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.c
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.h
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.c
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.h
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_common.c
    tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_generator.c
    tcl/rivet/trunk/src/mod_rivet_ng/rivetCore.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Mon Nov  7 11:55:03 2016
@@ -1,3 +1,14 @@
+2016-11-07 Massimo Manghi <mx...@apache.org>
+    * src/mod_rivet/rivetCore.c: changed also code
+    of command ::rivet::parse, now handling the
+    cache and calling directly Tcl
+    * src/mod_rivet/mod_rivet_generator.c: now
+    calling Tcl_EvalObjEx instead of Rivet_ParseExec
+    * src/mod_rivet/mod_rivet_common.c: now initializing
+    the thread interpreter private cache with
+    the new calls to the cache handler
+    * rivet/init.tcl.in: tested also call to AbortScript
+
 2016-11-03 Massimo Manghi <mx...@apache.org>
     * src/mod_rivet/mod_rivet_cache.[c|h]: new file
     for the cache code created to have uniform file structure

Modified: tcl/rivet/trunk/rivet/init.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/init.tcl?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/init.tcl (original)
+++ tcl/rivet/trunk/rivet/init.tcl Mon Nov  7 11:55:03 2016
@@ -108,10 +108,22 @@ namespace eval ::Rivet {
 
     proc request_handling {} {
         ::try {
-            #<content-generation-script>
-        } trap {RIVET ABORTPAGE} {
-            #<abort-script>
-        } trap {RIVET THREAD_EXIT} {
+
+            puts "<h2>New request processing</h2>"
+            eval [::rivet::url_script]
+
+        } trap {RIVET ABORTPAGE} {::rivet::error_code ::rivet::error_options} {
+
+            puts "<h2>New request processing calls AbortScript</h2>"
+            puts "<h4>Error code and options: $::rivet::error_code $::rivet::error_options</h2>"
+            set abort_script [::rivet::inspect AbortScript]
+            if {![string equal $abort_script "undefined"} {
+
+                eval $abort_script
+
+            }
+
+        } trap {RIVET THREAD_EXIT} {::rivet::error_code ::rivet::error_options} {
             #<sudden-exit-script>
         } on error {::rivet::error_code ::rivet::error_options} {
 	        #<error-script>
@@ -123,6 +135,7 @@ namespace eval ::Rivet {
     ###
     ## The main initialization procedure for Rivet.
     ###
+
     proc init {} {
         global auto_path
         global server

Modified: tcl/rivet/trunk/rivet/init.tcl.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/init.tcl.in?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/init.tcl.in (original)
+++ tcl/rivet/trunk/rivet/init.tcl.in Mon Nov  7 11:55:03 2016
@@ -108,10 +108,22 @@ namespace eval ::Rivet {
 
     proc request_handling {} {
         ::try {
-            #<content-generation-script>
-        } trap {RIVET ABORTPAGE} {
-            #<abort-script>
-        } trap {RIVET THREAD_EXIT} {
+
+            puts "<h2>New request processing</h2>"
+            eval [::rivet::url_script]
+
+        } trap {RIVET ABORTPAGE} {::rivet::error_code ::rivet::error_options} {
+
+            puts "<h2>New request processing calls AbortScript</h2>"
+            puts "<h4>Error code and options: $::rivet::error_code $::rivet::error_options</h2>"
+            set abort_script [::rivet::inspect AbortScript]
+            if {![string equal $abort_script "undefined"} {
+
+                eval $abort_script
+
+            }
+
+        } trap {RIVET THREAD_EXIT} {::rivet::error_code ::rivet::error_options} {
             #<sudden-exit-script>
         } on error {::rivet::error_code ::rivet::error_options} {
 	        #<error-script>
@@ -123,6 +135,7 @@ namespace eval ::Rivet {
     ###
     ## The main initialization procedure for Rivet.
     ###
+
     proc init {} {
         global auto_path
         global server

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.c?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.c Mon Nov  7 11:55:03 2016
@@ -55,6 +55,7 @@
 #include "apache_config.h"
 #include "rivet.h"
 #include "mod_rivet_common.h"
+#include "mod_rivet_generator.h"
 
 rivet_interp_globals    interp_globals;
 

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.h?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.h (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet.h Mon Nov  7 11:55:03 2016
@@ -21,8 +21,8 @@
 
 /* $Id$ */
 
-#ifndef _MOD_RIVET_H_
-#define _MOD_RIVET_H_
+#ifndef __mod_rivet_h__
+#define __mod_rivet_h__
 
 #include <apr_queue.h>
 #include <apr_tables.h>
@@ -200,6 +200,7 @@ typedef struct _thread_worker_private {
     request_rec*        r;                  /* current request_rec                  */
     TclWebRequest*      req;
     Tcl_Obj*            request_init;
+    Tcl_Obj*            request_processing; /* request processing central procedure */
     Tcl_Obj*            request_cleanup;
     rivet_server_conf*  running_conf;       /* running configuration                */
     running_scripts*    running;            /* (per request) running conf scripts   */

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.c?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.c Mon Nov  7 11:55:03 2016
@@ -148,18 +148,12 @@ char* Rivet_MakeCacheKey (apr_pool_t*
  *
  */
 
-Tcl_HashEntry* Rivet_CacheEntryLookup (rivet_thread_interp* rivet_interp,char* hashKey)
+Tcl_HashEntry* Rivet_CacheEntryLookup (rivet_thread_interp* rivet_interp,char* hashKey,int* isNew)
 {
     Tcl_HashEntry*  entry = NULL;
-    int             isNew = 0;
 
-    entry = Tcl_CreateHashEntry(rivet_interp->objCache, hashKey, &isNew);
-
-    if (isNew) {
-        return NULL;
-    } else {
-        return entry;
-    }
+    entry = Tcl_CreateHashEntry(rivet_interp->objCache, hashKey, isNew);
+    return entry;
 
 }
 

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.h?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.h (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_cache.h Mon Nov  7 11:55:03 2016
@@ -28,7 +28,7 @@ EXTERN char* Rivet_MakeCacheKey (apr_poo
                                                       time_t        mtime,
                                                       unsigned int  user_conf,
                                                       int           toplevel);
-EXTERN Tcl_HashEntry* Rivet_CacheEntryLookup (rivet_thread_interp* rivet_interp,char* hashKey);
+EXTERN Tcl_HashEntry* Rivet_CacheEntryLookup (rivet_thread_interp* rivet_interp,char* hashKey,int* isNew);
 EXTERN Tcl_Obj* Rivet_CacheFetchScript (Tcl_HashEntry* entry);
 EXTERN int Rivet_CacheStoreScript(rivet_thread_interp* rivet_interp, Tcl_HashEntry* entry, Tcl_Obj* script);
 

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_common.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_common.c?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_common.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_common.c Mon Nov  7 11:55:03 2016
@@ -402,9 +402,12 @@ rivet_thread_private* Rivet_CreatePrivat
     private->exit_status    = 0;
     private->abort_code     = NULL;
     private->request_init   = Tcl_NewStringObj("::Rivet::initialize_request\n", -1);
+    //private->request_processing = Tcl_NewStringObj("::Rivet::request_handling\n",-1);
+    private->request_processing = Tcl_NewStringObj("::Rivet::request_handling\n",-1);
     private->request_cleanup = Tcl_NewStringObj("::Rivet::cleanup_request\n", -1);
     Tcl_IncrRefCount(private->request_init);
     Tcl_IncrRefCount(private->request_cleanup);
+    Tcl_IncrRefCount(private->request_processing);
 
     apr_threadkey_private_set (private,rivet_thread_key);
     return private;

Modified: tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_generator.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_generator.c?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_generator.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/mod_rivet_generator.c Mon Nov  7 11:55:03 2016
@@ -721,9 +721,10 @@ Rivet_SendContent(rivet_thread_private *
 
     /* URL referenced script execution and exception handling */
 
-    if (Rivet_ParseExecFile (private, private->r->filename, 1) != TCL_OK)
+    if (Tcl_EvalObjEx(interp, private->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 */
 
         if (!private->page_aborting) 

Modified: tcl/rivet/trunk/src/mod_rivet_ng/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet_ng/rivetCore.c?rev=1768503&r1=1768502&r2=1768503&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet_ng/rivetCore.c (original)
+++ tcl/rivet/trunk/src/mod_rivet_ng/rivetCore.c Mon Nov  7 11:55:03 2016
@@ -201,6 +201,12 @@ TCL_CMD_HEADER( Rivet_Parse )
     char*                   filename;
     apr_status_t            stat_s;
     apr_finfo_t             finfo_b;
+    char*                   cache_key;
+    rivet_thread_interp*    rivet_interp;
+    Tcl_HashEntry*          entry  = NULL;
+    Tcl_Obj*                script = NULL;
+    int                     result;
+    int                     isNew;
 
     THREAD_PRIVATE_DATA(private)
     CHECK_REQUEST_REC(private,"::rivet::parse")
@@ -253,7 +259,36 @@ TCL_CMD_HEADER( Rivet_Parse )
         return TCL_ERROR;
     }
 
-    return Rivet_ParseExecFile(private,filename,0);
+    /* */
+
+    cache_key = 
+        Rivet_MakeCacheKey( private->pool,
+                            private->r->filename,
+                            finfo_b.ctime,finfo_b.mtime,
+                            IS_USER_CONF(private->running_conf),0);
+
+    rivet_interp = RIVET_PEEK_INTERP(private,private->running_conf);
+    entry = Rivet_CacheEntryLookup (rivet_interp,cache_key,&isNew);
+
+    if (isNew)
+    {
+        script = Tcl_NewObj();
+        Tcl_IncrRefCount(script);
+
+        result = Rivet_GetRivetFile(filename,0,script,interp);
+        if (result != TCL_OK)
+        {
+            Tcl_AddErrorInfo(interp,apr_pstrcat(private->pool,"Could not read file ",filename,NULL));
+            return result;
+        }
+        
+        Rivet_CacheStoreScript(rivet_interp,entry,script);
+    } else {
+        script = Rivet_CacheFetchScript(entry);
+    }
+
+    return Tcl_EvalObjEx(interp,script,0); 
+    //return Rivet_ParseExecFile(private,filename,0);
 }
 
 /*
@@ -1760,6 +1795,7 @@ TCL_CMD_HEADER( Rivet_UrlScript )
     unsigned int         user_conf; 
     time_t               ctime;
     time_t               mtime;
+    int                  isNew;
 
     THREAD_PRIVATE_DATA(private)
     CHECK_REQUEST_REC(private,"::rivet::url_script")
@@ -1771,8 +1807,8 @@ TCL_CMD_HEADER( Rivet_UrlScript )
     mtime = private->r->finfo.mtime;
     cache_key = Rivet_MakeCacheKey(private->pool,private->r->filename,ctime,mtime,user_conf,1);
 
-    entry = Rivet_CacheEntryLookup (rivet_interp,cache_key);
-    if (entry == NULL)
+    entry = Rivet_CacheEntryLookup (rivet_interp,cache_key,&isNew);
+    if (isNew)
     {
         Tcl_Interp*     interp;
         



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