Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 21220 invoked from network); 10 Oct 2010 13:11:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Oct 2010 13:11:48 -0000 Received: (qmail 63170 invoked by uid 500); 10 Oct 2010 13:11:45 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 63032 invoked by uid 500); 10 Oct 2010 13:11:42 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 63023 invoked by uid 99); 10 Oct 2010 13:11:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Oct 2010 13:11:42 +0000 X-ASF-Spam-Status: No, hits=-1.3 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of aw@ice-sa.com does not designate 199.46.245.198 as permitted sender) Received: from [199.46.245.198] (HELO tus-mailout1.raytheon.com) (199.46.245.198) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Oct 2010 13:11:34 +0000 Received: from dmint00.directory.ray.com ([147.25.154.124]) by tus-mailout1.raytheon.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id o9ADBAKU015430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 10 Oct 2010 13:11:11 GMT Received: from raytheon.com (localhost [127.0.0.1]) by dmint00.directory.ray.com (Switch-3.4.3/Switch-3.4.1) with ESMTP id o9ADB9L9032536 sender aw@ice-sa.com; Sun, 10 Oct 2010 13:11:09 GMT Message-Id: <1783560185.1286716248634@ace.smi> Date: Sun, 10 Oct 2010 13:10:48 +0000 From: =?ISO-8859-1?Q?Andr=E9_Warnier?= To: Tomcat Users List Subject: Re: Disable class monitoring for reloading container classes Cc: "Caldarale, Charles R" MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Virus-Checked: Checked by ClamAV on apache.org This email contained a .zip file attachment. Raytheon does not allow email = attachments that are considered likely to contain malicious code. For your = protection this attachment has been removed. If this email is from an unknown source, please simply delete this email. If this email was expected, and it is from a known sender, you may follow t= he below suggested instructions to obtain these types of attachments. + Instruct the sender to enclose the file(s) in a ".zip" compressed file, a= nd rename the ".zip" compressed file with a different extension, such as, "= .rtnzip". Password protecting the renamed ".zip" compressed file adds an a= dditional layer of protection. When you receive the file, please rename it = with the extension ".zip". Additional instructions and options on how to receive these attachments can= be found at: http://security.it.ray.com/antivirus/extensions.html http://security.it.ray.com/news/2007/zipfiles.html Should you have any questions or difficulty with these instructions, please= contact the Help Desk at 877.844.4712 --- Caldarale, Charles R wrote: > From: Andr=E9 Warnier [mailto:aw@ice-sa.com]=20 > Subject: Re: Disable class monitoring for reloading container classes >=20 >> thanks for the perl program. >=20 > I would not introduce yet another variable into situation, since perl is = not involved in any way with your Tomcat installation, and we don't know ho= w a particular perl implementation might decide to handle timestamps. I re= commended C and Java programs since those underly Tomcat, and trying to pin= point the exact location of the time discrepancy is likely crucial to eithe= r fixing it or working around it. Until the actual source of the problem i= s determined, you're just throwing darts - blindfolded. >=20 Charles, I would not dream of disagreeing with you on a Java matter, but in= this case, I will. The perl interpreter is usually as close as you can get to the underlying s= ystem's=20 libraries without resorting to C, and a perl script is an order of magnitud= e easier to=20 handle than a C program. What would be really nice, is if someone wrote a quick Java equivalent to t= he perl script=20 I submitted. Now if you *really* insist, the modified version of the perl program, below= , will=20 explicitly use a couple of C functions, themselves using the builtin C stru= ctures to get=20 the file's "last modified" time. Running C in perl, scary stuff.. ;-) The interesting bit however, is when I run this program alternatively on my= Windows XP PC=20 and on a Linux server, both set for the same "Berlin" timezone (GMT+1, curr= ent +1h of DST,=20 so GMT+2), I get different answers. For a file in each case modified a few seconds ago, which would be around 1= 2:00 GMT, a) Windows shows : C:\Programs\local>perl showmodified.pl showmodified.pl System raw timestamp : 1286712069 Current GMT time (no DST) : 2010/10/10-12:01:09 Current local time (with DST) : 2010/10/10-14:01:09 File [showmodified.pl]: last modified timestamp : 1286712049 the file was last modified 20 seconds ago last modified as GMT time (no DST) : 2010/10/10-12:00:49 last modified as local time (with DST) : 2010/10/10-14:00:49 b) Linux shows : aw@colin:~$ perl showmodified_C.pl showmodified_C.pl System raw timestamp : 1286712131 Current GMT time (no DST) : 2010/10/10-12:02:11 Current local time (with DST) : 2010/10/10-14:02:11 File [showmodified_C.pl]: last modified timestamp : 1286708460 the file was last modified 3671 seconds ago last modified as GMT time (no DST) : 2010/10/10-11:01:00 last modified as GMT time (no DST), as C would have it : 2010/10/10-11:01:0= 0 last modified as local time (with DST) : 2010/10/10-13:01:00 last modified as local time (with DST), as C would have it : 2010/10/10-13:= 01:00 aw@colin:~$ Even more surprising, for once it seems (to me) that Windows is actually mo= re logical. Or else, the underlying C libraries of Linux somehow adjust the values I'm = getting. Windows appears to record (and return) the last modified time of a file as = GMT/UTC, while=20 Linux apparently records it as "local time", but without the DST adjustment= . Or is it recording it as GMT, plus the DST adjustment ? (Unfortunately, the normal timezone here is GMT+1, and the DST adjustment r= ight now is=20 also +1 h, so I do not know which is which.) In any case, I get + one hour difference as compared to Windows, and what I= get is nonsense. The file was not modified 3671 seconds ago, it was modified 71 seconds ago. Unfortunately also, changing the system time or its timezone, on the Linux = system on which=20 I am testing, is not an option for now. Finding information on the web specifically about different OS'es practices= in terms of=20 recording "last modified" times is apparently not easy. But I did find this rather old discussion of a similar issue, which seems t= o say the=20 opposite of what I claim above : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D4860999 Can anyone smarter than I am throw more light on the subject ? Which, to bring it back closer to topic, could be rephrased as : does a JVM= used by Tomcat=20 always return a "correct" (or at least comparable) last modified timestamp = for an=20 application file, independently of the platform, time zones, and DST adjust= ments ? Perl script (also attached, zipped) : Note : you may need for this to first run : perl -MCPAN -e "install Inline::C" (and answer yes to all the questions) ---- start copying here --------- #!/usr/bin/perl # showmodified_C.pl use warnings; use strict; my ($sec,$min,$hour,$mday,$mon,$year); my $subject =3D $ARGV[0] or die "missing argument"; die "File not found or not readable : $!" unless ((-f $subject) && (-r $sub= ject)); my $now =3D time(); print "System raw timestamp : $now\n"; ($sec,$min,$hour,$mday,$mon,$year) =3D gmtime($now); print "Current GMT time (no DST) :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; ($sec,$min,$hour,$mday,$mon,$year) =3D localtime($now); print "Current local time (with DST) :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; print "File [$subject]:\n"; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) =3D stat($subject); print "last modified timestamp : $mtime\n"; print "the file was last modified ",$now-$mtime," seconds ago\n"; ($sec,$min,$hour,$mday,$mon,$year) =3D gmtime($mtime); print "last modified as GMT time (no DST) :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; ($year,$mon,$mday,$hour,$min,$sec) =3D C_gmtime($mtime); print "last modified as GMT time (no DST), as C would have it :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; ($sec,$min,$hour,$mday,$mon,$year) =3D localtime($mtime); print "last modified as local time (with DST) :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; ($year,$mon,$mday,$hour,$min,$sec) =3D C_localtime($mtime); print "last modified as local time (with DST), as C would have it :=20 ",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$mi= n,$sec),"\n"; use Inline C =3D> <<'END_OF_C_CODE'; #include void C_localtime(int utc) { struct tm *ltime =3D localtime(&utc); Inline_Stack_Vars; Inline_Stack_Reset; Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_year))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_mon))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_mday))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_hour))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_min))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_sec))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_isdst))); Inline_Stack_Done; } void C_gmtime(int utc) { struct tm *ltime =3D gmtime(&utc); Inline_Stack_Vars; Inline_Stack_Reset; Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_year))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_mon))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_mday))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_hour))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_min))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_sec))); Inline_Stack_Push(sv_2mortal(newSViv(ltime->tm_isdst))); Inline_Stack_Done; } END_OF_C_CODE exit; ---- stop copying here --------- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org