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 Massimo Manghi <ma...@unipr.it> on 2007/12/26 17:18:48 UTC

Rivet Tcl stuff removal and other issues

Hi everybody

I made some minor changes to some files in Rivet. 
Here is a short description of my work

 * The target 'uninstall-local' has been added to Makefile.am
and removes althogheter the tcl code installed by Rivet.

 * In both mod_rivet.c the call to Tcl_EvalFile is now checked 
explicitly against the TCL_ERROR code.

 * dio_Mysql.tcl has been fixed in 2 methods: the switch '-host' was
not handled in the 'open' method. The method 'exec' does determine
now if the command is a 'select' by explicit comparison with a 
literal string. Though I can't recall exactly in what circumstances
it happened to me the previous code failed because 'lindex $req 0'
returned a string with spaces in it (probably builing queries using
lists).

I can't commit these changes immediately, but I'm confident I will
able to it in a few days.

More things to do: Do we intend to keep the server array? It is
created in  mod_rivet.c but it's not documented, and its variables
have wrong definitions in them. If a purpose can be given to this
array I can fix it and document it, otherwise the code can be removed
(or compiled conditionally).

I'm working to a small and simple implementation of the algorithm
in rivetCrypt written in Javascript. 
My idea is to put it in the examples as a simple application 
to conceal from possible automatic scanning email addresses or 
other data that have to be shown on a web page. 

regards

 -- Massimo


Index: Makefile.am
===================================================================
--- Makefile.am	(revision 604427)
+++ Makefile.am	(working copy)
@@ -1,11 +1,11 @@
 #
-# top-level Makefile.am for Apache Rivet
+# top-level Makefile.am for Apache Rivet: gets turned into a Makefile.in by
automake
 #
-# ...gets turned into a Makefile.in by automake
-#
 # $Id$
 #
-#foreign -- need to set this somehow
+# 2007/12/25: Added target uninistall-local that removes the tcl stuff (mxmanghi)
+#
+#
 
 EXTRA_DIST=LICENSE contrib debian doc rivet win/nmakehlp.c src/testing.c
src/TclWebcgi.c
 SUBDIRS = src doc
@@ -19,7 +19,7 @@
 	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@ ; )
+uninstall-local:
+	rm -fr $(RIVETLIB_DESTDIR)
+
+# 

Index: src/apache-2/mod_rivet.c
===================================================================
--- src/apache-2/mod_rivet.c	(revision 604427)
+++ src/apache-2/mod_rivet.c	(working copy)
@@ -845,11 +845,11 @@
     /* Eval Rivet's init.tcl file to load in the Tcl-level
        commands. */
 
-    /* We want to run the init.tcl specific to the installation
+    /* We want to run the installation specific 'init.tcl'
      */
 
-    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl")) {
 //  if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
+    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl") == TCL_ERROR) {
         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) );

Index: src/apache-1/mod_rivet.c
===================================================================
--- src/apache-1/mod_rivet.c	(revision 604427)
+++ src/apache-1/mod_rivet.c	(working copy)
@@ -200,8 +200,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]);
@@ -705,14 +706,13 @@
     /* Eval Rivet's init.tcl file to load in the Tcl-level
     commands. */
 
-    /* We want to run the init.tcl specific to the installation
-     * that is being carried out
+    /* We want to run the installation specific 'init.tcl'
      */
 
     Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl");
 
-    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl")) {
 //  if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL) {
+    if (Tcl_EvalFile(interp,RIVETLIB_DESTDIR"/init.tcl") == TCL_ERROR) {
 	ap_log_error( APLOG_MARK, APLOG_ERR, s,
 		      "init.tcl must be installed correctly for Apache Rivet to function: %s",
 		      Tcl_GetStringResult(interp) );
@@ -752,7 +752,7 @@
     char *buf;
     char *format;
 
-    format = TCL_VARARGS_START(char *,arg1,argList);
+    format = (char *)TCL_VARARGS_START(char *,arg1,argList);
     buf = ap_pvsprintf(globalrr->pool, format, argList);
     ap_log_error(APLOG_MARK, APLOG_CRIT, globalrr->server,
 		 "Critical error in request: %s", globalrr->unparsed_uri);


Index: rivet/packages/dio/dio_Mysql.tcl
===================================================================
--- rivet/packages/dio/dio_Mysql.tcl	(revision 604427)
+++ rivet/packages/dio/dio_Mysql.tcl	(working copy)
@@ -16,7 +16,7 @@
 
 # $Id$
 
-package provide dio_Mysql 0.1
+package provide dio_Mysql 0.2
 
 namespace eval DIO {
     ::itcl::class Mysql {
@@ -49,7 +49,7 @@
 	    if {![lempty $user]} { lappend command -user $user }
 	    if {![lempty $pass]} { lappend command -password $pass }
 	    if {![lempty $port]} { lappend command -port $port }
-	    if {![lempty $host]} { lappend command $host }
+	    if {![lempty $host]} { lappend command -host $host }
 
 	    if {[catch $command error]} { return -code error $error }
 
@@ -68,7 +68,14 @@
 	    if {![info exists conn]} { open }
 
 	    set cmd mysqlexec
-	    if {[::string tolower [lindex $req 0]] == "select"} { set cmd mysqlsel }
+#
+#	    if {[::string tolower [lindex $req 0]] == "select"} { set cmd mysqlsel }
+#	    select is a 6 characters word, so let's see if the query is a select
+#
+	    set q [::string trim $req]
+	    set q [::string tolower $q]
+	    set q [::string range $q 0 5]
+	    if {[::string match select $q]} { set cmd mysqlsel }
 
 	    set errorinfo ""
 	    if {[catch {$cmd $conn $req} error]} {


--
Universita' degli Studi di Parma (http://www.unipr.it)


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


Re: Rivet Tcl stuff removal and other issues

Posted by Massimo Manghi <ma...@unipr.it>.
On Sun, 30 Dec 2007 17:31:43 +0100, David Welton wrote
> > I know that putting this question I'm maybe destroying the
> > residual reputation I have: what is 'ab'?
> 
> It stands for 'apache benchmark', and the man page should be 
> available with 'man ab'.  You can use it to measure performance, but 
> also to pound on a server a little bit.
> 

Wonderful, a meaningful name. It recalls the old joke about
the VAX/VMS programmer who wanted his brain to be partially
removed because he wanted to become an IBM mainframe programmer:
by the late '80s "that was the job where the money was".
But the surgeons went a bit too further removing his brain and
when he came out of the surgery he spoke like this

"Grep! awk bc! cc..." 

happy new year to you guys.

--
Universita' degli Studi di Parma (http://www.unipr.it)


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


Re: Rivet Tcl stuff removal and other issues

Posted by David Welton <da...@gmail.com>.
> I know that putting this question I'm maybe destroying the
> residual reputation I have: what is 'ab'?

It stands for 'apache benchmark', and the man page should be available
with 'man ab'.  You can use it to measure performance, but also to
pound on a server a little bit.

-- 
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

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


Re: Rivet Tcl stuff removal and other issues

Posted by Massimo Manghi <ma...@unipr.it>.
On Fri, 28 Dec 2007 18:00:42 +0100, David Welton wrote
> > Do you mean that EvalFile might behave unexpectedly when
> > running on other systems?
> 
> No, not that - just that init.tcl ends up in the right place on all systems.
> 

Well, as I said I don't have a chance to test it on Windows
at the moment.
I don't even know whether David Zolli's attempt to compile 
Rivet on MacX eventually succeeded. What apache architecture
had Dave Zolli installed? Just before Christmas I had
segfaults problems myself because I mistakenly installed
a threaded Apache instead of a 'prefork' one.

> > For what I can see Rivet on Apache2 runs quite well. Last week
> > I dropped the apache1.3 instance on my computer at work.
> 
> Cool!  Some stress testing with 'ab' might be in order:
> 
> ab -c 10 -n 1000 .....
> 

I know that putting this question I'm maybe destroying the 
residual reputation I have: what is 'ab'?

-- Massimo


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


Re: Rivet Tcl stuff removal and other issues

Posted by David Welton <da...@gmail.com>.
> Do you mean that EvalFile might behave unexpectedly when
> running on other systems?

No, not that - just that init.tcl ends up in the right place on all systems.

> For what I can see Rivet on Apache2 runs quite well. Last week
> I dropped the apache1.3 instance on my computer at work.

Cool!  Some stress testing with 'ab' might be in order:

ab -c 10 -n 1000 .....

-- 
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

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


Re: Rivet Tcl stuff removal and other issues

Posted by Massimo Manghi <ma...@unipr.it>.
On Thu, 27 Dec 2007 12:18:43 +0100, David Welton wrote
> >  * In both mod_rivet.c the call to Tcl_EvalFile is now checked
> > explicitly against the TCL_ERROR code.
> 
> Have you guys managed to test installation with EvalFile vs the
> package require on different systems at all?
> 

Do you mean that EvalFile might behave unexpectedly when
running on other systems?

I can only test it on my Debian/Linux machines. Testing
it on a Windows machine would take a bit too long to me
by now, but maybe Pat is willing to work again on that port.


> Also, go ahead and remove the commented line.  Comments, in general,
> are ok when you're hacking at something, but if you use a version
> control system, just get rid of the old code, perhaps with a comment
> that this used to be so and so, and was changed for whatever reason.
> 

The lines commented out were meant to remember the previous
code, in case we had to back up to it. I had it in my mind and
I wanted to remove them as soon as the testing phase reached
a satisfying stage. I will add an explicit comment about this.

For what I can see Rivet on Apache2 runs quite well. Last week
I dropped the apache1.3 instance on my computer at work. 

-- Massimo


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


Re: Rivet Tcl stuff removal and other issues

Posted by David Welton <da...@gmail.com>.
>  * In both mod_rivet.c the call to Tcl_EvalFile is now checked
> explicitly against the TCL_ERROR code.

Have you guys managed to test installation with EvalFile vs the
package require on different systems at all?

Also, go ahead and remove the commented line.  Comments, in general,
are ok when you're hacking at something, but if you use a version
control system, just get rid of the old code, perhaps with a comment
that this used to be so and so, and was changed for whatever reason.

Ciao,
-- 
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

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