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 mx...@apache.org on 2007/11/05 18:58:30 UTC

svn commit: r592108 - in /tcl/rivet/trunk: Makefile.am configure.ac src/Makefile.am src/apache-1/Makefile.am src/apache-1/mod_rivet.c src/apache-2/TclWebapache.c src/apache-2/mod_rivet.c

Author: mxmanghi
Date: Mon Nov  5 09:58:25 2007
New Revision: 592108

URL: http://svn.apache.org/viewvc?rev=592108&view=rev
Log:
2007-11-05  Massimo Manghi <ma...@unipr.it>

	* configure.ac: the macro rivet_target_dir was added 
	to 'configure'. This macro generates a name for the 
	directory where Rivet libraries must be copied during 
	the installation phase. User is enabled to change
	the default value by feeding 'configure' with the switch
	'--with-rivet-target-dir'. This macro defines also the
	variable RIVET_TCL_TARGET and calls AC_SUBST on it.
	The target directory gets inserted also in the 
	auto_path list variable of every script run by 
	the module. Defined configuration symbol 
	RIVETLIB_DESTDIR in config.h.

	* Makefile.am,src/Makefile.am: RIVET_TCL_TARGET variable
	propagation.

	* src/apache-1/Makefile.am: rivetWWW.c removed from 
	linking into mod_rivet.so (this requires docs to 
	be updated, as commands in this file have to be 
	loaded explicitly using 'package require Rivet')

	* src/apache-1/mod_rivet.c: Tcl_DeleteInterp called
	upon child exit. ${RIVETLIB_DESTDIR)/init.tcl is 
	run during the interpreter initialization.
	
	* src/apache-2/mod_rivet.c: Exit handler reenabled,
	and Tcl_DeleteInterp called upon child exit. 
	${RIVETLIB_DESTDIR)/init.tcl is run during the 
	interpreter initialization. Code clean up in 
	Rivet_GetConf. Minor changes in order to get rid
	of some compilation warnings.

	* src/apache-2/TclWebapache.c: Test checking for 
	null values in the table of environment variables
	has been extended to the value field. Failure to
	do so caused a child to segfault when rivet was
	used in conjuction with dir_module


Modified:
    tcl/rivet/trunk/Makefile.am
    tcl/rivet/trunk/configure.ac
    tcl/rivet/trunk/src/Makefile.am
    tcl/rivet/trunk/src/apache-1/Makefile.am
    tcl/rivet/trunk/src/apache-1/mod_rivet.c
    tcl/rivet/trunk/src/apache-2/TclWebapache.c
    tcl/rivet/trunk/src/apache-2/mod_rivet.c

Modified: tcl/rivet/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/Makefile.am?rev=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/Makefile.am (original)
+++ tcl/rivet/trunk/Makefile.am Mon Nov  5 09:58:25 2007
@@ -9,12 +9,17 @@
 
 EXTRA_DIST=LICENSE contrib debian doc rivet win/nmakehlp.c src/testing.c src/TclWebcgi.c
 SUBDIRS = src doc
+RIVETLIB_DESTDIR = @RIVET_TCL_TARGET@
 
 libtool: $(LIBTOOL_DEPS)
 	$(SHELL) ./config.status --recheck
 
 install-data-local:
-	$(mkinstalldirs) $(DESTDIR)@libdir@/rivet@VERSION@
-	cp -r rivet/* $(DESTDIR)@libdir@/rivet@VERSION@
+	$(mkinstalldirs) $(RIVETLIB_DESTDIR)
+	cp -r rivet/* $(RIVETLIB_DESTDIR)
+	-( cd  $(RIVETLIB_DESTDIR) ; echo 'eval pkg_mkIndex -verbose [pwd] init.tcl [glob [file join packages * *.tcl] [file join *[info sharedlibextension]]]' | @TCLSH_PROG@ ; )
+
+#	$(mkinstalldirs) $(DESTDIR)@libdir@/rivet@VERSION@
+#	cp -r rivet/* $(DESTDIR)@libdir@/rivet@VERSION@
 # This little bit of line noise generates the package index file (pkgIndex.tcl)
-	-( cd  $(DESTDIR)@libdir@/rivet@VERSION@ ; echo 'eval pkg_mkIndex -verbose [pwd] init.tcl [glob [file join packages * *.tcl] [file join *[info sharedlibextension]]]' | @TCLSH_PROG@ ; )
\ No newline at end of file
+#	-( cd  $(DESTDIR)@libdir@/rivet@VERSION@ ; echo 'eval pkg_mkIndex -verbose [pwd] init.tcl [glob [file join packages * *.tcl] [file join *[info sharedlibextension]]]' | @TCLSH_PROG@ ; )

Modified: tcl/rivet/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/configure.ac?rev=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/configure.ac (original)
+++ tcl/rivet/trunk/configure.ac Mon Nov  5 09:58:25 2007
@@ -344,9 +344,9 @@
 	    AC_SUBST(APR_INCLUDES)
 	    APR_LDLFAGS=`${apr_found} --link-libtool --libs`
 	    AC_SUBST(APR_LDFLAGS)
-        else
-            AC_MSG_ERROR([Could not find apr-1-config.  apr-1-config must be in your PATH or you must specify the location of the apr script using --with-apr-config])
-        fi
+    else
+        AC_MSG_ERROR([Could not find apr-1-config.  apr-1-config must be in your PATH or you must specify the location of the apr script using --with-apr-config])
+    fi
 ])
 
 # apache version
@@ -360,7 +360,7 @@
     AC_ARG_WITH(
         apache_version,
         [  --with-apache-version[=VER]  build for apache 1.x or 2.x],,
-        ,[with_apache_version="2"]
+        [with_apache_version="2"]
     )
 
     AC_MSG_CHECKING(for apache version)
@@ -372,7 +372,7 @@
         AC_MSG_RESULT( building for apache 2.x )
 	AC_CONFIG_FILES([src/apache-2/Makefile])
 	apache_version_dir="apache-2"
-    AC_DEFINE(APACHE2,1,[Apache2 define to config.h])
+        AC_DEFINE(APACHE2,1,[Apache2 define to config.h])
     fi
 ])
 
@@ -393,15 +393,24 @@
 	    TCL_PACKAGE_PATH=${res}
             AC_SUBST(TCL_PACKAGE_PATH)
         fi
-	     
 ])
 
-
 AC_DEFUN([GET_RIVET_BASE], [
-	RIVET_BASE_INCLUDE=`pwd`/src	
-	AC_SUBST(RIVET_BASE_INCLUDE)
+    RIVET_BASE_INCLUDE=`pwd`/src	
+    AC_SUBST(RIVET_BASE_INCLUDE)
 ])
 
+AC_DEFUN([RIVET_TCL_LIB],[
+    AC_ARG_WITH(
+        rivet_target_dir,
+        [ --with-rivet-target-dir=DIR  Rivet tcl library target dir ],,
+		with_rivet_target_dir="${apache_base}/lib/rivet${PACKAGE_VERSION}"
+    )
+    AC_MSG_CHECKING(for Rivet tcl library target)
+    RIVET_TCL_TARGET=${with_rivet_target_dir}
+    AC_SUBST(RIVET_TCL_TARGET)
+    AC_MSG_RESULT([$with_rivet_target_dir])
+])
 
 APACHE_VERSION
 GET_RIVET_BASE
@@ -409,9 +418,11 @@
 CHECK_APXS
 APACHE_INCLUDES
 APR_HANDLING
+RIVET_TCL_LIB
 AC_SUBST(apache_include)
 AC_SUBST(apache_version_dir)
 
+AC_DEFINE_UNQUOTED(RIVETLIB_DESTDIR,"${RIVET_TCL_TARGET}",[The path to the rivet tcl library])
 AC_DEFINE_UNQUOTED(NAMEOFEXECUTABLE,"${TCLSH_PROG}",[The path to a working tclsh executable])
 
 # We need to use the package path for the installation procedure.  On
@@ -419,7 +430,6 @@
 #TCL_PACKAGE_PATH variable, so we have to handle this
 HANDLE_TCL_PACKAGE_PATH
 AC_SUBST(TCL_PACKAGE_PATH)
-
 
 # Finally, substitute all of the various values into the Makefile.
 # You may alternatively have a special pkgIndex.tcl.in or other files

Modified: tcl/rivet/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/Makefile.am?rev=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/src/Makefile.am (original)
+++ tcl/rivet/trunk/src/Makefile.am Mon Nov  5 09:58:25 2007
@@ -25,7 +25,7 @@
 
 # ... and these two.  We want to put the libs in the package path,
 # rather than the standard library location for the system.
-lib_libexecdir = @TCL_PACKAGE_PATH@/rivet
+lib_libexecdir = @RIVET_TCL_TARGET@
 lib_libexec_LTLIBRARIES = librivet.la librivetparser.la
 
 #

Modified: tcl/rivet/trunk/src/apache-1/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-1/Makefile.am?rev=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/Makefile.am (original)
+++ tcl/rivet/trunk/src/apache-1/Makefile.am Mon Nov  5 09:58:25 2007
@@ -37,7 +37,6 @@
 	mod_rivet.c \
 	TclWebapache.c \
 	../rivetCore.c \
-	../rivetWWW.c \
 	../rivetChannel.c \
 	../rivetParser.c
 

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=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-1/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-1/mod_rivet.c Mon Nov  5 09:58:25 2007
@@ -704,7 +704,15 @@
 
     /* Eval Rivet's init.tcl file to load in the Tcl-level
     commands. */
-    if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
+
+    /* We want to run the init.tcl specific to the installation
+     * that is being carried out
+     */
+
+    Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl");
+
+    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl")) {
+//  if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
 	ap_log_error( APLOG_MARK, APLOG_ERR, s,
 		      "init.tcl must be installed correctly for Apache Rivet to function: %s",
 		      Tcl_GetStringResult(interp) );
@@ -1381,6 +1389,15 @@
 			     Tcl_GetString(function));
 		ap_log_error(APLOG_MARK, APLOG_ERR, s, "%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);
 	    }
 	}
 	sr = sr->next;

Modified: tcl/rivet/trunk/src/apache-2/TclWebapache.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/TclWebapache.c?rev=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/TclWebapache.c (original)
+++ tcl/rivet/trunk/src/apache-2/TclWebapache.c Mon Nov  5 09:58:25 2007
@@ -423,8 +423,9 @@
     env     = (apr_table_entry_t *) env_arr->elts;
     for (i = 0; i < env_arr->nelts; ++i)
     {
-	if (!env[i].key)
+	if ((!env[i].key) || (!env[i].val)) {
 	    continue;
+	}
 
 	key = TclWeb_StringToUtfToObj(env[i].key, req);
 	val = TclWeb_StringToUtfToObj(env[i].val, req);

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=592108&r1=592107&r2=592108&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Mon Nov  5 09:58:25 2007
@@ -24,6 +24,9 @@
 #include <sys/stat.h>
 #include <string.h>
 
+/* as long as we need to emulate ap_chdir_file we need to include unistd.h */
+#include <unistd.h>
+
 /* Apache includes */
 #include <httpd.h>
 #include <http_config.h>
@@ -412,8 +415,9 @@
             delEntry = Tcl_FindHashEntry(
                     rsc->objCache,
                     rsc->objCacheList[ct]);
-            if (delEntry != NULL)
+            if (delEntry != NULL) {
                 Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
+	    }
             Tcl_DeleteHashEntry(delEntry);
 
             free(rsc->objCacheList[ct]);
@@ -672,17 +676,14 @@
     }
 }
 
-
-
-
 /* Function to get a config and merge the directory/server options  */
 rivet_server_conf *
 Rivet_GetConf( request_rec *r )
 {
-    rivet_server_conf *newconfig = NULL;
     rivet_server_conf *rsc = RIVET_SERVER_CONF( r->server->module_config );
-    rivet_server_conf *rdc;
     void *dconf = r->per_dir_config;
+    //rivet_server_conf *newconfig = NULL;
+    //rivet_server_conf *rdc;
     //int tst;
     
     FILEDEBUGINFO;
@@ -691,9 +692,8 @@
     if (dconf == NULL) {
         return rsc;
     }
-
     return rsc;
-
+/*
     rdc = RIVET_SERVER_CONF( dconf );
     
     newconfig = RIVET_NEW_CONF( r->pool );
@@ -703,6 +703,7 @@
     Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
 
     return newconfig;
+ */
 }
 
 static void *
@@ -805,8 +806,6 @@
     Tcl_DecrRefCount(arrayName);
 }
 
-
-
 /*
  *-----------------------------------------------------------------------------
  *
@@ -849,7 +848,12 @@
 
     /* Eval Rivet's init.tcl file to load in the Tcl-level
        commands. */
-    if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
+
+    /* We want to run the init.tcl specific to the installation
+     */
+
+    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl")) {
+//  if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
         ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
                 "init.tcl must be installed correctly for Apache Rivet to function: %s",
                 Tcl_GetStringResult(interp) );
@@ -1048,7 +1052,11 @@
 Rivet_InitHandler(apr_pool_t *pPool, apr_pool_t *pLog, apr_pool_t *pTemp,
        server_rec *s)
 {
+#ifdef HIDE_RIVET_VERSION
     ap_add_version_component(pPool, "Rivet");
+#else
+    ap_add_version_component(pPool, "Rivet/"VERSION);
+#endif
     return OK;
 }
 
@@ -1248,13 +1256,22 @@
                 ( sr == s || rsc->separate_virtual_interps ||
                   function != parentfunction))
         {
-            if (Tcl_EvalObjEx(rsc->server_interp,
-                        function, 0) != TCL_OK) {
+            if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
                 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
                         errmsg, Tcl_GetString(function));
                 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, "%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);
+	    }
+
         }
         sr = sr->next;
     }
@@ -1434,7 +1451,7 @@
     Rivet_ChildHandlers(s, 1);
 
     //cleanup
-    //apr_pool_cleanup_register (pChild, s, Rivet_ChildExit, Rivet_ChildExit);
+    apr_pool_cleanup_register (pChild, s, Rivet_ChildExit, Rivet_ChildExit);
 }
 
 /* Set things up to execute a file, then execute */
@@ -1579,6 +1596,7 @@
         request_cleanup = Tcl_NewStringObj("::Rivet::cleanup_request\n", -1);
         Tcl_IncrRefCount(request_cleanup);
     }
+
     if(Tcl_EvalObjEx(interp, request_cleanup, 0) == TCL_ERROR) {
         ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, "%s",
                 Tcl_GetVar(interp, "errorInfo", 0));
@@ -1600,7 +1618,7 @@
 {
     //static const char * const aszPre[] = {
     //    "http_core.c", "mod_mime.c", NULL };
-    static const char * const aszPreTranslate[] = {"mod_alias.c", NULL};
+    //static const char * const aszPreTranslate[] = {"mod_alias.c", NULL};
 
     ap_hook_post_config (Rivet_InitHandler, NULL, NULL, APR_HOOK_LAST);
     ap_hook_handler (Rivet_SendContent, NULL, NULL, APR_HOOK_LAST);



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