From fffdd9651f59b2e1e46eaad4c540e27d9d8422f3 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 4 Aug 2010 17:32:20 +0000 Subject: [PATCH 1/1] always use respond_complete to finish a request, whether there is a final message or not git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1989 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perl/lib/OpenSRF/AppSession.pm | 21 +++++++++++---------- src/perl/lib/OpenSRF/Application.pm | 18 ++++-------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/perl/lib/OpenSRF/AppSession.pm b/src/perl/lib/OpenSRF/AppSession.pm index 1bcfa5c..c8ee269 100644 --- a/src/perl/lib/OpenSRF/AppSession.pm +++ b/src/perl/lib/OpenSRF/AppSession.pm @@ -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); } diff --git a/src/perl/lib/OpenSRF/Application.pm b/src/perl/lib/OpenSRF/Application.pm index d1e3d8f..9971d45 100644 --- a/src/perl/lib/OpenSRF/Application.pm +++ b/src/perl/lib/OpenSRF/Application.pm @@ -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")) { -- 2.43.2