themage has asked for the wisdom of the Perl Monks concerning the following question:

Wise ones,

I'm using HTML::Mason for the web interface for a lib used to configure network hardware over telnet.

Everything seemed to work nice and smooth, until I tried this outside my lab environment.

Several places in my code I have things like this:
print STDERR "Going to call longfunction()\n"; my $val=$nethard->longfunction(); print STDERR "After the call to longfunction()\n";
longfunction executes several telnet commands, depende on the exact longfunction.

The behavior I don't understand is that the first message is correctly printed, the longfunction is called, and looks to terminate ok, but any code after that is skipped, as if each component had a timeout, that I can't find anywhere, and that terminate the component.

Even if this is the case (which I thing is strange, once I had - and still have - Mason pages with queries that execute for several minutes), I think some error should be logged to STDERR (apache error_log) and it isn't.

Any idea? Anyone know what I should look for?

Thank you very much every one.

Update: did found the problem. It was a timeout in Net::Telnet that turned into a die (cmd call without -errmode=>'return'). Still confuse me anyway, as I expected that nothing after that component call should display, and expected the die to be displayed as a mason error, as every other die, and that doesn't happen. The page renders completly just as if the component did return ok.

Replies are listed 'Best First'.
Re: HTML::Mason and long method call
by shmem (Chancellor) on Oct 23, 2006 at 12:10 UTC
    I think some error should be logged to STDERR (apache error_log) and it isn't.

    Looks to me like *somewhere* redirection of STDERR and/or STDOUT is done, and for some reason (code barfs out before?) the defaults aren't restored. Maybe you could dup STDERR and STDOUT into a SAVEOUT and SAVEERR filehandle before, and restore them after calling longfunction().

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Hi shmem,

      The problem is not with my longfunction STDERR, or even with the mason STDERR. If inside my longfunction I print to STDERR I get the message in error_log, and the same happens when I print to STDERR after the call to this component.

      My problem is that Mason seems to terminate my component and behave like everything is ok.

      This component is not complemently run, but everything after its call in the caller is runned normally. My final page is created as if this component runned completly ok but didn't sent any output.

        Did you try to isolate where it stops printing inside of longfunction? Did you check if any error is being printed in the HTML output to the browser? (What is MasonErrorMode/error_mode?) What code is inside longfunction? Did you try the Mason mailing list? Also, looking in the MASON_DATA_ROOT at what the components get compiled into can help sometimes. What is your system (redhat?) ? What version of Mason?