always use respond_complete to finish a request, whether there is a final message...
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 4 Aug 2010 17:32:20 +0000 (17:32 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 4 Aug 2010 17:32:20 +0000 (17:32 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1989 9efc2488-bf62-4759-914b-345cdb29e865

src/perl/lib/OpenSRF/AppSession.pm
src/perl/lib/OpenSRF/Application.pm

index 1bcfa5c..c8ee269 100644 (file)
@@ -1017,21 +1017,22 @@ sub respond_complete {
        my $msg = shift;
        return unless ($self and $self->session and !$self->complete);
 
-       my $response;
-       if (ref($msg) && UNIVERSAL::isa($msg, 'OpenSRF::DomainObject::oilsResult')) {
-               $response = $msg;
-       } else {
-               $response = new OpenSRF::DomainObject::oilsResult;
-               $response->content($msg);
-       }
-
-    push @{$self->{current_chunk}}, $response;
+    if (defined($msg)) {
+       my $response;
+           if (ref($msg) && UNIVERSAL::isa($msg, 'OpenSRF::DomainObject::oilsResult')) {
+                   $response = $msg;
+       } else {
+               $response = new OpenSRF::DomainObject::oilsResult;
+                   $response->content($msg);
+       }
+
+        push @{$self->{current_chunk}}, $response;
+    }
 
        my $stat = OpenSRF::DomainObject::oilsConnectStatus->new(
                statusCode => STATUS_COMPLETE(),
                status => 'Request Complete' );
 
-
        $self->session->send( ( map { ('RESULT', $_) } @{$self->{current_chunk}} ), 'STATUS' => $stat, $self->threadTrace);
        $self->complete(1);
 }
index d1e3d8f..9971d45 100644 (file)
@@ -203,13 +203,8 @@ sub handler {
                                my $time = sprintf '%.3f', time() - $start;
 
                                $log->debug( "Method duration for [$method_name]:  ". $time );
-                               if( defined( $resp ) ) {
-                                       $appreq->respond_complete( $resp );
-                               } else {
-                                       $appreq->status( OpenSRF::DomainObject::oilsConnectStatus->new(
-                                                               statusCode => STATUS_COMPLETE(),
-                                                               status => 'Request Complete' ) );
-                               }
+                               $appreq->respond_complete( $resp );
+
                        } catch Error with {
                                my $e = shift;
                                warn "Caught error from 'run' method: $e\n";
@@ -281,14 +276,9 @@ sub handler {
                                        $log->debug( "Method duration for [".$aref->[2]->api_name." -> ".join(', ',@{$aref->[1]}).']:  '.$time, DEBUG );
 
                                        $appreq = $aref->[0];   
-                                       if( ref( $response ) ) {
-                                               $appreq->respond_complete( $response );
-                                       } else {
-                                               $appreq->status( OpenSRF::DomainObject::oilsConnectStatus->new(
-                                                                       statusCode => STATUS_COMPLETE(),
-                                                                       status => 'Request Complete' ) );
-                                       }
+                                       $appreq->respond_complete( $response );
                                        $log->debug( "Executed: " . $appreq->threadTrace, INTERNAL );
+
                                } catch Error with {
                                        my $e = shift;
                                        if(UNIVERSAL::isa($e,"Error")) {