Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1 [solved]

2009-05-13 Thread Gustaf Neumann

Dear Alexey,

Glad the problem is resolved. i commited a slightly
modified version of the patch (moved the static definition
to the right place in the file, made sure that year is always
4 digits) to CVS head on sourceforge. The patch makes
perfectly sense for non en* locale settings.

It would have saved all of us time if you would have
told us earlier that you are using a patched version.
I have checked the debian patches, there are no
other .c or .h files in the change set, so hopefully
this source of confusion is closed.

Many thanks for your help.

best regards
-gustaf neumann

PS: Tom, can you commit your improvements to queue.c
as well to cvs head?

Alexey Pechnikov schrieb:

Hello!

I'm sorry but the problem is produced by patch for non-english locale. 
This patch use wrong format string:

snprintf(buf, 40, %s, %d %s %d %02d:%02d:%02d GMT,

I did fix the bug and I'm think this patch may be added to upstream.

Patch is here:
http://mobigroup.ru/files/aol4.5.1/httptime.c.diff

Thanks for help!

=
--- httptime.c.orig 2003-01-18 22:24:20.0 +0300
+++ httptime.c  2009-05-12 20:14:24.0 +0400
@@ -27,6 +27,9 @@
  * version of this file under either the License or the GPL.
  */

+static char *weekdays_names[7] =
+{ Sun, Mon, Tue, Wed, Thu, Fri, Sat };
+

 /*
  * time.c --
@@ -92,11 +95,14 @@
 }

 /*
- * This will most likely break if the locale is not an english one.
+ * Using snprintf instead of strftime to always use english names
  * The format is RFC 1123: Sun, 06 Nov 1997 09:12:45 GMT
  */

-strftime(buf, 40, %a, %d %b %Y %H:%M:%S GMT, tmPtr);
+snprintf(buf, 40, %s, %02d %s %d %02d:%02d:%02d GMT,
+weekdays_names[tmPtr-tm_wday], tmPtr-tm_mday,
+month_names[tmPtr-tm_mon], tmPtr-tm_year + 1900,
+tmPtr-tm_hour, tmPtr-tm_min, tmPtr-tm_sec);

 Ns_DStringAppend(pds, buf);
 return pds-string;


Best regards, Alexey Pechnikov.
http://pechnikov.tel/


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.
  



--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-10 Thread Alexey Pechnikov
Hello!

On Sunday 10 May 2009 00:32:35 Tom Jackson wrote:
 I did notice an interesting comment in the C source:
 from nsd/httptime.c:
 /*
  * This will most likely break if the locale is not an english one.
  * The format is RFC 1123: Sun, 06 Nov 1997 09:12:45 GMT
  */
 
 strftime(buf, 40, %a, %d %b %Y %H:%M:%S GMT, tmPtr);
 
 So, is your locale set to an english one?

My locale is ru_RU.UTF-8.

Best regards, Alexey Pechnikov.
http://pechnikov.tel/


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-10 Thread Alexey Pechnikov
Hello!

On Sunday 10 May 2009 15:48:21 Gustaf Neumann wrote:
 Try in an aolserver script:
 
set ::env(LANG) C.UTF-8
ns_log notice START of times [::ns_http_time 0]
 
 Most likely, it will work as expected
 
 My recommendation is to set the LANG in the startup file.
 Maybe, aolserver should force a LANG/LOCALE to avoid
 unexpected behavior...

It's bad because russian strings in scripts and from databases wll be corrupted.

Best regards, Alexey Pechnikov.
http://pechnikov.tel/


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-10 Thread Dossy Shiobara

On 5/10/09 9:59 AM, Alexey Pechnikov wrote:

On Sunday 10 May 2009 15:48:21 Gustaf Neumann wrote:

Try in an aolserver script:

set ::env(LANG) C.UTF-8
ns_log notice START of times [::ns_http_time 0]


It's bad because russian strings in scripts and from databases wll be corrupted.


Alexey,

Have you confirmed this through empirical testing?  There is a 
difference between the locale that the system libc functions use (i.e., 
env(LANG)) vs. what AOLserver's encoding is set to (through the config 
.tcl ns_params).


It might be worth investigating as to whether setting the system locale 
and properly configuring the AOLserver encoding (need a good HOWTO on 
this) will behave for you.



--
Dossy Shiobara  | do...@panoptic.com | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on. (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Tom Jackson
On Sat, 2009-05-09 at 13:18 +0400, Alexey Pechnikov wrote:
 Hello!
 
 As I did find
 [ns_httptime 0] 
 Thu, 1 Jan 1970 00:00:00 GMT
 
 It's wrong! Correct value is Thu, 01 Jan 1970 00:00:00 GMT. So 
 cache control by headers If-Modified-Since and If-None-Match
 refused.

You can use this as a temporary replacement:

proc ::ns_httptime { seconds } {

return [clock format $seconds -format %a, %d %b %Y %H:%M:%S %Z -gmt 1]

}

tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Alexey Pechnikov
Hello!

On Saturday 09 May 2009 20:11:11 Tom Jackson wrote:
 You can use this as a temporary replacement:
 
 proc ::ns_httptime { seconds } {
 
 return [clock format $seconds -format %a, %d %b %Y %H:%M:%S %Z -gmt 1]
 
 }

Tnx, but AOL internals set wrong header again
Last-Modified: Sat, 9 May 2009 18:07:40 GMT

I did find this error by testing AOL internal caching.

My custom cache function doesn't have the problem:

set mtime [file mtime $fname]

... create gzipped version in cache if needed ...

set none_header [ns_set iget [ns_conn headers] If-None-Match]
set none_header [clock scan $none_header]
set since_header [ns_set iget [ns_conn headers] If-Modified-Since]
set since_header [clock scan $since_header]
if {$none_header == $mtime || $since_header == $mtime} {
ns_return 304 {} {}
return
}

... return original or gzipped file ...


Best regards, Alexey Pechnikov.
http://pechnikov.tel/


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Jeff Hobbs

On 09/05/2009 1:32 PM, Tom Jackson wrote:
Anyone know if the Tcl clock functions are thread-safe? 


Yes, they are.  8.4 had a few issues earlier on, but 8.5 has a 
completely rewritten 'clock' that certainly does away with those issues.


Jeff


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Tom Jackson
On Sat, 2009-05-09 at 13:36 -0700, Jeff Hobbs wrote:
 On 09/05/2009 1:32 PM, Tom Jackson wrote:
  Anyone know if the Tcl clock functions are thread-safe? 
 
 Yes, they are.  8.4 had a few issues earlier on, but 8.5 has a 
 completely rewritten 'clock' that certainly does away with those issues.

How about the latest 8.4 version? Nothing wrong with 8.5, but there are
a few incompatibilities between the two.

This may not be important, my only reason for asking is the potential
problem with a non-english locale, but that seems just as likely to
affect Tcl. 

The code comment may just affect the month/day names.

I think Alexey's issue must be coming from some other code path. 

tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Dossy Shiobara

On 5/9/09 5:14 PM, Jeff Hobbs wrote:


The last known OS thread-safety call issues in 8.4 were with
gethostbyname, et al and corrected for 8.4.14 (Y2006).  The checks for
calls like localtime_r have been in since longer.  Assuming strftime is
mt-safe, all is ok (the man page is silent on that, but it does print
into a passed in buffer).


I haven't looked at Tcl 8.5 source, but has clock ... -gmt been fixed 
so that it doesn't diddle with env(TZ) any more, which isn't 
thread-safe.  I remember that there's Tcl mutexes around the env(TZ) 
diddling, but that isn't safe when an application embeds Tcl and 
modifies env(TZ) as well but doesn't have access to the mutex that Tcl's 
clock is using.


I was hoping that newclock addressed this, and newclock is in Tcl 8.5, 
right?


--
Dossy Shiobara  | do...@panoptic.com | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on. (p. 70)


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Jeff Hobbs

On 9-May-09, at 2:46 PM, Tom Jackson wrote:

On Sat, 2009-05-09 at 14:14 -0700, Jeff Hobbs wrote:

You mention
incompatibilities - what are they?  It should be 100% upwards
compatible, though it has new features.  However, it isn't  
necessarily

100% compatible on the date scan detection, since 8.4- was always
guess-heuristic based, while 8.5 is more deterministic.


I was referring to 8.4.x compared to 8.5.x, not just [clock]. I was
thinking that if you upgrade to 8.5.x you needed to do a code  
review, is

this not necessary?


Minor version updates should be compatible in Tcl.  There is the rare  
case of taking what was an error condition and doing something else,  
but if you aren't relying on some undocumented private behavior, a  
code review isn't required (unless you want to take advantage of newer  
features).


Jeff


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.


Re: [AOLSERVER] ns_httptime format error in AOL 4.5.1

2009-05-09 Thread Tom Jackson
On Sat, 2009-05-09 at 19:30 -0400, Dossy Shiobara wrote:
 On 5/9/09 5:14 PM, Jeff Hobbs wrote:
 
  The last known OS thread-safety call issues in 8.4 were with
  gethostbyname, et al and corrected for 8.4.14 (Y2006).  The checks for
  calls like localtime_r have been in since longer.  Assuming strftime is
  mt-safe, all is ok (the man page is silent on that, but it does print
  into a passed in buffer).
 
 I haven't looked at Tcl 8.5 source, but has clock ... -gmt been fixed 
 so that it doesn't diddle with env(TZ) any more, which isn't 
 thread-safe.  I remember that there's Tcl mutexes around the env(TZ) 
 diddling, but that isn't safe when an application embeds Tcl and 
 modifies env(TZ) as well but doesn't have access to the mutex that Tcl's 
 clock is using.
 
 I was hoping that newclock addressed this, and newclock is in Tcl 8.5, 
 right?

Of course this is why we have abstraction APIs, which are so prominent
in AOLserver. Even if an API is, at an initial point, exactly the same
as the basis API, it is possible, even likely, that changes will be
made. If an abstraction API had been introduced early on, then client
code would remain protected from expected changes. It is hard to explain
the importance of creating a layered API, until you are faced with the
need to change an implementation without changing the client API.

AOLserver is a very good example of planning for future change.

tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
lists...@listserv.aol.com with the
body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: 
field of your email blank.