LP#1655449: Bundling/chunking limits for SubRquests
authorMike Rylander <mrylander@gmail.com>
Tue, 10 Jan 2017 20:30:18 +0000 (15:30 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 16 Feb 2017 19:53:16 +0000 (14:53 -0500)
We need to teach subrequests to inherit parent request bundling/chunking
parameters so they don't cause overruns in dispatch mode.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Stephenson <jason@sigio.com>
src/perl/lib/OpenSRF/AppSession.pm
src/perl/lib/OpenSRF/Application.pm

index 158513b..36d56b0 100644 (file)
@@ -1164,7 +1164,11 @@ sub new {
         threadTrace     => 0,  # needed for respond in RD mode
         max_chunk_count => 0,  # needed for respond in RD mode
         max_chunk_size  => 0,  # needed for respond in RD mode
-        current_chunk   => [], # needed for respond_complete in RD mode
+        max_bundle_size        => 0,
+        current_bundle  => [], # needed for respond_complete in RD mode
+        current_bundle_count=> 0,
+        current_bundle_size    => 0,
+        max_bundle_count       => 0,
         @_
     }, $class);
     if ($self->session) {
index 5d01cb5..5995f1c 100644 (file)
@@ -572,14 +572,24 @@ sub method_lookup {
                $meth = $self->method_lookup($method,$proto,1);
        }
 
-       $meth->session($self->session) if $meth && ref($self); # Pass the caller's session
+       if ($meth && ref($self)) {
+               $meth->session($self->session); # Pass the caller's session
+               $meth->max_chunk_size($self->max_chunk_size);
+               $meth->max_bundle_size($self->max_bundle_size);
+       }
+
        return $meth;
 }
 
 sub dispatch {
        my $self = shift;
        $log->debug("Creating a dispatching SubRequest object", DEBUG);
-    my $req = OpenSRF::AppSubrequest->new( session => $self->session, respond_directly => 1 );
+    my $req = OpenSRF::AppSubrequest->new(
+        session => $self->session,
+        max_chunk_size  => $self->max_chunk_size,
+        max_bundle_size  => $self->max_bundle_size,
+        respond_directly => 1
+    );
     return $self->run($req,@_);
 }
 
@@ -593,7 +603,11 @@ sub run {
        if ( !UNIVERSAL::isa($req, 'OpenSRF::AppRequest') ) {
                $log->debug("Creating a SubRequest object", DEBUG);
                unshift @params, $req;
-               $req = OpenSRF::AppSubrequest->new( session => $self->session );
+               $req = OpenSRF::AppSubrequest->new(
+                       session => $self->session,
+                       max_chunk_size  => $self->max_chunk_size,
+                       max_bundle_size  => $self->max_bundle_size
+               );
        } else {
                $log->debug("This is a top level request", DEBUG);
        }