From 01127e72360ccac8572b9316ac7b88a22ab57311 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 22 Feb 2005 13:44:46 +0000 Subject: [PATCH] Added "register_death_callback()" interface to run code at the begining of "kill_me()". This is the first thing needed to provide a transparent transaction interface somewhere down the line. It is added now to support database transactions that span multiple requests. We need this in order to send a ROLLBACK to the DB in the case of a session killing error during a DB transaction. We don't want to leave locks or failed transactions lying around in the DB, right? git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@94 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/AppSession.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 230e3a1..b25dcc4 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -125,6 +125,7 @@ sub server_build { my $self = bless { recv_queue => [], request_queue => [], requests => 0, + death_callbacks => [], endpoint => SERVER, state => CONNECTING, session_id => $sess_id, @@ -323,9 +324,21 @@ sub finish { } } +sub register_death_callback { + my $self = shift; + my $cb = shift; + push @{ $self->{death_callbacks} }, $cb; +} + sub kill_me { my $self = shift; if( ! $self->session_id ) { return 0; } + + # run each 'kill_me' callback; + for my $sub (@{$self->{death_callbacks}}) { + $sub->($self); + } + $self->disconnect; $logger->transport( "AppSession killing self: " . $self->session_id(), DEBUG ); my @a; @@ -840,6 +853,11 @@ sub respond_complete { } +sub register_death_callback { + my $self = shift; + my $cb = shift; + $self->session->register_death_callback( $cb ); +} package OpenSRF::AppSubrequest; -- 2.11.0