From 08ef33103fb8cbb36933759eb0c28dd040b200c0 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 3 Nov 2016 10:07:11 -0400 Subject: [PATCH] Provide an API, because ENV is no longer friendly to us Signed-off-by: Mike Rylander --- src/perl/lib/OpenSRF.pm | 17 +++++++++++++++++ src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/perl/lib/OpenSRF.pm b/src/perl/lib/OpenSRF.pm index b577ecd..33b8c83 100644 --- a/src/perl/lib/OpenSRF.pm +++ b/src/perl/lib/OpenSRF.pm @@ -42,4 +42,21 @@ Returns the scalar value of its caller. sub class { return scalar(caller); } +=head2 OSRF_APACHE_REQUEST_OBJ + +Gets and sets the Apache request object when running inside mod_perl. +This allows other parts of OpenSRF to investigate the state of the +remote connection, such as whether the client has disconnected, and +react accordingly. + +=cut + +our $_OARO; +sub OSRF_APACHE_REQUEST_OBJ { + my $self = shift; + my $a = shift; + $_OARO = $a if $a; + return $_OARO; +} + 1; diff --git a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm index 04259e2..9e15ecd 100644 --- a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm +++ b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm @@ -211,7 +211,7 @@ sub wait { vec($infile, $socket->fileno, 1) = 1; my $nfound; - if (!$ENV{OSRF_APACHE_REQUEST_OBJ} || $timeout <= 1.0) { + if (!OpenSRF->OSRF_APACHE_REQUEST_OBJ || $timeout <= 1.0) { $nfound = select($infile, undef, undef, $timeout); } else { $timeout -= 1.0; @@ -226,8 +226,8 @@ sub wait { $nfound = select($infile, undef, undef, $sleep); last if $nfound; if ( - $ENV{OSRF_APACHE_REQUEST_OBJ} && - $ENV{OSRF_APACHE_REQUEST_OBJ}->connection->aborted + OpenSRF->OSRF_APACHE_REQUEST_OBJ && + OpenSRF->OSRF_APACHE_REQUEST_OBJ->connection->aborted ) { # Should this be more severe? Die or throw error? $logger->warn("Upstream Apache client disconnected, aborting."); -- 2.11.0