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/08/16 16:27:09 UTC

svn commit: r1618366 - in /tcl/rivet/trunk: ChangeLog Makefile.in configure.ac src/experimental/mod_rivet.c src/experimental/rivet_worker_mpm.c

Author: mxmanghi
Date: Sat Aug 16 14:27:09 2014
New Revision: 1618366

URL: http://svn.apache.org/r1618366
Log:
    * src/experimental/mod_rivet.c: reinstated big mutex aroud Rivet_SendContent (where originally 
    Tcl_Mutex lock/unlock were called. The module is usable but way too slow wrt prefork because
    of the locking


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/Makefile.in
    tcl/rivet/trunk/configure.ac
    tcl/rivet/trunk/src/experimental/mod_rivet.c
    tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1618366&r1=1618365&r2=1618366&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Sat Aug 16 14:27:09 2014
@@ -1,3 +1,8 @@
+2014-08-16 Massimo Manghi <mx...@apache.org>
+    * src/experimental/mod_rivet.c: reinstated big mutex aroud Rivet_SendContent (where originally 
+    Tcl_Mutex lock/unlock were called. The module is usable but way too slow wrt prefork because
+    of the locking
+
 2014-08-15 Massimo Manghi <mx...@apache.org>
     * src/experimental/mod_rivet.c: Tcl protecting mutex localized in order to restrict as much as possible
     the protected code and reduce the size of the bottleneck. Still, this is not OK and the current implementation

Modified: tcl/rivet/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/Makefile.in?rev=1618366&r1=1618365&r2=1618366&view=diff
==============================================================================
--- tcl/rivet/trunk/Makefile.in (original)
+++ tcl/rivet/trunk/Makefile.in Sat Aug 16 14:27:09 2014
@@ -17,7 +17,7 @@
 #
 # top-level Makefile.am for Apache Rivet: gets turned into a Makefile.in by automake
 #
-# $Id: Makefile.am 1517859 2013-08-27 16:08:31Z mxmanghi $
+# $Id: Makefile.am 1616967 2014-08-09 15:29:07Z mxmanghi $
 #
 # 2007/12/25: Added target uninistall-local that removes the tcl stuff (mxmanghi)
 # 2010/06/22: target instal-data-local searches for pkgIndex.tcl files and deletes them

Modified: tcl/rivet/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/configure.ac?rev=1618366&r1=1618365&r2=1618366&view=diff
==============================================================================
--- tcl/rivet/trunk/configure.ac (original)
+++ tcl/rivet/trunk/configure.ac Sat Aug 16 14:27:09 2014
@@ -631,6 +631,25 @@ AC_DEFUN([HONOR_HEAD_REQUESTS],[
     fi
 ])
 
+AC_DEFUN([SINGLE_TCL_THREAD],[
+    AC_ARG_ENABLE(
+    single_thread,
+    [  --enable-single-thread Forces single Tcl thread in worker bridge ],
+    [ single_thread=$enable_single_thread ],
+    [ single_thread="no"]
+    )
+
+    AC_MSG_CHECKING(whether MPM bridge has to run a single thread)
+    if test "$single_thread" = "yes"; then
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(MPM_SINGLE_THREAD,1,[yes, MPM worker single thread])
+    else
+        AC_MSG_RESULT([no, maximal number of Tcl threads])
+        #AC_DEFINE(HEAD_REQUESTS,0,[Honor HEAD requests])
+    fi
+])
+
+
 # RIVET_COMMANDS_EXPORT (--enable-rivet-commands-export).
 # Enable export of commands in Rivet's namespace. Definining this symbols
 # sets the boolean configuration variable rivet_commands_export 
@@ -764,6 +783,7 @@ IMPORT_RIVET_COMMANDS
 APACHE_REQUEST
 RIVET_CORE_CMDS
 RIVET_CHANNEL
+SINGLE_TCL_THREAD
 
 # Let's separate the point version from the major and minor version
 # to build a Rivet version to be substituted as basic version for 

Modified: tcl/rivet/trunk/src/experimental/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/mod_rivet.c?rev=1618366&r1=1618365&r2=1618366&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/experimental/mod_rivet.c Sat Aug 16 14:27:09 2014
@@ -358,6 +358,7 @@ Rivet_SendContent(rivet_thread_private *
     }
 
     //Tcl_MutexLock(&sendMutex);
+    apr_thread_mutex_lock(module_globals->req_mutex);
 
     /* Set the global request req to know what we are dealing with in
      * case we have to call the PanicProc. */
@@ -447,8 +448,6 @@ Rivet_SendContent(rivet_thread_private *
         Tcl_IncrRefCount(request_init);
     }
 
-
-    apr_thread_mutex_lock(module_globals->req_mutex);
     if (Tcl_EvalObjEx(interp, request_init, 0) == TCL_ERROR)
     {
         ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server,
@@ -456,10 +455,8 @@ Rivet_SendContent(rivet_thread_private *
                             Tcl_GetStringResult(interp));
 
         retval = HTTP_INTERNAL_SERVER_ERROR;
-        apr_thread_mutex_unlock(module_globals->req_mutex);
         goto sendcleanup;
     }
-    apr_thread_mutex_unlock(module_globals->req_mutex);
 
     /* Apache Request stuff */
 
@@ -555,6 +552,7 @@ sendcleanup:
     /* We reset this pointer to signal we have terminated the request processing */
 
     globals->r = NULL;
+    apr_thread_mutex_unlock(module_globals->req_mutex);
 
     //Tcl_MutexUnlock(&sendMutex);
     return retval;
@@ -562,7 +560,7 @@ sendcleanup:
 
 /* -- Rivet_ExecuteAndCheck
  * 
- * Tcl script execution central procedure. The script stored
+ * Tcl script execution central procedure. The script stored in
  * outbuf is evaluated and in case an error occurs in the execution
  * an error handler is executed. In case the error code returned
  * is RIVET then the error was caused by the invocation of a 
@@ -596,7 +594,6 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
     rivet_server_conf *conf = Rivet_GetConf(req);
     rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
-    apr_thread_mutex_lock(module_globals->req_mutex);
     Tcl_Preserve (interp);
     if ( Tcl_EvalObjEx(interp, tcl_script_obj, 0) == TCL_ERROR ) {
         Tcl_Obj *errscript;
@@ -681,7 +678,6 @@ good:
             TclWeb_PrintError( errorinfo, 0, globals->req );
         }
     }
-    apr_thread_mutex_unlock(module_globals->req_mutex);
 
     if (!globals->req->headers_set && (globals->req->charset != NULL)) {
         TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL),globals->req);

Modified: tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c?rev=1618366&r1=1618365&r2=1618366&view=diff
==============================================================================
--- tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c (original)
+++ tcl/rivet/trunk/src/experimental/rivet_worker_mpm.c Sat Aug 16 14:27:09 2014
@@ -194,9 +194,7 @@ static void* APR_THREAD_FUNC request_pro
         private->r   = request_obj->r;
         private->req = request_obj->req;
 
-        //apr_thread_mutex_lock(module_globals->req_mutex);
         request_obj->code = Rivet_SendContent(private);
-        //apr_thread_mutex_unlock(module_globals->req_mutex);
 
         apr_thread_mutex_lock(request_obj->mutex);
         request_obj->status = done;
@@ -208,7 +206,7 @@ static void* APR_THREAD_FUNC request_pro
 
     } while (private->keep_going > 0);
             
-    ap_log_error(APLOG_MARK, APLOG_INFO, 0, module_globals->server, "processor thread orlderly exit");
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, module_globals->server, "processor thread orderly exit");
 
     Rivet_ProcessorCleanup(private);
 
@@ -282,16 +280,21 @@ static void supervisor_housekeeping (voi
 
 
 /* -- threaded_bridge_supervisor
- *
  * 
  */
 
 static void* APR_THREAD_FUNC threaded_bridge_supervisor(apr_thread_t *thd, void *data)
 {
     server_rec* s = (server_rec *)data;
+#ifdef RIVET_MPM_SINGLE_THREAD
+    int thread_to_start = 1;
+#else
+    int thread_to_start = (int)round(module_globals->mpm_max_threads);
+#endif
+
+    ap_log_error(APLOG_MARK,APLOG_INFO,0,s,"starting %d Tcl threads",thread_to_start);
+    start_thread_pool(thread_to_start);
 
-    ap_log_error(APLOG_MARK,APLOG_INFO,0,s,"starting %d Tcl threads",(int)round(module_globals->mpm_max_threads));
-    start_thread_pool(module_globals->mpm_max_threads);
     do
     {
         apr_thread_t*   p;



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