You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by ka...@apache.org on 2009/05/07 04:27:57 UTC

svn commit: r772488 - in /tcl/rivet/trunk: ChangeLog src/apache-1/mod_rivet.c src/apache-2/mod_rivet.c src/rivetChannel.c

Author: karl
Date: Thu May  7 02:27:56 2009
New Revision: 772488

URL: http://svn.apache.org/viewvc?rev=772488&view=rev
Log:
* src/apache-2/mod_rivet.c: When Rivet was shutting down and per-vhost
  separate virtual interpreters were in use, the shutdown code deleted
  the master interpreter and all of the slave interpreters using
  Tcl_DepeteInterp().  This was an error as it should only delete the
  mater interpreter, as deleting the master interpreter causes its
  slaves to be deleted. It now does this.  (Had it checked using
  Tcl_InterpDeleted to see if the interpreter was already marked as
  deleted, it probably would have been OK.)

* src/rivetChannel.c - update Tcl channel handler to channel version 4.

Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/src/apache-1/mod_rivet.c
    tcl/rivet/trunk/src/apache-2/mod_rivet.c
    tcl/rivet/trunk/src/rivetChannel.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=772488&r1=772487&r2=772488&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Thu May  7 02:27:56 2009
@@ -1,4 +1,16 @@
 2009-05-05 Karl Lehenbauer <ka...@apache.org>
+    * src/apache-2/mod_rivet.c: When Rivet is shutting down and per-vhost
+      separate virtual interpreters were in use, the shutdown code deleted
+      the master interpreter and all of the slave interpreters using
+      Tcl_DepeteInterp().  This was an error as it should only delete the
+      mater interpreter, as deleting the master interpreter causes its
+      slaves to be deleted. It now does this.  (Had it checked using
+      Tcl_InterpDeleted to see if the interpreter was already marked as
+      deleted, it probably would have been OK.)
+
+    * src/rivetChannel.c - update Tcl channel handler to channel version 4.
+
+2009-05-05 Karl Lehenbauer <ka...@apache.org>
     * Add new Rivet Tcl command,apache_table, which can query, get and set
       values in the Apache "notes", "headers_in", "headers_out",
       "err_headers_out" and "subprocess_env" tables.

Modified: tcl/rivet/trunk/src/apache-1/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-1/mod_rivet.c?rev=772488&r1=772487&r2=772488&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-1/mod_rivet.c Thu May  7 02:27:56 2009
@@ -1466,17 +1466,21 @@
 		ap_log_error(APLOG_MARK, APLOG_ERR, s, "%s",
 			     Tcl_GetVar(rsc->server_interp, "errorInfo", 0));
 	    }
+	}
+	sr = sr->next;
 
-	/*
-	 * Upon child exit we delete each interpreter before the caller 
-	 * uses Tcl_Finalize 
-	 */
-
-	    if (!init) {
-	    	Tcl_DeleteInterp(rsc->server_interp);
+	if (!init) {
+	    /*
+	     * Upon child exit we delete the master interpreter before the 
+	     * caller invokes Tcl_Finalize.  Even if we're running separate
+	     * virtual interpreters, we don't delete the slaves
+	     * as deleting the master implicitly deltes its slave interpreters.
+	     */
+	    rsc = RIVET_SERVER_CONF(s->module_config);
+	    if (!Tcl_InterpDeleted (rsc->server_interp)) {
+		Tcl_DeleteInterp(rsc->server_interp);
 	    }
 	}
-	sr = sr->next;
     }
 }
 

Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.c?rev=772488&r1=772487&r2=772488&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Thu May  7 02:27:56 2009
@@ -309,6 +309,7 @@
     rivet_server_conf *conf = Rivet_GetConf(req);
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
+    Tcl_Preserve (interp);
     if ( Tcl_EvalObjEx(interp, outbuf, 0) == TCL_ERROR ) {
         Tcl_Obj *errscript;
         Tcl_Obj *errorCodeListObj;
@@ -380,6 +381,7 @@
     }
     TclWeb_PrintHeaders(globals->req);
     Tcl_Flush(*(conf->outchannel));
+    Tcl_Release(interp);
 
     return TCL_OK;
 }
@@ -837,6 +839,7 @@
     rivet_interp_globals *globals = NULL;
 
     ap_assert (interp != (Tcl_Interp *)NULL);
+    Tcl_Preserve (interp);
 
     /* Create TCL commands to deal with Apache's BUFFs. */
     rsc->outchannel = apr_pcalloc(p, sizeof(Tcl_Channel));
@@ -863,7 +866,7 @@
      * 
      * This is the old call for setting up the tcl environment.
      *
-     * if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
+     * if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL)
      * 
      * We may revert to it if we can devise a mechanism that
      * links a specific installation to RivetTcl's version
@@ -879,8 +882,10 @@
      * won't send any result packets to the browser unless the Rivet
      * programmer does a "flush stdout" or the page is completed.
      */
-    Tcl_SetChannelOption(interp, *(rsc->outchannel), "-buffersize", "1000000");
+    // Tcl_SetChannelOption(interp, *(rsc->outchannel), "-buffersize", "1000000");
+    Tcl_SetChannelBufferSize (*(rsc->outchannel), 1000000);
     Tcl_RegisterChannel(interp, *(rsc->outchannel));
+    Tcl_Release(interp);
 }
 
 
@@ -1290,6 +1295,7 @@
                 ( sr == s || rsc->separate_virtual_interps ||
                   function != parentfunction))
         {
+	    Tcl_Preserve (rsc->server_interp);
             if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
                 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
                         errmsg, Tcl_GetString(function));
@@ -1300,18 +1306,23 @@
 		        "errorInfo: %s",
                         Tcl_GetVar(rsc->server_interp, "errorInfo", 0));
             }
-
-	/*
-	 * Upon child exit we delete each interpreter before the caller 
-	 * uses Tcl_Finalize 
-	 */
-
-	    if (!init) {
-	    	Tcl_DeleteInterp(rsc->server_interp);
-	    }
+	    Tcl_Release (rsc->server_interp);
 
         }
         sr = sr->next;
+
+	if (!init) {
+	    /*
+	     * Upon child exit we delete the master interpreter before the 
+	     * caller invokes Tcl_Finalize.  Even if we're running separate
+	     * virtual interpreters, we don't delete the slaves
+	     * as deleting the master implicitly deltes its slave interpreters.
+	     */
+	    rsc = RIVET_SERVER_CONF(s->module_config);
+	    if (!Tcl_InterpDeleted (rsc->server_interp)) {
+		Tcl_DeleteInterp(rsc->server_interp);
+	    }
+	}
     }
 }
 /*
@@ -1447,8 +1458,7 @@
 			interpCount++);
 
                 /* Separate virtual interps. */
-                myrsc->server_interp = Tcl_CreateSlave(interp,
-                        slavename, 0);
+                myrsc->server_interp = Tcl_CreateSlave(interp, slavename, 0);
 		if (myrsc->server_interp == NULL) {
 		    ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
 			          "slave interp create failed: %s",

Modified: tcl/rivet/trunk/src/rivetChannel.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/rivetChannel.c?rev=772488&r1=772487&r2=772488&view=diff
==============================================================================
--- tcl/rivet/trunk/src/rivetChannel.c (original)
+++ tcl/rivet/trunk/src/rivetChannel.c Thu May  7 02:27:56 2009
@@ -84,17 +84,21 @@
 }
 
 Tcl_ChannelType RivetChan = {
-    "apache_channel",
-    NULL,
-    closeproc,
-    inputproc,
-    outputproc,
-    NULL,
-    setoptionproc,
-    NULL,
-    watchproc,
-    gethandleproc,
-    NULL,
-    NULL
+    "apache_channel",           /* typeName */
+    TCL_CHANNEL_VERSION_4,      /* channel type version */
+    closeproc,                  /* close proc */
+    inputproc,                  /* input proc */
+    outputproc,                 /* output proc */
+    NULL,                       /* seek proc - can be null */
+    setoptionproc,              /* set option proc - can be null */
+    NULL,                       /* get option proc - can be null */
+    watchproc,                  /* watch proc */
+    gethandleproc,              /* get handle proc */
+    NULL,                       /* close 2 proc - can be null */
+    NULL,                       /* block mode proc - can be null */
+    NULL,                       /* flush proc - can be null */
+    NULL,                       /* handler proc - can be null */
+    NULL,                       /* wide seek proc - can be null if seekproc is*/
+    NULL                        /* thread action proc - can be null */
 };
 



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