Skip to content

Commit

Permalink
Item14221: Revert Engine changes made by Item14205
Browse files Browse the repository at this point in the history
Reverts two commits:
 - 74d590a
 - d079f79
  • Loading branch information
gac410 committed Dec 5, 2016
1 parent efab1aa commit 979a363
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 36 deletions.
11 changes: 2 additions & 9 deletions FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
Expand Up @@ -65,13 +65,7 @@ sub run {
or die "Failed to create FastCGI socket: $!";
}
$args ||= {};

# Prepare output handles for FastCGI.
$this->{$_} = IO::Handle->new foreach qw(fhIN fhOUT fhERR);
# This is a little trick to make all `print STDERR' clauses send their
# output to the log file. May not work for spawned processes.
STDERR->fdopen($this->{fhERR}->fileno, "w");
my $r = FCGI::Request( $this->{fhIN}, $this->{fhOUT}, $this->{fhERR}, \%ENV, $sock,
my $r = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock,
&FCGI::FAIL_ACCEPT_ON_INTR );
my $manager;

Expand Down Expand Up @@ -193,8 +187,7 @@ sub preparePath {
}

sub write {
my $this = shift;
syswrite $this->{fhOUT}, $_[0];
syswrite STDOUT, $_[1];
}

sub closeSocket {
Expand Down
4 changes: 1 addition & 3 deletions core/lib/Foswiki/Configure/Wizards/AutoConfigureEmail.pm
Expand Up @@ -184,9 +184,7 @@ NOCERT

if ( $Foswiki::cfg{SMTP}{MAILHOST} ) {

if ( 1
|| $Foswiki::cfg{Engine} && $Foswiki::cfg{Engine} !~ m/FastCGI$/ )
{
if ( $Foswiki::cfg{Engine} && $Foswiki::cfg{Engine} !~ m/FastCGI$/ ) {
( $ok, $out, $err ) = _muteExec( \&_autoconfigSMTP, $reporter );
}
else {
Expand Down
24 changes: 1 addition & 23 deletions core/lib/Foswiki/Engine.pm
Expand Up @@ -34,34 +34,12 @@ BEGIN {
Constructs an engine object.
The default object has three initialized keys on it: =fhIN=, =fhOUT=, =fhERR=.
Those are filehandles used to communicate with HTTP server/environment and by
default they're set to =STDIN=, =STDOUT=, and =STDERR= correspondingly. It is
recommended to use =$engine->{fhERR}= instead of STDERR in order to get error
messages always logged correctly:
<verbatim>
print $Foswiki::engine->{fhERR} "This is the error we wanna see in the log.\n";
$SIG{__DIE__} = sub {
print $Foswiki::engine->{fhERR} @_;
exit 1;
};
</verbatim>
=cut

sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $this = {

# Standard file handles to support engines/environments where
# communication is based on custom sockets.
fhIN => \*STDIN,
fhOUT => \*STDOUT,
fhERR => \*STDERR,
};
my $this = {};
return bless $this, $class;
}

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Engine/CGI.pm
Expand Up @@ -220,7 +220,7 @@ sub prepareBody {
# as breaking uploads (though cdot believes this is because of the
# deprecated dual nature of param delivering lightweight file handles,
# and it would probably work in Foswiki. Just not tried it)
my $cgi = new CGI( $this->{fhIN} );
my $cgi = new CGI();
my $err = $cgi->cgi_error;
throw Foswiki::EngineException( $1, $2 )
if defined $err && $err =~ m/\s*(\d{3})\s*(.*)/;
Expand Down

0 comments on commit 979a363

Please sign in to comment.