I'm sending the patches for configure.ac (which introduces the
--with-rivet-target-dir
switch for changing the rivet tcl library destination directory),
mod_rivet.c
with the changes I described in my previous message and Makefile.am for
handling
the new variable defined in configure.
comments absolutely welcome (and necessary, I think)
--Massimo
Valery Masiutsin wrote:
Hello, Massimo !
Hm would you like to point me to the conversations about exit handlers ?
How much time ago that was happened ?
I am working on replacing libapreq bits with their libapreq2 equivalents now
(apache_* files), API has been changed significantly (totally ?), so
i presume it will take another week or even two. BTW those tests
helped me a lot.
Regards Valery
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: configure.ac
===================================================================
--- configure.ac (revision 588292)
+++ configure.ac (working copy)
@@ -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,28 @@
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],,
+ )
+ AC_MSG_CHECKING(for Rivet tcl library target)
+ if test x"${withval}" = x ; then
+ rivet_target_dir="${apache_base}/lib/rivet${PACKAGE_VERSION}"
+ else
+ rivet_target_dir="${withval}"
+ fi
+ RIVET_TCL_TARGET=${rivet_target_dir}
+ AC_SUBST(RIVET_TCL_TARGET)
+ AC_MSG_RESULT([$rivet_target_dir])
+])
APACHE_VERSION
GET_RIVET_BASE
@@ -409,9 +422,12 @@
CHECK_APXS
APACHE_INCLUDES
APR_HANDLING
+RIVET_TCL_LIB
AC_SUBST(apache_include)
AC_SUBST(apache_version_dir)
+#AC_DEFINE_UNQUOTED(RIVETLIB_DESTDIR,"${apache_base}/lib/rivet${PACKAGE_VERSION}",[The path to the rivet tcl library])
+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
@@ -420,7 +436,6 @@
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
# which require substituting th AC variables in. Include these here.
Index: Makefile.am
===================================================================
--- Makefile.am (revision 588292)
+++ Makefile.am (working copy)
@@ -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@/[EMAIL PROTECTED]@
- cp -r rivet/* $(DESTDIR)@libdir@/[EMAIL PROTECTED]@
+ $(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@/[EMAIL PROTECTED]@
+# cp -r rivet/* $(DESTDIR)@libdir@/[EMAIL PROTECTED]@
# This little bit of line noise generates the package index file (pkgIndex.tcl)
- -( cd $(DESTDIR)@libdir@/[EMAIL PROTECTED]@ ; 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@/[EMAIL PROTECTED]@ ; echo 'eval pkg_mkIndex -verbose [pwd] init.tcl [glob [file join packages * *.tcl] [file join *[info sharedlibextension]]]' | @TCLSH_PROG@ ; )
Index: src/apache-2/mod_rivet.c
===================================================================
--- src/apache-2/mod_rivet.c (revision 588292)
+++ src/apache-2/mod_rivet.c (working copy)
@@ -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>
@@ -255,7 +258,37 @@
Tcl_DecrRefCount(obj);
}
+/*
+ * Experimental function that sets up an array with some of the request_rec fields
+ * as they are passed to the handler.
+ *
+ */
+
static void
+Rivet_InitRequestVariables (Tcl_Interp *interp, request_rec *r)
+{
+ Tcl_Obj *obj;
+
+ obj = Tcl_NewStringObj(r->filename,-1);
+ Tcl_IncrRefCount(obj);
+ Tcl_SetVar2Ex(interp,
+ "request",
+ "filename",
+ obj,
+ TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(obj);
+
+ obj = Tcl_NewStringObj(r->canonical_filename,-1);
+ Tcl_IncrRefCount(obj);
+ Tcl_SetVar2Ex(interp,
+ "request",
+ "canonical_filename",
+ obj,
+ TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(obj);
+}
+
+static void
Rivet_PropagateServerConfArray( Tcl_Interp *interp, rivet_server_conf *rsc )
{
apr_table_t *t;
@@ -412,8 +445,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 +706,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 +722,8 @@
if (dconf == NULL) {
return rsc;
}
-
return rsc;
-
+/*
rdc = RIVET_SERVER_CONF( dconf );
newconfig = RIVET_NEW_CONF( r->pool );
@@ -703,6 +733,7 @@
Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
return newconfig;
+ */
}
static void *
@@ -805,8 +836,6 @@
Tcl_DecrRefCount(arrayName);
}
-
-
/*
*-----------------------------------------------------------------------------
*
@@ -849,6 +878,10 @@
/* Eval Rivet's init.tcl file to load in the Tcl-level
commands. */
+
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, "auto_path: %s",
+ Tcl_GetVar(interp, "auto_path", TCL_GLOBAL_ONLY));
+
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",
@@ -1048,7 +1081,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 +1285,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 +1480,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 */
@@ -1469,6 +1515,8 @@
globals->r = r;
globals->req = (TclWebRequest *)apr_pcalloc(r->pool, sizeof(TclWebRequest));
+ Rivet_InitRequestVariables(interp,r);
+
if (r->per_dir_config != NULL)
rdc = RIVET_SERVER_CONF( r->per_dir_config );
else
@@ -1600,7 +1648,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]