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/09/26 23:09:31 UTC

svn commit: r1627887 - in /tcl/rivet/trunk: ChangeLog src/experimental/apache_config.c src/experimental/mod_rivet.c src/experimental/mod_rivet.h tests/inspect.test tests/rivet.test tests/virtualhost.test

Author: mxmanghi
Date: Fri Sep 26 21:09:30 2014
New Revision: 1627887

URL: http://svn.apache.org/r1627887
Log:
    * src/experimental/mod_rivet.c: Add user scripts handling. Fixed bug in per dir and per user
    scripts when virtual interpreters are off.
    * src/experimental/mod_rivet.h: add macros for user configuration flags handling
    * src/experimental/apache_config.h: add user configuration handling
    * tests/inspect.test: trimming tests in order to make them independent for the final CR. 
    Carriage returns should now be appended when needed
    * tests/virtualhost.test: adding returned string space class character trimming
    * tests/rivet.test: changing localhost into 127.0.0.1 as it breaks in certain cases


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/src/experimental/apache_config.c
    tcl/rivet/trunk/src/experimental/mod_rivet.c
    tcl/rivet/trunk/src/experimental/mod_rivet.h
    tcl/rivet/trunk/tests/inspect.test
    tcl/rivet/trunk/tests/rivet.test
    tcl/rivet/trunk/tests/virtualhost.test

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Fri Sep 26 21:09:30 2014
@@ -1,3 +1,13 @@
+2014-09-26 Massimo Manghi <mx...@apache.org>
+    * src/experimental/mod_rivet.c: Add user scripts handling. Fixed bug in per dir and per user
+    scripts when virtual interpreters are off.
+    * src/experimental/mod_rivet.h: add macros for user configuration flags handling
+    * src/experimental/apache_config.h: add user configuration handling
+    * tests/inspect.test: trimming tests in order to make them independent for the final CR. 
+    Carriage returns should now be appended when needed
+    * tests/virtualhost.test: adding returned string space class character trimming
+    * tests/rivet.test: changing localhost into 127.0.0.1 as it breaks in certain cases
+    
 2014-09-08 Massimo Manghi <mx...@apache.org>
     * src/experimental/mod_rivet.c: handling per dir configurations that have no Rivet directives
     in them, thus leaving the 'path' field NULL.

Modified: tcl/rivet/trunk/src/experimental/apache_config.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/apache_config.c?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/apache_config.c (original)
+++ tcl/rivet/trunk/src/experimental/apache_config.c Fri Sep 26 21:09:30 2014
@@ -81,15 +81,13 @@ static char*
 Rivet_AppendStringToConf (char* p,const char* string,apr_pool_t *pool)
 {
 
-    if (p == NULL)
-    {
-        return apr_pstrcat(pool,apr_pstrdup(pool,string),"\n",NULL);
-    }
-    else
-    {
-        return apr_pstrcat(pool,p,string,"\n",NULL);
+    if (p == NULL) { 
+        p = apr_pstrdup(pool,string);
+    } else {
+        p = apr_pstrcat(pool,p,"\n",string,NULL);
     }
 
+    return p;
 }
 
 /*
@@ -112,31 +110,34 @@ Rivet_AppendStringToConf (char* p,const 
 static const char *
 Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc, const char *script, const char *string)
 {
-    Tcl_Obj *objarg = NULL;
+    char** c = NULL;
 
     if ( STREQU( script, "GlobalInitScript" ) ) {
-        rsc->rivet_global_init_script = Rivet_AppendStringToConf(rsc->rivet_global_init_script,string,pool);
+        c = &rsc->rivet_global_init_script;
     } else if ( STREQU( script, "ChildInitScript" ) ) {
-        rsc->rivet_child_init_script = Rivet_AppendStringToConf(rsc->rivet_child_init_script,string,pool);
+        c = &rsc->rivet_child_init_script;
     } else if ( STREQU( script, "ChildExitScript" ) ) {
-        rsc->rivet_child_exit_script = Rivet_AppendStringToConf(rsc->rivet_child_exit_script,string,pool);
+        c = &rsc->rivet_child_exit_script;
     } else if ( STREQU( script, "BeforeScript" ) ) {
-        rsc->rivet_before_script = Rivet_AppendStringToConf(rsc->rivet_before_script,string,pool);
+        c = &rsc->rivet_before_script;
     } else if ( STREQU( script, "AfterScript" ) ) {
-        rsc->rivet_after_script = Rivet_AppendStringToConf(rsc->rivet_after_script,string,pool);
+        c = &rsc->rivet_after_script;
     } else if ( STREQU( script, "ErrorScript" ) ) {
-        rsc->rivet_error_script = Rivet_AppendStringToConf(rsc->rivet_error_script,string,pool);
+        c = &rsc->rivet_error_script;
     } else if ( STREQU( script, "AbortScript" ) ) {
-        rsc->rivet_abort_script = Rivet_AppendStringToConf(rsc->rivet_abort_script,string,pool);
+        c = &rsc->rivet_abort_script;
     } else if ( STREQU( script, "AfterEveryScript" ) ) {
-        rsc->after_every_script = Rivet_AppendStringToConf(rsc->after_every_script,string,pool);
+        c = &rsc->after_every_script;
     } else if ( STREQU( script, "ServerInitScript" ) ) {
-        rsc->rivet_server_init_script = Rivet_AppendStringToConf(rsc->rivet_server_init_script,string,pool);
+        c = &rsc->rivet_server_init_script;
+    } else {
+        return NULL;
     }
+   
+    *c = Rivet_AppendStringToConf(*c,string,pool);
 
-    if( !objarg ) return string;
+    return *c;
 
-    return Tcl_GetStringFromObj( objarg, NULL );
 }
 
 /* 
@@ -214,7 +215,7 @@ Rivet_CopyConfig( rivet_server_conf *old
     newrsc->rivet_error_script = oldrsc->rivet_error_script;
     newrsc->rivet_abort_script = oldrsc->rivet_abort_script;
     newrsc->after_every_script = oldrsc->after_every_script;
-    newrsc->user_scripts_updated = oldrsc->user_scripts_updated;
+    //newrsc->user_scripts_updated = oldrsc->user_scripts_updated;
     newrsc->rivet_default_error_script = oldrsc->rivet_default_error_script;
     newrsc->default_cache_size = oldrsc->default_cache_size;
     newrsc->upload_max = oldrsc->upload_max;
@@ -228,6 +229,8 @@ Rivet_CopyConfig( rivet_server_conf *old
     newrsc->rivet_user_vars = oldrsc->rivet_user_vars;
     newrsc->idx = oldrsc->idx;
     newrsc->path = oldrsc->path;
+    //newrsc->user_conf = oldrsc->user_conf;
+    newrsc->user_scripts_status = oldrsc->user_scripts_status;
 }
 
 /*
@@ -280,8 +283,8 @@ Rivet_MergeDirConfigVars(apr_pool_t *p, 
     new->after_every_script = add->after_every_script ?
         add->after_every_script : base->after_every_script;
 
-    new->user_scripts_updated = add->user_scripts_updated ?
-        add->user_scripts_updated : base->user_scripts_updated;
+    //new->user_scripts_updated = add->user_scripts_updated ?
+    //    add->user_scripts_updated : base->user_scripts_updated;
 
     new->upload_dir = add->upload_dir ? add->upload_dir : base->upload_dir;
 
@@ -300,6 +303,8 @@ Rivet_MergeDirConfigVars(apr_pool_t *p, 
     }
 
     RIVET_CONF_SELECT(new,base,add,path)
+    new->user_scripts_status = add->user_scripts_status;
+    //new->user_conf = add->user_conf;
 }
 
 /*
@@ -474,7 +479,7 @@ Rivet_CreateConfig(apr_pool_t *p, server
     rsc->rivet_abort_script         = NULL;
     rsc->after_every_script         = NULL;
 
-    rsc->user_scripts_updated = 0;
+    rsc->user_scripts_status        = 0;
 
     rsc->rivet_default_error_script = "::Rivet::handle_error";
 
@@ -491,7 +496,6 @@ Rivet_CreateConfig(apr_pool_t *p, server
     rsc->rivet_user_vars            = (apr_table_t *) apr_table_make ( p, 4 );
     rsc->idx                        = 0;
     rsc->path                       = NULL;
-
     return rsc;
 }
 
@@ -520,17 +524,20 @@ Rivet_UserConf( cmd_parms *cmd, 
         return "Rivet Error: RivetUserConf requires two arguments";
     }
 
-    /* We have modified these scripts. */
+    /* We have modified these scripts.  */
     /* This is less than ideal though, because it will get set to 1
-     * every time - FIXME. */
+     * every time - FIXME.              */
+
+    //rdc->user_scripts_updated = 1;
+    //rdc->user_conf            = 1;
 
-    rdc->user_scripts_updated = 1;
+    rdc->user_scripts_status |= (USER_SCRIPTS_UPDATED | USER_SCRIPTS_CONF);
 
     if (STREQU(var,"BeforeScript")      || 
         STREQU(var,"AfterScript")       || 
         STREQU(var,"AbortScript")       ||
         STREQU(var,"AfterEveryScript")  ||
-        STREQU(var,"UploadDirectory")  ||
+        STREQU(var,"UploadDirectory")   ||
         STREQU(var,"ErrorScript"))
     {
         apr_table_set( rdc->rivet_user_vars, var, 
@@ -567,8 +574,7 @@ Rivet_UserConf( cmd_parms *cmd, 
  */
 
 const char *
-Rivet_DirConf( cmd_parms *cmd, void *vrdc, 
-               const char *var, const char *val )
+Rivet_DirConf(cmd_parms *cmd,void *vrdc,const char *var,const char *val)
 {
     const char *string = val;
     rivet_server_conf *rdc = (rivet_server_conf *)vrdc;
@@ -579,9 +585,12 @@ Rivet_DirConf( cmd_parms *cmd, void *vrd
         return "Rivet Error: RivetDirConf requires two arguments";
     }
 
-    if( STREQU( var, "UploadDirectory" ) ) {
+    if(STREQU(var, "UploadDirectory")) 
+    {
         rdc->upload_dir = val;
-    } else {
+    } 
+    else 
+    {
         if (STREQU(var,"BeforeScript")      || 
             STREQU(var,"AfterScript")       || 
             STREQU(var,"AbortScript")       ||
@@ -628,8 +637,7 @@ Rivet_DirConf( cmd_parms *cmd, void *vrd
  */
 
 const char *
-Rivet_ServerConf( cmd_parms *cmd, void *dummy, 
-                  const char *var, const char *val )
+Rivet_ServerConf(cmd_parms *cmd,void *dummy,const char *var,const char *val)
 {
     server_rec *s = cmd->server;
     rivet_server_conf *rsc = RIVET_SERVER_CONF(s->module_config);
@@ -658,7 +666,7 @@ Rivet_ServerConf( cmd_parms *cmd, void *
     }
 
     if (string != NULL) apr_table_set( rsc->rivet_server_vars, var, string );
-    return( NULL );
+    return(NULL);
 }
 
 /* apache_config.c */

Modified: tcl/rivet/trunk/src/experimental/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/mod_rivet.c?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/experimental/mod_rivet.c Fri Sep 26 21:09:30 2014
@@ -71,6 +71,56 @@ void  Rivet_PerInterpInit(Tcl_Interp* in
 
 #define ERRORBUF_SZ     256
 
+/*
+ *-----------------------------------------------------------------------------
+ * Rivet_CreateCache --
+ *
+ * Arguments:
+ *     rsc: pointer to a server_rec structure
+ *
+ * Results:
+ *     None
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void Rivet_CreateCache (apr_pool_t *p, vhost_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));
+    Tcl_InitHashTable(interp_obj->objCache, TCL_STRING_KEYS);
+}
+
+/*
+ * Rivet_DuplicateVhostInterp
+ *
+ *
+ */
+
+static vhost_interp* 
+Rivet_DuplicateVHostInterp(apr_pool_t* pool, vhost_interp* source_obj)
+{
+    vhost_interp* interp_obj = apr_pcalloc(pool,sizeof(vhost_interp));
+
+    interp_obj->interp      = source_obj->interp;
+    interp_obj->cache_free  = source_obj->cache_free;
+    interp_obj->cache_size  = source_obj->cache_size;
+
+    /* TODO: decouple cache by creating a cache object and store only a pointer to it */
+
+    if (interp_obj->cache_size) {
+        Rivet_CreateCache(pool,interp_obj); 
+    }
+
+    interp_obj->pool            = source_obj->pool;
+    interp_obj->scripts         = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts));
+    interp_obj->per_dir_scripts = apr_hash_make(pool); 
+    interp_obj->flags           = source_obj->flags;
+    return interp_obj;
+}
+
  /* XXX: the pool passed to Rivet_NewVHostInterp must be the private pool of
   * a rivet_thread_private object 
   */
@@ -119,16 +169,13 @@ vhost_interp* Rivet_NewVHostInterp(apr_p
     // Initialize cache structures
 
     if (interp_obj->cache_size) {
-        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);
+        Rivet_CreateCache(pool,interp_obj); 
     }
 
     interp_obj->flags = 0;
 
-    interp_obj->scripts         = (running_scripts *) apr_pcalloc(interp_obj->pool,sizeof(running_scripts));
-    interp_obj->per_dir_scripts = apr_hash_make(interp_obj->pool); 
+    interp_obj->scripts         = (running_scripts *) apr_pcalloc(pool,sizeof(running_scripts));
+    interp_obj->per_dir_scripts = apr_hash_make(pool); 
 
     return interp_obj;
 }
@@ -206,15 +253,19 @@ rivet_thread_private* Rivet_VirtualHosts
         {
             rivet_interp = Rivet_NewVHostInterp(private->pool);
             Tcl_RegisterChannel(rivet_interp->interp,*private->channel);
+        } 
+        else
+        {
+            rivet_interp = Rivet_DuplicateVHostInterp(private->pool,root_interp);           
         }
 
         /* these 5 lines initialize the interpreter base running scripts */
 
-        RIVET_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_before_script);
-        RIVET_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_after_script);
-        RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_error_script);
-        RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,rivet_abort_script);
-        RIVET_NULL_SCRIPT_INIT (rivet_interp->scripts,myrsc,after_every_script);
+        RIVET_SCRIPT_INIT (private->pool,rivet_interp->scripts,myrsc,rivet_before_script);
+        RIVET_SCRIPT_INIT (private->pool,rivet_interp->scripts,myrsc,rivet_after_script);
+        RIVET_NULL_SCRIPT_INIT (private->pool,rivet_interp->scripts,myrsc,rivet_error_script);
+        RIVET_NULL_SCRIPT_INIT (private->pool,rivet_interp->scripts,myrsc,rivet_abort_script);
+        RIVET_NULL_SCRIPT_INIT (private->pool,rivet_interp->scripts,myrsc,after_every_script);
 
         private->interps[myrsc->idx] = rivet_interp;
 
@@ -369,9 +420,8 @@ Rivet_SendContent(rivet_thread_private *
     int ctype;
     Tcl_Interp*             interp;
     rivet_interp_globals*   globals = NULL;
-    request_rec*            r     = private->r;
-    void*                   dconf = r->per_dir_config;
     vhost_interp*           interp_obj;
+    request_rec*            r = private->r;
 #ifdef USE_APACHE_RSC
     //rivet_server_conf    *rsc = NULL;
 #else
@@ -395,58 +445,62 @@ Rivet_SendContent(rivet_thread_private *
     /* the interp index in the private data can not be changed by a config merge */
 
     interp_obj = private->interps[private->running_conf->idx];
-    if (dconf)
+    private->running = interp_obj->scripts;
+
+    if (r->per_dir_config)
     {
-        rivet_server_conf*  rdc         = NULL;
+        rivet_server_conf* rdc = NULL;
 
-        rdc = RIVET_SERVER_CONF(dconf); 
+        rdc = RIVET_SERVER_CONF(r->per_dir_config); 
 
-        if (rdc == NULL)
+        if ((rdc != NULL) && (rdc->path))
         {
-            /* a Directory sections exists but there were no Rivet configuration directives in it */
-
-            private->running = interp_obj->scripts;
+            /* Let's check if a scripts object is already stored in the per-dir hash table */
 
-        }
-        else
-        {
+            private->running = 
+                (running_scripts *) apr_hash_get (interp_obj->per_dir_scripts,rdc->path,strlen(rdc->path));
 
-            if (rdc->path == NULL)
+            if (private->running == NULL)
             {
-                private->running = interp_obj->scripts;
+                rivet_server_conf*  newconfig   = NULL;
+                running_scripts*    scripts     = 
+                            (running_scripts *) apr_pcalloc (private->pool,sizeof(running_scripts));
+
+                newconfig = RIVET_NEW_CONF(r->pool);
+
+                Rivet_CopyConfig( private->running_conf, newconfig );
+                Rivet_MergeDirConfigVars( r->pool, newconfig, private->running_conf, rdc );
+                private->running_conf = newconfig;
+
+                RIVET_SCRIPT_INIT (private->pool,scripts,newconfig,rivet_before_script);
+                RIVET_SCRIPT_INIT (private->pool,scripts,newconfig,rivet_after_script);
+                RIVET_NULL_SCRIPT_INIT (private->pool,scripts,newconfig,rivet_error_script);
+                RIVET_NULL_SCRIPT_INIT (private->pool,scripts,newconfig,rivet_abort_script);
+                RIVET_NULL_SCRIPT_INIT (private->pool,scripts,newconfig,after_every_script);
+     
+                apr_hash_set (interp_obj->per_dir_scripts,rdc->path,strlen(rdc->path),scripts);
+               
+                private->running = scripts;
             }
-            else
-            {
+        }
 
-            /* Let's check if a scripts object is already stored in the per-dir hash table */
+        if (USER_CONF_UPDATED(rdc))
+        {
+            rivet_server_conf*  newconfig   = NULL;
+            private->running = (running_scripts *) apr_pcalloc (private->pool,sizeof(running_scripts));
 
-                private->running = 
-                    (running_scripts *) apr_hash_get (interp_obj->per_dir_scripts,rdc->path,strlen(rdc->path));
+            newconfig = RIVET_NEW_CONF(r->pool);
 
-                if (private->running == NULL)
-                {
-                    rivet_server_conf*  newconfig   = NULL;
-                    running_scripts*    scripts     = 
-                                (running_scripts *) apr_pcalloc (interp_obj->pool,sizeof(running_scripts));
-
-                    newconfig = RIVET_NEW_CONF(r->pool);
-
-                    Rivet_CopyConfig( private->running_conf, newconfig );
-                    Rivet_MergeDirConfigVars( r->pool, newconfig, private->running_conf, rdc );
-                    private->running_conf = newconfig;
-
-                    RIVET_SCRIPT_INIT (scripts,newconfig,rivet_before_script);
-                    RIVET_SCRIPT_INIT (scripts,newconfig,rivet_after_script);
-                    RIVET_NULL_SCRIPT_INIT (scripts,newconfig,rivet_error_script);
-                    RIVET_NULL_SCRIPT_INIT (scripts,newconfig,rivet_abort_script);
-                    RIVET_NULL_SCRIPT_INIT (scripts,newconfig,after_every_script);
-         
-                    apr_hash_set (interp_obj->per_dir_scripts,rdc->path,strlen(rdc->path),scripts);
-                   
-                    private->running = scripts;
+            Rivet_CopyConfig( private->running_conf, newconfig );
+            Rivet_MergeDirConfigVars( r->pool, newconfig, private->running_conf, rdc );
+            private->running_conf = newconfig;
+
+            RIVET_SCRIPT_INIT (r->pool,private->running,newconfig,rivet_before_script);
+            RIVET_SCRIPT_INIT (r->pool,private->running,newconfig,rivet_after_script);
+            RIVET_NULL_SCRIPT_INIT (r->pool,private->running,newconfig,rivet_error_script);
+            RIVET_NULL_SCRIPT_INIT (r->pool,private->running,newconfig,rivet_abort_script);
+            RIVET_NULL_SCRIPT_INIT (r->pool,private->running,newconfig,after_every_script);
 
-                }
-            }
         }
     }
     else
@@ -615,7 +669,7 @@ Rivet_SendContent(rivet_thread_private *
     }
 
     /* Reset globals */
-    Rivet_CleanupRequest( r );
+    Rivet_CleanupRequest(r);
 
     retval = OK;
 sendcleanup:
@@ -800,8 +854,8 @@ Rivet_ParseExecFile(rivet_thread_private
     Tcl_Obj*        outbuf  = NULL;
     Tcl_HashEntry*  entry   = NULL;
     Tcl_Interp*     interp;
-    time_t ctime;
-    time_t mtime;
+    time_t          ctime;
+    time_t          mtime;
     //rivet_server_conf *rsc;
 
     //rsc = Rivet_GetConf( private->r );
@@ -818,7 +872,7 @@ Rivet_ParseExecFile(rivet_thread_private
        doing caching on the modification time of the .htaccess files
        that concern us. FIXME */
 
-    if (private->running_conf->user_scripts_updated && (rivet_interp->cache_size != 0)) 
+    if (USER_CONF_UPDATED(private->running_conf) && (rivet_interp->cache_size != 0)) 
     {
         int ct;
         Tcl_HashEntry *delEntry;
@@ -830,15 +884,21 @@ Rivet_ParseExecFile(rivet_thread_private
             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;
             }
-            Tcl_DeleteHashEntry(delEntry);
 
-            free(rivet_interp->objCacheList[ct]);
-            rivet_interp->objCacheList[ct] = NULL;
             ct++;
         }
+        apr_pool_destroy(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;
     }
 
@@ -865,10 +925,13 @@ Rivet_ParseExecFile(rivet_thread_private
     /* Look for the script's compiled version.  If it's not found,
      * create it.
      */
+
     if (rivet_interp->cache_size)
     {
-        hashKey = (char*) apr_psprintf(private->r->pool, "%s%lx%lx%d", filename,
-                mtime, ctime, toplevel);
+        unsigned int user_conf = IS_USER_CONF(private->running_conf);
+
+        hashKey = (char*) apr_psprintf(private->r->pool, "%s%lx%lx%d-%d", filename,
+                mtime, ctime, toplevel,user_conf);
         entry = Tcl_CreateHashEntry(rivet_interp->objCache, hashKey, &isNew);
     }
 
@@ -935,21 +998,6 @@ Rivet_ParseExecFile(rivet_thread_private
         instead of removing the last entry in the cache (for what purpose after all??)
         we signal a 'cache full' condition
  */
-
- /*
-            Tcl_HashEntry *delEntry;
-            delEntry = Tcl_FindHashEntry(
-                            rivet_interp->objCache,
-                            rivet_interp->objCacheList[rivet_interp->cache_size - 1]);
-            Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
-            Tcl_DeleteHashEntry(delEntry);
-            free(rivet_interp->objCacheList[rivet_interp->cache_size - 1]);
-            memmove((rivet_interp->objCacheList) + 1, rivet_interp->objCacheList,
-                    sizeof(char *) * (rivet_interp->cache_size - 1));
-
-            rivet_interp->objCacheList[0] = (char*) malloc ((strlen(hashKey)+1) * sizeof(char));
-            strcpy (rivet_interp->objCacheList[0], hashKey);
- */
             
             if ((rivet_interp->flags & RIVET_CACHE_FULL) == 0)
             {
@@ -965,7 +1013,7 @@ Rivet_ParseExecFile(rivet_thread_private
         Tcl_IncrRefCount(outbuf);
     }
 
-    private->running_conf->user_scripts_updated = 0;
+    //private->running_conf->user_scripts_status &= ~(unsigned int)USER_SCRIPTS_UPDATED;
     {
         int res = 0;
 

Modified: tcl/rivet/trunk/src/experimental/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/mod_rivet.h?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/mod_rivet.h (original)
+++ tcl/rivet/trunk/src/experimental/mod_rivet.h Fri Sep 26 21:09:30 2014
@@ -77,8 +77,16 @@
 #define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
 #define MULTIPART_FORM_DATA 1
 
+#define USER_SCRIPTS_UPDATED 1
+#define USER_SCRIPTS_CONF    1<<1
+#define USER_SCRIPTS_MERGED  1<<2
+
+#define IS_USER_CONF(mc)        ((mc->user_scripts_status & USER_SCRIPTS_CONF) != 0)
+#define USER_CONF_UPDATED(mc)   ((mc->user_scripts_status & USER_SCRIPTS_UPDATED) != 0)
+#define USER_CONF_MERGED(mc)    ((mc->user_scripts_status & USER_SCRIPTS_MERGED) != 0)
+
 /* IMPORTANT: If you make any changes to the rivet_server_conf struct,
- * you need to make the appropriate modifications to Rivet_CopyConfig,
+ * you need to make the appropriate modinficationus to Rivet_CopyConfig,
  * Rivet_CreateConfig, Rivet_MergeConfig and so on. */
 
 module AP_MODULE_DECLARE_DATA rivet_module;
@@ -98,7 +106,9 @@ typedef struct _rivet_server_conf {
 
     /* This flag is used with the above directives. If any of them have changed, it gets set. */
 
-    int         user_scripts_updated;
+    unsigned int    user_scripts_status;
+
+    //int         user_scripts_updated;
 
     int             default_cache_size;
     int             upload_max;
@@ -114,6 +124,7 @@ typedef struct _rivet_server_conf {
     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 */
+    //int             user_conf;
 
     //Tcl_Interp *server_interp;        /* per server Tcl interpreter                         */
     //int*          cache_size;
@@ -305,8 +316,7 @@ EXTERN int Rivet_SendContent (rivet_thre
 EXTERN Tcl_Interp* Rivet_CreateTclInterp (server_rec* s);
 
 /* temporary content generation handler */
-
-EXTERN int RivetContent (rivet_thread_private* private);
+//EXTERN int RivetContent (rivet_thread_private* private);
 
 /* error code set by command 'abort_page' */
 
@@ -332,20 +342,22 @@ EXTERN int RivetContent (rivet_thread_pr
 #define RIVET_CONF_SELECT(selected,base,overlay,field) \
     selected->field = overlay->field ? overlay->field : base->field;
 
-#define RIVET_SCRIPT_INIT(running_script,rivet_conf_rec,objscript) \
+#define RIVET_CR_TERM(pool,string)  apr_pstrcat(pool,string,"\n",NULL)
+
+#define RIVET_SCRIPT_INIT(p,running_script,rivet_conf_rec,objscript) \
     if (rivet_conf_rec->objscript == NULL) {\
         running_script->objscript = Tcl_NewStringObj("",-1);\
     } else {\
-        running_script->objscript = Tcl_NewStringObj(rivet_conf_rec->objscript,-1);\
+        running_script->objscript = Tcl_NewStringObj(RIVET_CR_TERM(p,rivet_conf_rec->objscript),-1);\
     }\
     Tcl_IncrRefCount(running_script->objscript);
  
-#define RIVET_NULL_SCRIPT_INIT(running_script,rivet_conf_rec,objscript) \
+#define RIVET_NULL_SCRIPT_INIT(p,running_script,rivet_conf_rec,objscript) \
     if (rivet_conf_rec->objscript == NULL) {\
         running_script->objscript = NULL;\
     } else {\
-        running_script->objscript = Tcl_NewStringObj(rivet_conf_rec->objscript,-1);\
+        running_script->objscript = Tcl_NewStringObj(RIVET_CR_TERM(p,rivet_conf_rec->objscript),-1);\
         Tcl_IncrRefCount(running_script->objscript);\
-    }\
+    }
 
 #endif /* MOD_RIVET_H */

Modified: tcl/rivet/trunk/tests/inspect.test
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/inspect.test?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/inspect.test (original)
+++ tcl/rivet/trunk/tests/inspect.test Fri Sep 26 21:09:30 2014
@@ -4,28 +4,26 @@
             -c "RivetServerConf ChildInitScript \"set init 1\"" } {} {
         catch {
             set inspect_page [::http::geturl "${urlbase}inspect.tcl?p=childinit"]
-            set match [::http::data $inspect_page]
+            set match [string trim [::http::data $inspect_page]]
             ::http::cleanup $inspect_page
         }
     }
     set match
-} {set init 1
-}
+} {set init 1}
 
 ::tcltest::test inspect-1.2 {basic introspection} {
     apachetest::start { 
             -c "RivetServerConf ChildInitScript \"set init 1\"" } {} {
         catch {
             set inspect_page [::http::geturl "${urlbase}inspect.tcl"]
-            set match [::http::data $inspect_page]
+            set match [string trim [::http::data $inspect_page]]
             ::http::cleanup $inspect_page
         }
     }
     set match
-} {server {ChildInitScript {set init 1
-}}}
+} {server {ChildInitScript {set init 1}}}
 
-::tcltest::test inspect-1.2 {basic introspection} {
+::tcltest::test inspect-1.3 {basic introspection} {
     file copy -force inspect.tcl /tmp/
     apachetest::start {
         -c "DocumentRoot /tmp" } {} {

Modified: tcl/rivet/trunk/tests/rivet.test
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/rivet.test?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/rivet.test (original)
+++ tcl/rivet/trunk/tests/rivet.test Fri Sep 26 21:09:30 2014
@@ -59,15 +59,17 @@ if { $testgroup2 } {
 # These tests start the server on their own, or don't need the server
 # at all.
 
-if { $testgroup3 } {
-    foreach Test {
+set group3 {
         failtest.test
         broken.test
         config.test
         parsepackage.test
         virtualhost.test
         inspect.test 
-    } {
+    }
+
+if { $testgroup3 } {
+    foreach Test $group3 {
         puts "Running $Test"
         source $Test
     }

Modified: tcl/rivet/trunk/tests/virtualhost.test
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/tests/virtualhost.test?rev=1627887&r1=1627886&r2=1627887&view=diff
==============================================================================
--- tcl/rivet/trunk/tests/virtualhost.test (original)
+++ tcl/rivet/trunk/tests/virtualhost.test Fri Sep 26 21:09:30 2014
@@ -161,7 +161,7 @@ set vhostconf {
 
 # Format: directive, file, 2 regexps to match
 set configs {
-    ChildInitScript childinit.tcl "vhost2 hello world<br>\n::childinit2 exists<br>\n::childinit1 exists<br>\n" \
+    ChildInitScript childinit.tcl "vhost2 hello world<br>\n::childinit2 exists<br>\n::childinit1 exists<br>" \
                                   "vhost1 hello world<br>\n::childinit1 exists<br>\n::childinit2 exists<br>"
     BeforeScript beforescript.tcl "^beforescript2\nVirtual Host2 Test" "^beforescript1\nVirtual Host1 Test"
     AfterScript afterscript.tcl "afterscript2" "afterscript1"
@@ -187,17 +187,18 @@ ServerName vhost2
 " {
 	set page1 [::http::geturl "${urlbase}vhost2.rvt" -headers [list Host vhost2]]
 	set page2 [::http::geturl "${urlbase}vhost1.rvt" -headers [list Host vhost1]]
-	set data1 [::http::data $page1]
-	set data2 [::http::data $page2]
+	set data1 [string trim [::http::data $page1]]
+	set data2 [string trim [::http::data $page2]]
 	::http::cleanup $page1
 	::http::cleanup $page2
 }
-#puts "--$re1--\n--$data1--"
-#puts "--$re2--\n--$data2--"
+#puts "|$re1|\n#$data1#"
+#puts "|$re2|\n#$data2#"
 
-list [regexp $re1 $data1 match] [regexp $re1 $data1 match]
+list [regexp $re1 $data1 match] [regexp $re2 $data2 match]
 #list $data1 $data2
     } {1 1}
+    incr i
 }
 
 set configs {



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