[OpenSRF-GIT] OpenSRF branch master updated. 304365165e7ba0cc08bb6c5f0ba25f0b541fd27d

Evergreen Git git at git.evergreen-ils.org
Mon Nov 5 13:09:31 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, master has been updated
       via  304365165e7ba0cc08bb6c5f0ba25f0b541fd27d (commit)
      from  51a4651186c94686051262a9255d165eadd4f049 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 304365165e7ba0cc08bb6c5f0ba25f0b541fd27d
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jul 24 12:08:56 2017 -0400

    LP#1706147 Perl Force-Recycle drone option
    
    Creates an API-level option to inform the OpenSRF drone management code
    that the running drone should be recycled upon completion of the current
    OpenSRF session.  This allows for quicker release of resources consumed
    by the drone.
    
    To use:
    
    sub some_api_method {
        my ($self, $client, ...) = @_;
        $self->session->force_recycle(1);
        ...
    }
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/src/perl/lib/OpenSRF/AppSession.pm b/src/perl/lib/OpenSRF/AppSession.pm
index b90e52c..ec5ebb4 100644
--- a/src/perl/lib/OpenSRF/AppSession.pm
+++ b/src/perl/lib/OpenSRF/AppSession.pm
@@ -146,6 +146,7 @@ sub server_build {
 
 	my $self = bless { recv_queue  => [],
 			   request_queue  => [],
+               force_recycle => 0,
 			   requests  => 0,
 			   session_data  => {},
 			   callbacks  => {},
@@ -228,6 +229,15 @@ sub stateless {
 	return $self->{stateless};
 }
 
+# When true, indicates the server drone should be killed (recycled)
+# after the current session has completed.  This overrides the
+# configured max_request value.
+sub force_recycle {
+    my ($self, $force) = @_;
+    $self->{force_recycle} = $force if defined $force;
+    return $self->{force_recycle};
+}
+
 # When we're a client and we want to connect to a remote service
 sub create {
 	my $class = shift;
diff --git a/src/perl/lib/OpenSRF/Server.pm b/src/perl/lib/OpenSRF/Server.pm
index ba463e4..8efbc4c 100644
--- a/src/perl/lib/OpenSRF/Server.pm
+++ b/src/perl/lib/OpenSRF/Server.pm
@@ -653,10 +653,16 @@ sub run {
             OpenSRF::Transport::SlimJabber::XMPPMessage->new(xml => $data)
         );
 
-        $self->keepalive_loop($session);
+        my $recycle = $self->keepalive_loop($session);
 
         last if ++$self->{num_requests} == $self->{parent}->{max_requests};
 
+        if ($recycle) {
+            $chatty && $logger->internal(
+                "server: child exiting early on force_recycle");
+            last;
+        }
+
         # Tell the parent process we are available to process requests
         $self->send_status;
 
@@ -772,7 +778,15 @@ sub keepalive_loop {
     }
 
     $chatty and $logger->internal("server: child done with request(s)");
+
+    # Capture the recycle option value before it's clobbered.
+    # The option may be set at any point along the life of the 
+    # session.  Once set, it remains set unless 
+    # $session->force_recycle(0) is explicitly called.
+    my $recycle = $session->force_recycle;
+
     $session->kill_me;
+    return $recycle;
 }
 
 # ----------------------------------------------------------------

-----------------------------------------------------------------------

Summary of changes:
 src/perl/lib/OpenSRF/AppSession.pm |   10 ++++++++++
 src/perl/lib/OpenSRF/Server.pm     |   16 +++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list