running hv3 as tclkit

42 views
Skip to first unread message

jemptymethod

unread,
Sep 1, 2009, 6:00:26 AM9/1/09
to tkhtml3
When I try to run hv3 as a tclkit rather than a windows exe I get the
following behavior, not when the page immediately loads, but whenever
any URLs are subsequently requested.

1) Several errors beginning with the following: can't read "state
(sock)": no such element in array
2) The page eventually resolves but does not render properly. It
renders as though Javascript and/or CSS is disabled, with any dynamic
layout not being applied.

Specfically the entire error is below. At a very high level I
understand: after the upvar on line 568 of hv3_http.tcl, within
'proc ::hv3::HttpFinish', it appears the array named 'state' exists
but does not for some reason contain the entry corresponding to
'sock'.

I'm not the world's greatest TCL programmer by any means however and
will probably get a little lost as I try to backtrace this. And
anyway I have to head to my day job now ;) Any suggestions as to how
to work around this when running as a tclkit would be appreciated.

can't read "state(sock)": no such element in array
while executing
"CloseSocket $state(sock) $token"
(procedure "::http::FinishReal" line 12)
invoked from within
"::http::FinishReal ::http::1 {can't read "state(sock)": no such
element in array}"
("eval" body line 1)
invoked from within
"eval [linsert $args 0 ::http::FinishReal $token]"
(procedure "Finish" line 7)
invoked from within
"Finish $token $err"
(procedure "http::Event" line 151)
invoked from within
"http::Event sock1740 ::http::1"

mscdex

unread,
Sep 3, 2009, 9:29:27 PM9/3/09
to tkhtml3
On Sep 1, 6:00 am, jemptymethod <jemptymet...@gmail.com> wrote:
> When I try to run hv3 as a tclkit rather than a windows exe I get the
> following behavior, not when the page immediately loads, but whenever
> any URLs are subsequently requested.
>
> 1) Several errors beginning with the following: can't read "state
> (sock)": no such element in array
> 2) The page eventually resolves but does not render properly.  It
> renders as though Javascript and/or CSS is disabled, with any dynamic
> layout not being applied.
>
> Specfically the entire error is below.  At a very high level I
> understand: after the upvar on line 568 of hv3_http.tcl, within
> 'proc ::hv3::HttpFinish', it appears the array named 'state' exists
> but does not for some reason contain the entry corresponding to
> 'sock'.
>
> I'm not the world's greatest TCL programmer by any means however and
> will probably get a little lost as I try to backtrace this.  And
> anyway I have to head to my day job now ;)  Any suggestions as to how
> to work around this when running as a tclkit would be appreciated.
>
> can't read "state(sock)": no such element in array
>     while executing
> "CloseSocket $state(sock) $token"
>     (procedure "::http::FinishReal" line 12)
>     invoked from within
> [ ... ]

I'm receiving the same errors when using eTcl 1.0.1 to run hv3.
However, it's hit or miss if the page will render at all. It seems the
first page I go to will show up partially (either no CSS or CSS is not
quite right) but any subsequent attempts to go to another URL by
entering an address in the address bar or by clicking a link fails
with the "state(sock)" error. Everything else seems to work just fine
though.

If someone can fix this, it would be great to have as an alternative
to Pocket Internet Explorer on older Windows CE devices!

jemptymethod

unread,
Sep 4, 2009, 1:43:10 PM9/4/09
to tkhtml3
I don't know that this entirely fixes things per se. However upon
further inspection it seems that the offending
proc, ::hv3::HttpFinish, is being used as a replacement for the
default implementation of http::Finish in the tcl library.

So, to get things to "work", at least without error messages, when
invoking hv3 as a starkit, I merely commented out the 2 last
executable lines at the very bottom of hv3_httpd.tcl, those beginning
"rename"

# Install the wrapper.
#rename ::http::Finish ::http::FinishReal
#rename ::hv3::HttpFinish ::http::Finish
#-----------------------------------------------------------------------

This has the effect of making hv3 use the default http::Finish and
this has "worked" for me, in that I don't get any errors. So use my
"fix" at your own risk.

However, as I compose this email I believe I'm beginning to understand
this all a bit more deeply. So I may follow up on the list in the
near future with subsequent findings.

jemptymethod

unread,
Sep 4, 2009, 2:21:19 PM9/4/09
to tkhtml3
Ok, I think I have a sufficient understanding of what's going on to
suggest the following solution. It "works" for me, though still, my
Tcl is rusty enough that it might be best if this were confirmed by
other members of this list, or even the general Tcl usenet group.

Anyway here goes. With reference to the source code below.

What the author(s) of hv3 seems to have been trying to achieve is to
call the default http::Finish with the 3rd arg always set to 0. The
default http::Finish in the end gets called by the final line
of ::hv3::Finish, the eval/linsert line. But before this is called,
for some reason the author(s) of hv3 saw fit to not only close $state
(sock), but to unset it. This seems to be causing a problem within
the default http::Finish, because it to tries to close $state(sock),
but this results in the error we've been experiencing because it's
already been unset.

So simply commenting out the unset line seems to be the least invasive
solution. What mystifies me is why this is happening for me when I
run the code as a starkit but not the executable. For the time being
I am willing to cross that bridge at another time. Perhaps the
executable is built from slightly different code? But then, I'm
assuming that when states they are experiencing the same problem, they
are running the .exe and not the starkit.

# Declare a wrapper around ::http::Finish
proc ::hv3::HttpFinish {token args} {
upvar 0 $token state
catch {
close $state(sock)
#unset state(sock)
}
eval [linsert $args 0 ::http::FinishReal $token]
}

# Install the wrapper.
rename ::http::Finish ::http::FinishReal
Reply all
Reply to author
Forward
0 new messages