From af8cab4b4b77f668e3c5ac85d191acf94537ef32 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 16 May 2013 10:17:15 -0400 Subject: [PATCH] Protect subrequests from post-complete messages Subrequests (AKA method_lookup()-based API calls) sometimes append final-lvalue responses to the response list even after respond_complete() has been called from within the implementation method. This commit discards all post-respond_complete values, protecting against extra, spurious values being returned to the ultimate client. Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton --- src/perl/lib/OpenSRF/AppSession.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/perl/lib/OpenSRF/AppSession.pm b/src/perl/lib/OpenSRF/AppSession.pm index 8b99c00..9e371c7 100644 --- a/src/perl/lib/OpenSRF/AppSession.pm +++ b/src/perl/lib/OpenSRF/AppSession.pm @@ -1098,15 +1098,22 @@ package OpenSRF::AppSubrequest; sub respond { my $self = shift; + return if $self->complete; + my $resp = shift; push @{$$self{resp}}, $resp if (defined $resp); } -sub respond_complete { respond(@_); } + +sub respond_complete { + my $self = shift; + $self->respond(@_); + $self->complete(1); +} sub new { my $class = shift; $class = ref($class) || $class; - return bless({resp => [], @_}, $class); + return bless({complete => 0, resp => [], @_}, $class); } sub responses { @{$_[0]->{resp}} } @@ -1118,6 +1125,13 @@ sub session { return $x->{session}; } +sub complete { + my $x = shift; + my $c = shift; + $x->{complete} = $c if ($c); + return $x->{complete}; +} + sub status {} -- 2.11.0