mtime problem.

17 views
Skip to first unread message

tienlx

unread,
May 10, 2008, 6:18:10 AM5/10/08
to MochiWeb
Hi all,
I encountered a problem when server static file.

=CRASH REPORT==== 10-May-2008::16:35:56 ===
crasher:
pid: <0.55.0>
registered_name: []
exception error: bad argument
in function erlang:universaltime_to_localtime/1
called as erlang:universaltime_to_localtime({{1969,12,31},
{23,59,59}})
in call from calendar:local_time_to_universal_time_dst/1
in call from httpd_util:rfc1123_date/1
in call from mochiweb_request:serve_file/3
in call from mochiweb_http:headers/4
initial call:
mochiweb_socket_server:acceptor_loop({<0.54.0>,#Port<0.123>,

#Fun<mochiweb_http.1.62821608>})

So I tried file:read_file_info/1 function and have result below:
> file:read_file_info("/home/ti/erlang/web/test/priv/www/index.html").
{ok,{file_info,88,regular,read_write,
{{2008,5,10},{16,14,15}},
{{2008,5,10},{18,36,56}},
{{2008,5,10},{18,36,56}},
33188,1,98,14518194,3630455,1001,1001}}
ok, its mtime is {{2008,5,10},{18,36,56}}. And i continue with:
8> httpd_util:rfc1123_date({{2008,5,10},{18,36,56}}).
** exception error: bad argument
in function erlang:universaltime_to_localtime/1
called as erlang:universaltime_to_localtime({{1969,12,31},
{23,59,59}})
in call from calendar:local_time_to_universal_time_dst/1
in call from httpd_util:rfc1123_date/1

It seem rfc1123_date/1 doesn't accept any date I given:

9> httpd_util:rfc1123_date({{2009,5,10},{18,36,56}}).
** exception error: bad argument
in function erlang:universaltime_to_localtime/1
called as erlang:universaltime_to_localtime({{1969,12,31},
{23,59,59}})
in call from calendar:local_time_to_universal_time_dst/1
in call from httpd_util:rfc1123_date/1
10> httpd_util:rfc1123_date({{2009,5,3},{8,6,3}}).
** exception error: bad argument
in function erlang:universaltime_to_localtime/1
called as erlang:universaltime_to_localtime({{1969,12,31},
{23,59,59}})
in call from calendar:local_time_to_universal_time_dst/1
in call from httpd_util:rfc1123_date/1

I current use Freebsd 7.0. Don't know what happen, it'd worked great
before.
Any opinion?

Regards,
Tien

tienlx

unread,
May 10, 2008, 6:22:09 AM5/10/08
to MochiWeb
Also, here is my Erlang/OTP info:
[{release,"OTP APN 181 01","R12B","5.6.1",
[{kernel,"2.12.1","/usr/local/lib/erlang/lib/
kernel-2.12.1"},
{stdlib,"1.15.1","/usr/local/lib/erlang/lib/
stdlib-1.15.1"},
{sasl,"2.1.5.2","/usr/local/lib/erlang/lib/sasl-2.1.5.2"}],
permanent}].

Thanks,
Tien

Bob Ippolito

unread,
May 10, 2008, 2:59:52 PM5/10/08
to moch...@googlegroups.com
That looks like an Erlang or FreeBSD bug in httpd_util:rfc1123_date/1
or something it calls, that module isn't part of mochiweb. Works fine
here on OS X.

1> httpd_util:rfc1123_date({{2008,5,10},{18,36,56}}).
"Sun, 11 May 2008 01:36:56 GMT"

Bob Ippolito

unread,
May 10, 2008, 4:14:42 PM5/10/08
to moch...@googlegroups.com
Looking deeper it seems that all
calendar:local_time_to_universal_time_dst does is call into the VM's
datetime functionality several times:

local_time_to_universal_time_dst(DateTime) ->
UtDst = erlang:localtime_to_universaltime(DateTime, true),
Ut = erlang:localtime_to_universaltime(DateTime, false),
%% Reverse check the universal times
LtDst = erlang:universaltime_to_localtime(UtDst),
Lt = erlang:universaltime_to_localtime(Ut),
...

One of those calls must be doing the wrong thing on your platform. You
should report this to the erlang mailing list, there isn't much we can
do about the problem in mochiweb. They probably need to know what your
TZ variable is also. We don't have any FreeBSD 7 machines so I can't
go any deeper on this myself.

-bob

tle

unread,
May 13, 2008, 10:05:13 AM5/13/08
to MochiWeb
Thanks Bob. This thing happen when i change the timezone. I'll post it
on erlang mailling list.

Regards,
Tien


On May 11, 3:14 am, "Bob Ippolito" <b...@redivi.com> wrote:
> Looking deeper it seems that all
> calendar:local_time_to_universal_time_dst does is call into the VM's
> datetime functionality several times:
>
> local_time_to_universal_time_dst(DateTime) ->
> UtDst = erlang:localtime_to_universaltime(DateTime, true),
> Ut = erlang:localtime_to_universaltime(DateTime, false),
> %% Reverse check the universal times
> LtDst = erlang:universaltime_to_localtime(UtDst),
> Lt = erlang:universaltime_to_localtime(Ut),
> ...
>
> One of those calls must be doing the wrong thing on your platform. You
> should report this to the erlang mailing list, there isn't much we can
> do about the problem in mochiweb. They probably need to know what your
> TZ variable is also. We don't have any FreeBSD 7 machines so I can't
> go any deeper on this myself.
>
> -bob
>
> On Sat, May 10, 2008 at 11:59 AM, Bob Ippolito <b...@redivi.com> wrote:
> > That looks like an Erlang or FreeBSD bug in httpd_util:rfc1123_date/1
> > or something it calls, that module isn't part of mochiweb. Works fine
> > here on OS X.
>
> > 1> httpd_util:rfc1123_date({{2008,5,10},{18,36,56}}).
> > "Sun, 11 May 2008 01:36:56 GMT"
>
Reply all
Reply to author
Forward
0 new messages