From 4d2ddfcfb668e8a52fa1fda08c6e7b03b681446f Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 17 Mar 2005 18:06:52 +0000 Subject: [PATCH] added some sanity checks to make sure we're not sending if we've been killed git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@241 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/AppSession.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 5c9bff0..1b6b557 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -381,6 +381,7 @@ sub kill_me { sub disconnect { my $self = shift; + return unless $self; unless( $self->state == DISCONNECTED ) { $self->send('DISCONNECT', "") if ($self->endpoint == CLIENT);; $self->state( DISCONNECTED ); @@ -398,6 +399,7 @@ sub disconnect { sub request { my $self = shift; my $meth = shift; + return unless $self; my $method; if (!ref $meth) { @@ -417,6 +419,8 @@ sub send { my @payload_list = @_; # this is a Domain Object + return unless ($self and $self->{peer_handle}); + $logger->debug( "In send", INTERNAL ); my $tT; @@ -711,7 +715,7 @@ sub flush_resend { my $self = shift; $logger->debug( "Resending..." . @_RESEND_QUEUE, DEBUG ); while ( my $req = shift @OpenSRF::AppSession::_RESEND_QUEUE ) { - $req->resend; + $req->resend unless $req->complete; } } @@ -739,6 +743,7 @@ sub _print_queue { sub status { my $self = shift; + return unless $self; $self->send( 'STATUS', @_ ); } @@ -777,7 +782,9 @@ sub queue_size { } sub send { - shift()->session->send(@_); + my $self = shift; + return unless ($self and $self->session); + $self->session->send(@_); } sub finish { @@ -839,6 +846,7 @@ sub payload { return shift()->{payload}; } sub resend { my $self = shift; + return unless ($self and $self->session); OpenSRF::Utils::Logger->debug( "I'm resending the request for threadTrace ". $self->threadTrace, DEBUG); if($self->payload) { @@ -850,12 +858,14 @@ sub resend { sub status { my $self = shift; my $msg = shift; + return unless ($self and $self->session); $self->session->send( 'STATUS',$msg, $self->threadTrace ); } sub respond { my $self = shift; my $msg = shift; + return unless ($self and $self->session); my $response; if (ref($msg) && UNIVERSAL::can($msg, 'getAttribute') && $msg->getAttribute('name') =~ /oilsResult/) { @@ -884,6 +894,7 @@ sub respond_complete { statusCode => STATUS_COMPLETE(), status => 'Request Complete' ); + return unless ($self and $self->session); $self->session->send( 'RESULT' => $response, 'STATUS' => $stat, $self->threadTrace); } -- 2.11.0