[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Re: Fix for using the perl debugger with HTTP::Server::Simple servers


George Hartzell wrote:
> Hi Jesse,
> 
> The patch below passes your test suite, and seems to me to follow a
> pattern established by other tools that swap around stdio handles.  It
> passes HTTP::Server::Simple's tests on my FreeBSD system, and also
> allows me to run my CGI::Application::Server based stuff in the
> debugger.
> 
> There's something about all the various braces and brackets and parens
> that irritates my xemacs' version of cperl mode, so indenting is
> funny, but I believe that the code is ok and the problem is somewhere
> in cperl mode.  I'd appreciate a review on your part though.
> 
> Thoughts or comments?

I wonder if the same kind of issue is affecting HTTP::Request::AsCGI. it
failed to "make" for me last night on FreeBSD, and it seemed to be a
STDIN/STDOUT issue. I reported the failure through cpantesters, but it
doesn't seem to have appeared yet.

  Mark

> --- /usr/local/lib/perl5/site_perl/5.8.8/HTTP/Server/Simple.pm	Sat Nov 25 16:15:39 2006
> +++ lib/HTTP/Server/Simple.pm	Tue Feb 27 10:03:42 2007
> @@ -262,11 +262,38 @@
>                  $self->accept_hook if $self->can("accept_hook");
>  
>  
> -                *STDIN  = $self->stdin_handle();
> -                *STDOUT = $self->stdout_handle();
> +                # be more rigorous about how we hook the socket up to stdio,
> +                # so that things work in the perl debugger.  
> +		# 
> +                # *STDIN  = $self->stdin_handle();
> +                # *STDOUT = $self->stdout_handle();
> +
> +		my $saved_stdin;
> +		my $saved_stdout;
> +		open( $saved_stdin, '<&', STDIN->fileno() ) or
> +		  die "Can't save original stdin: $!";
> +		close STDIN;
> +		open( STDIN, '<&', $self->stdin_handle() ) or
> +		  die "Can't dup stdin: $!";
> +
> +		open( $saved_stdout, '>&', STDOUT->fileno() ) or
> +                  die "Can't save original stdout: $!";
> +                close STDOUT;
> +                open( STDOUT, '>&', $self->stdout_handle() ) or
> +                  die "Can't dup stdout: $!";
> +
>                  select STDOUT;   # required for HTTP::Server::Simple::Recorder
>                                   # XXX TODO glasser: why?
> +
>                  $pkg->process_request;
> +
> +                close STDIN;
> +                open( STDIN, "<&", $saved_stdin) or
> +                  die "Can't restore stdin:$!";
> +                close STDOUT;
> +                open( STDOUT, ">&", $saved_stdout) or
> +                  die "Can't restore stdout:$!";
> +
>                  close $remote;
>              }
>          }
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/suppressed/
>               http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
> 
> 


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.