[OpenSRF-GIT] OpenSRF branch master updated. a0d5b0536231cc06552fb9d7533a713c314ef9d3
Evergreen Git
git at git.evergreen-ils.org
Mon Dec 16 11:20:58 EST 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via a0d5b0536231cc06552fb9d7533a713c314ef9d3 (commit)
via 59b4dd74e8695bc9bd7ad6c379b0f313db1cbb61 (commit)
from b93e0ca9c88e76d8a6a3c2451cbb49756c6ecf68 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a0d5b0536231cc06552fb9d7533a713c314ef9d3
Author: Mike Rylander <mrylander at gmail.com>
Date: Thu May 16 10:17:15 2013 -0400
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 <mrylander at gmail.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
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 {}
commit 59b4dd74e8695bc9bd7ad6c379b0f313db1cbb61
Author: Galen Charlton <gmc at esilibrary.com>
Date: Mon Dec 16 08:08:51 2013 -0800
LP#1180849: test case - ignoring subrequest responses after respond_complete()
This patch adds a regression test for verifying that subrequests
ignore additional responses after respond_complete() is called.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/t/02-AppSession.t b/src/perl/t/02-AppSession.t
index 01cce39..5a88b2c 100644
--- a/src/perl/t/02-AppSession.t
+++ b/src/perl/t/02-AppSession.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 4;
BEGIN {
use_ok( 'OpenSRF::AppSession' );
@@ -12,3 +12,11 @@ my $locale = OpenSRF::AppSession->default_locale('fr-CA');
is($locale, 'fr-CA', 'got back the default locale we set');
$locale = OpenSRF::AppSession->reset_locale();
is($locale, 'en-US', 'got back en-US after reset of default locale');
+
+my $subreq = OpenSRF::AppSubrequest->new();
+$subreq->respond('a');
+$subreq->respond('b');
+$subreq->respond_complete();
+$subreq->respond('c');
+my @responses = $subreq->responses();
+is_deeply(\@responses, ['a', 'b'], 'further responses ignored after respond_complete() is called');
-----------------------------------------------------------------------
Summary of changes:
src/perl/lib/OpenSRF/AppSession.pm | 18 ++++++++++++++++--
src/perl/t/02-AppSession.t | 10 +++++++++-
2 files changed, 25 insertions(+), 3 deletions(-)
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list