Commit 1a9ec21d authored by Xavier Guimard's avatar Xavier Guimard

Use IO::Handle methods (#1148)

parent e1545279
......@@ -79,8 +79,7 @@ sub statusInit {
my $statusPipe = IO::Pipe->new;
my $statusOut = IO::Pipe->new;
if ( my $pid = fork() ) {
# TODO: log new process pid
$class->logger->debug("Status collector launched ($pid)");
$statusPipe->writer();
$statusOut->reader();
$statusPipe->autoflush(1);
......
......@@ -336,7 +336,7 @@ sub sessionStorageInit {
. Data::Dumper->new( [ $class->tsv->{sessionCacheOptions} ] )
->Terse(1)->Indent(0)->Dump; # To send params on one line
}
print { $class->tsv->{statusPipe} } "RELOADCACHE $params\n";
$class->tsv->{statusPipe}->print("RELOADCACHE $params\n");
}
}
return 1;
......
......@@ -42,10 +42,11 @@ sub getStatus {
my $statusOut = $class->tsv->{statusOut};
return $class->abort( $req, "$class: status page can not be displayed" )
unless ( $statusPipe and $statusOut );
print $statusPipe "STATUS " . ( $req->{env}->{QUERY_STRING} || '' ) . "\n";
$statusPipe->print(
"STATUS " . ( $req->{env}->{QUERY_STRING} || '' ) . "\n" );
my $buf;
while (<$statusOut>) {
while ( $statusOut->getline ) {
last if (/^END$/);
$buf .= $_;
}
......@@ -201,9 +202,8 @@ sub updateStatus {
$user ||= $req->{env}->{REMOTE_ADDR};
$url ||= $req->{env}->{REQUEST_URI};
eval {
print $statusPipe "$user => "
. $req->{env}->{HTTP_HOST}
. "$url $action\n";
$statusPipe->print(
"$user => " . $req->{env}->{HTTP_HOST} . "$url $action\n" );
};
}
......
......@@ -165,9 +165,9 @@ sub do {
# Update status
if ( my $p = $self->HANDLER->tsv->{statusPipe} ) {
print $p ( $req->user ? $req->user : $req->address ) . ' => '
. $req->uri
. " $err\n";
$p->print( ( $req->user ? $req->user : $req->address ) . ' => '
. $req->uri
. " $err\n" );
}
# Update history
......
......@@ -27,10 +27,10 @@ sub status {
my ( $self, $req ) = @_;
my $res = {};
if ( my $p = $self->p->HANDLER->tsv->{statusPipe} ) {
print $p "STATUS json=1\n";
$p->print("STATUS json=1\n");
my $buf;
$p = $self->p->HANDLER->tsv->{statusOut};
while (<$p>) {
while ( $p->getline ) {
last if (/^END$/);
$buf .= $_;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment