<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I thought I would report here whats
happening in this particular case.<br>
<br>
The problem is the following code:<br>
<br>
in <tt>$ERL_TOP/erts/emulator/drivers/unix/unix_efile.c:497-502<br>
</tt><tt>...<br>
#if SIZEOF_OFF_T == 4</tt><tt><br>
</tt><tt> pInfo->size_high = 0;</tt><tt><br>
</tt><tt>#else</tt><tt><br>
</tt><tt> pInfo->size_high = (Uint32)(statbuf.st_size
>> 32); // <- there it is</tt><tt><br>
</tt><tt>#endif</tt><tt><br>
</tt><tt> pInfo->size_low = (Uint32)statbuf.st_size;</tt><tt><br>
</tt>...<br>
<br>
This piece of code expects struct stat.st_size to be of type
off_t. I don't know if I can count on the man-page being correct
when declaring that stat st_size is of type off_t? Is it always
the correct .. probably a bad assumption.<br>
<br>
If sizeof(off_t) is 8 (e.g. not 4), this will be executed,<br>
<tt> <br>
pInfo->size_high = (Uint32)(statbuf.st_size >> 32)<br>
<br>
</tt>but if sizeof(statbuf.st_size) is 4 then we have a problem
since<tt> statbuf.st_size >> 32 </tt> will result in an
undefined behaviour.<br>
In this case it will do nothing and happily copy down the value in
high.<br>
<br>
Hence the 32-bit duplication seen up in the shell from
<a class="moz-txt-link-freetext" href="file:read_file_info/1">file:read_file_info/1</a>.<br>
<br>
// Björn-Egil<br>
<br>
On 2014-05-14 05:57, Ahmad Baitalmal wrote:<br>
</div>
<blockquote
cite="mid:CADyHSWAp4EBXS0L6tyeTvebmnDiqRxit-7TYrmj-+bLHO1xGJA@mail.gmail.com"
type="cite">
<div dir="ltr">Björn,
<div>What kind of arch are you running on?</div>
<div><br>
</div>
<div>I'm running on a Ralink RT3052 (MIPS 24KEc V4.12). </div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Tue, May 13, 2014 at 5:36 PM,
Björn-Egil Dahlberg <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:wallentin.dahlberg@gmail.com" target="_blank">wallentin.dahlberg@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Oh no .. trouble in paradise.
<div><br>
</div>
<div>I see the same duplication problem here (nice catch
Erik),</div>
<div>
<div><br>
</div>
<div>1> <<I1:32,I2:32>> =
<<15990163246731:64>>, {I1,I2}.</div>
<div>{3723,3723}</div>
</div>
<div><br>
</div>
<div>Which leads me to think there is a problem in int
efile_fileinfo(...) with the highs and lows.</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">2014-05-14 0:02 GMT+02:00 Ahmad
Baitalmal <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:ahmad@bitbuilder.com" target="_blank">ahmad@bitbuilder.com</a>></span>:
<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Thanks Erik,
<div><br>
</div>
<div>I did a bit more digging, The call for
<a class="moz-txt-link-freetext" href="file:read_file_info">file:read_file_info</a> in cowboy_static.erl is
returning this:
<div><br>
<div><font style="font-size:14px"
face="Monaco">{ok,{file_info,<font
color="#b51a00">15990163246731</font>,regular,read_write,<br>
{{2014,5,13},{20,51,46}},<br>
{{2014,5,9},{19,57,47}},<br>
{{2014,5,13},{19,46,18}},<br>
33188,1,2049,0,1704124,0,0}}</font></div>
<div><br>
</div>
<div>The file is only <font color="#b51a00">3723</font>
bytes. I verified this also on an erl
shell. Same result. </div>
<div><br>
</div>
<div>So it looks like something is up in
kernel-3.0/file.erl when running on a
mipsel chip.</div>
<div><br>
</div>
<div>Everything else is working, except for
this file size issue. Oh and the body is
empty. </div>
<div><br>
</div>
<div>For now, I plan on using an onresponse
hook to load up the file and fix the
content-length as it goes out. :( Not
ideal...</div>
<div><br>
<div>
<div
style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div
style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div
style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="font-family:'Helvetica
Neue';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div
style="font-family:Calibri,sans-serif;margin:0in
0in 0.0001pt;font-size:11pt"><font
color="#4dacff">_</font>_<font
color="#4dacff">_</font>_<font
color="#4dacff">_</font>_<font
color="#4dacff">_</font>_<font
color="#4dacff">_</font>_<font
color="#4dacff">_</font>_<font
style="text-align:-webkit-auto" color="#4dacff">_</font><span
style="text-align:-webkit-auto">_</span></div>
<span><font color="#888888">
<div
style="color:rgb(0,0,0);font-family:Calibri,sans-serif;margin:0in
0in
0.0001pt;font-size:17px"><b><span
style="font-size:15px"><font
color="#223269">Ahmad
Baitalmal</font></span></b></div>
<div
style="font-family:Calibri,sans-serif;margin:0in
0in
0.0001pt;font-size:11pt"><b><span
style="font-size:10pt"><font
color="#2e84e6">CEO
& Co-Founder</font></span></b></div>
<div
style="color:rgb(0,0,0);font-family:Calibri,sans-serif;margin:0in
0in
0.0001pt;font-size:11pt">
<b><span
style="font-size:10pt"><font
color="#223269"><a
moz-do-not-send="true"
href="http://BitBuilder.com" target="_blank">BitBuilder.com</a></font></span></b></div>
<div
style="font-family:Calibri,sans-serif;margin:0in
0in
0.0001pt;font-size:11pt">
<span
style="font-size:13px"><font
color="#9ca7cb"><a
moz-do-not-send="true"
href="tel:650.539.9401" value="+16505399401" target="_blank">650.539.9401</a></font></span></div>
</font></span></div>
</div>
</div>
</div>
</div>
<div>
<div>
<br>
<div>
<div>On May 13, 2014, at 1:13 AM,
Erik Søe Sørensen <<a
moz-do-not-send="true"
href="mailto:eriksoe@gmail.com"
target="_blank">eriksoe@gmail.com</a>>
wrote:</div>
<br>
<blockquote type="cite">
<div dir="ltr">
<div>It's not just a
reverse-endian'ed size...<br>
458453399216374 =
0x'0001'A0F6'0001'A0F6 --
weird duplication...<br>
</div>
(0x1A0F6 = 106742 = 104.2KB, so
that part fits.)<br>
</div>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">2014-05-13
1:10 GMT+02:00 Ahmad Baitalmal
<span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:ahmad@bitbuilder.com"
target="_blank">ahmad@bitbuilder.com</a>></span>:<br>
<blockquote
class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Thanks Loïc,
<div><br>
</div>
<div>It now runs and I can
connect. I thought I
read somewhere that relx
automatically started
the related apps. I
guess it doesn't always.
<div><br>
</div>
<div>There is something
wrong still, I'm
getting this error for
all files in the
browser.</div>
<div><span
style="color:rgb(255,0,0);font-family:Menlo,monospace;font-size:11px;white-space:pre-wrap"><a class="moz-txt-link-freetext" href="net::ERR_CONTENT_LENGTH_MISMATCH">net::ERR_CONTENT_LENGTH_MISMATCH</a></span><br>
</div>
<div><br>
</div>
<div>I checked the
headers and cowboy is
reporting the header "<font
color="#3d85c6"><b>Content-Length:</b></font>
<font color="#b45f06">458453399216374</font>"
for a file that is
only 104K.<br>
</div>
</div>
<div><br>
</div>
<div>Could this be a
problem with cowboy
running on a
little-endian machine
(mipsel)?</div>
<div><br>
</div>
<div>Thanks,</div>
</div>
<div class="gmail_extra">
<div>
<div><br>
<br>
<div
class="gmail_quote">
On Sun, May 11, 2014
at 10:32 PM, Loïc
Hoguin <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span>
wrote:<br>
<blockquote
class="gmail_quote"
style="margin:0 0
0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">You
didn't start the
cowboy
dependencies, I'm
not sure how it
could have worked
on your Mac.
Cowboy requires
crypto, cowlib and
ranch to be
started to run.
Try
application:ensure_all_started(cowboy)
instead and it'll
do that for you.
<div>
<div><br>
<br>
On 05/12/2014
02:20 AM,
Ahmad
Baitalmal
wrote:<br>
</div>
</div>
<blockquote
class="gmail_quote"
style="margin:0
0 0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">
<div>
Hi,<br>
Im going crazy
trying to
solve this.<br>
<br>
Works on my
Mac, but when
I copy to a
linux router
(OpenWRT, R17,
cowboy<br>
0.9.0) it give
me the error
below.<br>
Is this a
cowboy or
erlang
gen_server
issue?<br>
I tried http,
same result.
So it's not an
ssl issue. I
can't tell
what<br>
the error
is...<br>
<br>
<br>
%
---------------------
This is my app
code that
starts cowboy<br>
-module(onion_app).<br>
-behavior(application).<br>
-export([start/2]).<br>
-export([stop/0]).<br>
-export([stop/1]).<br>
-include("common.hrl").<br>
<br>
start(_Type,
_Args) -><br>
application:start(cowboy),<br>
Dispatch =
cowboy_router:compile([<br>
{'_', [<br>
{"/",
cowboy_static,
{priv_file,
onion
,"index.html"}},<br>
{"/[...]",
cowboy_static,
{priv_dir,
onion , ""}}<br>
]}<br>
]),<br>
RootDir =
code:root_dir(),<br>
Port = 443,<br>
cowboy:start_https(my_https_listener,
10,[<br>
{port,
Port},<br>
{certfile,
RootDir ++
"/ssl/onion.crt"},<br>
{keyfile,
RootDir ++
"/ssl/onion.key"}<br>
],<br>
[<br>
{env,
[{dispatch,
Dispatch}]}<br>
]<br>
)<br>
onion_sup:start_link().<br>
stop(_State)
-><br>
ok.<br>
<br>
<br>
%
---------------------
I'm getting
this error :(<br>
Exec:
/mnt/sda1/onion/erts-6.0/bin/erlexec
-boot<br>
/mnt/sda1/onion/releases/1/onion -env ERL_LIBS<br>
/mnt/sda1/onion/releases/1/lib
-config<br>
/mnt/sda1/onion/releases/1/sys.config -args_file<br>
/mnt/sda1/onion/releases/1/vm.args -- console<br>
<br>
=INFO
REPORT====
11-May-2014::03:45:55
===<br>
application:
onion<br>
exited:
{bad_return,<br>
{{onion_app,start,[normal,[]]},<br>
{'EXIT',<br>
{noproc,<br>
{gen_server,call,<br>
[ranch_sup,<br>
{start_child,<br>
{{ranch_listener_sup,my_https_listener},<br>
{ranch_listener_sup,start_link,<br>
[my_https_listener,10,ranch_ssl,<br>
[{port,443},<br>
{certfile,"/mnt/sda1/onion/ssl/onion.crt"},<br>
{keyfile,"/mnt/sda1/onion/ssl/onion.key"}],<br>
cowboy_protocol,<br>
[{env,<br>
[{dispatch,<br>
[{'_',[],<br>
[{[],[],cowboy_static,<br>
{priv_file,onion,"index.html"}},<br>
{[<<"tomato">>,'...'],[],tomato,[tomato]},<br>
{['...'],<br>
[],cowboy_static,<br>
{priv_dir,onion,[]}}]}]}]}]]},<br>
permanent,5000,supervisor,<br>
[ranch_listener_sup]}},<br>
infinity]}}}}}<br>
type:
permanent<br>
Eshell V6.0
(abort with
^G)<br>
(onion@ROC)1>
{"Kernel pid<br>
terminated",application_controller,"{application_start_failure,onion,{bad_return,{{onion_app,start,[normal,[]]},{'EXIT',{noproc,{gen_server,call,[ranch_sup,{start_child,{{ranch_listener_sup,my_https_listener},{ranch_listener_sup,start_link,[my_https_listener,10,ranch_ssl,[{port,443},{certfile,\"/mnt/sda1/onion/ssl/onion.crt\"},{keyfile,\"/mnt/sda1/onion/ssl/onion.key\"}],cowboy_protocol,[{env,[{dispatch,[{'_',[],[{[],[],cowboy_static,{priv_file,onion,\"index.html\"}},{['...'],[],cowboy_static,{priv_dir,onion,[]}}]}]}]}]]},permanent,5000,supervisor,[ranch_listener_sup]}},infinity]}}}}}}"}<br>
<br>
<br>
Thanks,<br>
<br>
--<br>
Ahmad<br>
___________<br>
<a
moz-do-not-send="true"
href="tel:650.539.9395" value="+16505399395" target="_blank">650.539.9395</a><br>
<br>
Sent from my
iPhon<br>
<br>
<br>
</div>
_______________________________________________<br>
erlang-questions
mailing list<br>
<a
moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a
moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
<span><font
color="#888888">
</font></span></blockquote>
<span><font
color="#888888">
<br>
-- <br>
Loïc Hoguin<br>
<a
moz-do-not-send="true"
href="http://ninenines.eu/" target="_blank">http://ninenines.eu</a><br>
</font></span></blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
</div>
</div>
<div dir="ltr">
<div>Ahmad</div>
<div>___________</div>
<div><a
moz-do-not-send="true"
href="tel:650.539.9395" value="+16505399395" target="_blank">650.539.9395</a></div>
<div><br>
</div>
Sent from my iPhone</div>
</div>
<br>
_______________________________________________<br>
erlang-questions mailing
list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org"
target="_blank">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org"
target="_blank">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div>Ahmad</div>
<div>___________</div>
<div>650.539.9395</div>
<div><br>
</div>
Sent from my iPhone</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>