On Thu, 2 Nov 2000, Jim Driscoll wrote:

> "[EMAIL PROTECTED]" wrote:
> > 
> > On Mon, 30 Oct 2000, Petr Jiricka wrote:
> > 
> > > Hi,
> > >
> > > I'd like to ask where the Tomcat 3.2 final release discussions are right
> > > now. It seemed that the last outstanding issue was the compilation under JDK
> > > 1.1, but that should be fixed now. So is there still something that needs to
> > > be fixed ?
> > >
> > > I would really appreciate if the release could happen within the next few
> > > days.
> > >
> > > Thanks
> > > Petr
> > >
> > >
> > 
> > session/cookie and other patches (date spinlock and one more i think) have
> > not been integrated...can someone dump em in and release b7 or final ?
> > -Ys-
> > [EMAIL PROTECTED]
> > 
> 
> 
> So, I haven't seen anything about this since Monday.  Could someone
> please hand me (and, I suspect, a few other folks) a clue on what the
> current plan is?  Thanks!
> 
> Jim
> 

dunno but heres a combined patch file (attached) which may help..im
missing one patch for the cookie handling but the others might be
useful...i've already sent this over before....can someone look at
the patches and integrate em or let me know if they dont work ?
-Ys-
[EMAIL PROTECTED]
--- Copy of Handler.java        Mon Oct  9 06:07:00 2000
+++ Handler.java        Sat Oct 28 19:57:49 2000
@@ -238,20 +238,22 @@
      */
     public void service(Request req, Response res) 
     {
-       if( ! initialized ) {
-           try {
-               init();
-               if ( ! initialized )
+       synchronized( this ) {
+           if( ! initialized ) {
+               try {
+                   init();
+                   if ( ! initialized )
                        return; // return if still not initialied
-           } catch( Exception ex ) {
-               initialized=false;
-               if( ex instanceof ClassNotFoundException ) {
-                   contextM.handleStatus( req, res, 404);
+               } catch( Exception ex ) {
+                   initialized=false;
+                   if( ex instanceof ClassNotFoundException ) {
+                       contextM.handleStatus( req, res, 404);
+                       return;
+                   }
+                   context.log("Exception in init  " + ex.getMessage(), ex );
+                   contextM.handleError( req, res, ex );
                    return;
                }
-               context.log("Exception in init  " + ex.getMessage(), ex );
-               contextM.handleError( req, res, ex );
-               return;
            }
        }
 

----------------- fix for race condition patch



I am sending this to both the JServ and Tomcat lists since mod_jserv is
part of both projects.

A customer of ours reported GPFs when running mod_jserv on windows.  I
tracked down the problem and have a fix to submit for it.

In jserv_ajpv12.c there is the following call:

len = (int) ap_bread(buffsocket, buffer, HUGE_STRING_LEN);

The spec for ap_bread states that the return value is the number of
bytes read or -1 if there was an error.  The code currently doesn't
check for this error response and simply calls ap_bwrite later with -1
for the length which results in a GPF on windows.  To fix I added the
following check after the call to ap_bread:

if (len < 0) {
  return -1;
}


In looking at both the current JServ sources and the Tomcat 3.1 sources,
both code lines have this problem.

thanks,
--Barry


------------------------- mod_jserv core dump fix ?


foo
From [EMAIL PROTECTED] Mon Oct 30 16:35:00 2000
Date: Fri, 13 Oct 2000 12:43:43 -0700
From: Tim Kientzle <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED], [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: SimpleDateFormat considered harmful

While stress-testing a Tomcat-based servlet system,
I'm running into performance problems caused
by thread contention.  Most of them have been
in my code, but I just found a big one within Tomcat:

org.apache.tomcat.util.MimeHeaderField.dateFormat()

invokes a java.text.SimpleDateFormat object to format
the dates on outgoing headers.  SimpleDateFormat relies
on DecimalFormat, which is synchronized.  (With 50
simultaneous requests against my servlet, I'm seeing over 20
of them waiting on a single shared DecimalFormat object.)

The attached sample program contains a drop-in replacement
for MimeHeaderField.dateFormat() that produces exactly the
same results, but is approximately six times faster and is
not synchronized.  Please include this (or something similar)
in Tomcat to improve performance.

Just for the record: the attached program is my own work,
I release it into the public domain.  Do with it as you will.

                        - Tim Kientzle
    [ Part 2: "Attached Text" ]

class test {

    /* REFERENCE: Compare results to SimpleDateFormat */

    public final static java.util.Locale LOCALE_US = java.util.Locale.US;

    public final static String RFC1123_PATTERN =
        "EEE, dd MMM yyyyy HH:mm:ss z";

    public final static java.text.DateFormat rfc1123Format =
        new java.text.SimpleDateFormat(RFC1123_PATTERN, LOCALE_US);

    /* MY IMPLEMENTATION: Computes RFC1123-format date directly */

    private static final String[] weekdays 
        = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
    private static final String[] months
        = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };

    static String formatDate( java.util.Date date ) {
        // Compute day number, seconds since beginning of day
        long s = date.getTime();;
        if(s >=0) s /= 1000; // seconds since 1 Jan 1970
        else s = (s-999)/1000; // floor(sec/1000)
        
        int dn = (int)(s / 86400);
        s %= 86400;  // positive seconds since beginning of day
        if(s<0) { s+=86400; dn--; }
        dn += 1969*365 + 492 - 19 + 4; // days since "1 Jan, year 1"

        // Convert days since 1 Jan, year 1 to year/yearday
        int y = 400*(dn/146097) + 1;
        int d = dn % 146097;
        if(d == 146096) { y += 399; d=365; } // Last year of 400 is long
        else {
            y += 100*(d/36524);
            d %= 36524;
            y += 4*(d/1461);
            d %= 1461;
            if(d == 1460) { y += 3; d=365; } // Last year out of 4 is long
            else {
                y += d/365;
                d %= 365;
            }
        }

        boolean isleap = ((y%4==0) && !(y%100==0)) || (y%400==0);

        // Compute month/monthday from year/yearday
        if(!isleap && (d >= 59)) d++; // Skip non-existent Feb 29
        if(d >= 60) d++; // Skip non-existent Feb 30
        int mon = ((d%214)/61)*2 + ((d%214)%61)/31;
        if(d>213) mon += 7;
        d = ((d%214)%61)%31 + 1;

        // Convert second to hour/min/sec
        int m = (int)(s/60), h = m/60; m %= 60; s %= 60;
        int w = (dn+1) % 7; // Day of week, 0==Sun

        /* RFC 1123 date string: "Sun, 06 Nov 1994 08:49:37 GMT" */
        StringBuffer buff = new StringBuffer(32);
        buff.append(weekdays[w]);
        buff.append(", ");
        buff.append((char)(d/10 + '0'));
        buff.append((char)(d%10 + '0'));
        buff.append(' ');
        buff.append(months[mon]);
        buff.append(' ');
        buff.append(y);
        buff.append(' ');
        buff.append((char)(h/10 + '0'));
        buff.append((char)(h%10 + '0'));
        buff.append(':');
        buff.append((char)(m/10 + '0'));
        buff.append((char)(m%10 + '0'));
        buff.append(':');
        buff.append((char)(s/10 + '0'));
        buff.append((char)(s%10 + '0'));
        buff.append(" GMT");
        return buff.toString();
    }

    /* TEST CODE: comparison, timing, etc. */

    private static void testit(java.util.Date d) {
        String mine = formatDate(d);
        String std = rfc1123Format.format(d).substring(0,29);
        if(!mine.equals(std)) {
            System.out.println("Mine: "+mine);
            System.out.println("Std:  "+std);
            System.out.println("Time: "+d.getTime()
                               +" Seconds: "+(d.getTime()/1000 % 86400)
                               +" Milliseconds: "+(d.getTime() % 1000));
        }
    }

    private static void testit(int year, int month, int day) {
        testit(new java.util.Date(year,month,day,12,1,2));
    }

    private static void testit(long milliseconds) {
        testit(new java.util.Date(milliseconds));
    }

    public static void main(String[] args) {
        testit(System.currentTimeMillis());
        testit(69,12,30);
        testit(69,12,31);

        // Compare the two versions for every day from 1850 to 2150
        {
            long t = (new java.util.Date(-50,0,1)).getTime();
            for(int y=0; y<300; y++) {
                for(int m=0; m<12; m++) {
                    for(int d=1; d<31; d++) {
                        testit(t);
                        t += 86397;
                    }
                }
            }
        }


        // Compare every millisecond around the 1999/2000 turnover
        {
            long t = (new java.util.Date(99,11,28)).getTime();
            for(int i=0; i<10*86400; i++)
                testit(t++);
        }

        // Time my version: convert every day from 1970-2020
        long start = System.currentTimeMillis();
        for(int y=70; y<120; y++) {
            for(int m=0; m<12; m++) {
                for(int d=1; d<31; d++) {
                    String mine = formatDate(new java.util.Date(y,m,d));
                }
            }
        }
        System.err.println("Mine: Elapsed: "+(System.currentTimeMillis()-start));


        // Time SimpleDateFormat: convert every day from 1970-2020
        start = System.currentTimeMillis();
        for(int y=70; y<120; y++) {
            for(int m=0; m<12; m++) {
                for(int d=1; d<31; d++) {
                    String std = rfc1123Format.format(new java.util.Date(y,m,d));
                }
            }
        }
        System.err.println("System: Elapsed: "+(System.currentTimeMillis()-start));

    }
}



------------------------------- Speed improvement ?


--- jakarta-tomcat/src/share/org/apache/tomcat/util/CookieTools.java-old        Mon 
Sep 25 15:01:46 2000
+++ jakarta-tomcat/src/share/org/apache/tomcat/util/CookieTools.java    Mon Sep 25 
+16:37:03 2000
@@ -134,8 +134,13 @@
        if (cookie.getMaxAge() >= 0) {
            if (version == 0) {
                buf.append (";Expires=");
-               DateTool.oldCookieFormat.format(new Date( System.currentTimeMillis() + 
cookie.getMaxAge() *1000L) ,buf,
+               if (cookie.getMaxAge() == 0) {
+                       System.out.println("Deleting cookie " + cookie.getName());
+                       DateTool.oldCookieFormat.format(new Date(1000000) ,buf, new 
+FieldPosition(0));
+               } else {
+                       DateTool.oldCookieFormat.format(new Date( 
+System.currentTimeMillis() + cookie.getMaxAge() *1000L) ,buf,
                                                new FieldPosition(0));
+               }
 
            } else {
                buf.append (";Max-Age=");


---------------------------- Cookie patch 1


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to