Permalink
Browse files

Checking in changes prior to tagging of version 1.58. Changelog diff is:

Index: CHANGES
===================================================================
--- CHANGES	(revision 671)
+++ CHANGES	(working copy)
@@ -1,3 +1,13 @@
+1.58: 2007-05-11
+
+    -- plugin reload support, if plugin supports it.  plugin must implement
+           sub can_reload { 1 }
+       and optionally:
+           sub pre_reload_unload { ... }
+       (which is called before the ->unload, module reload, and ->load)
+       new management command is:
+           reload <plugin_name>
+
 1.57: 2007-04-26
 
     -- make ClientHTTP (webserver mode) support transfer-encoding


git-svn-id: http://code.sixapart.com/svn/perlbal/trunk@672 6caf28e9-730f-0410-b62b-a31386fe13fb
  • Loading branch information...
1 parent df8500c commit 7b8acfcc8bf3a23086f9827a833288b065bb942e bradfitz committed May 11, 2007
Showing with 50 additions and 4 deletions.
  1. +10 −0 CHANGES
  2. +1 −0 MANIFEST.SKIP
  3. +1 −1 META.yml
  4. +38 −3 lib/Perlbal.pm
View
10 CHANGES
@@ -1,3 +1,13 @@
+1.58: 2007-05-11
+
+ -- plugin reload support, if plugin supports it. plugin must implement
+ sub can_reload { 1 }
+ and optionally:
+ sub pre_reload_unload { ... }
+ (which is called before the ->unload, module reload, and ->load)
+ new management command is:
+ reload <plugin_name>
+
1.57: 2007-04-26
-- make ClientHTTP (webserver mode) support transfer-encoding
View
1 MANIFEST.SKIP
@@ -7,6 +7,7 @@ conf/ljdev.conf
conf/perlbal.conf
lib/Perlbal/Plugin/AtomInject.pm
lib/Perlbal/Plugin/AtomStream.pm
+lib/Perlbal/Plugin/pRuleLJ.pm
Perlbal.spec
.shipit
View
2 META.yml
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Perlbal
-version: 1.57
+version: 1.58
version_from: lib/Perlbal.pm
installdirs: site
requires:
View
41 lib/Perlbal.pm
@@ -33,7 +33,7 @@ my $has_cycle = eval "use Devel::Cycle; 1;";
use Devel::Peek;
use vars qw($VERSION);
-$VERSION = '1.57';
+$VERSION = '1.58';
use constant DEBUG => $ENV{PERLBAL_DEBUG} || 0;
use constant DEBUG_OBJ => $ENV{PERLBAL_DEBUG_OBJ} || 0;
@@ -998,18 +998,21 @@ sub MANAGE_unload {
return $mc->ok;
}
+
sub MANAGE_load {
my $mc = shift->parse(qr/^load \w+$/);
my $fn;
$fn = $1 if $mc->orig =~ /^load (\w+)$/i;
my $last_case;
+ my $last_class;
my $load = sub {
my $name = shift;
$last_case = $name;
- my $rv = eval "use Perlbal::Plugin::$name; Perlbal::Plugin::$name->load; 1;";
+ my $class = $last_class = "Perlbal::Plugin::$name";
+ my $rv = eval "use $class; $class->load; 1;";
return $mc->err($@) if ! $rv && $@ !~ /^Can\'t locate/;
return $rv;
};
@@ -1018,7 +1021,39 @@ sub MANAGE_load {
return $mc->err($@) unless $rv;
$PluginCase{lc $fn} = $last_case;
- $plugins{$last_case} = 1;
+ $plugins{$last_case} = $last_class;
+
+ return $mc->ok;
+}
+
+sub MANAGE_reload {
+ my $mc = shift->parse(qr/^reload (\w+)$/);
+ my ($fn) = $mc->args;
+
+ my $class = $PluginCase{lc $fn} or
+ return $mc->err("Unknown/unloaded plugin '$fn'");
+ $class = "Perlbal::Plugin::$class";
+
+ eval "$class->can_reload" or
+ return $mc->err("Plugin $class doesn't support reloading");
+
+ if ($class->can("pre_reload_unload")) {
+ eval "$class->pre_reload_unload; 1" or
+ return $mc->err("Error running $class->pre_reload_unload: $@");
+ }
+
+ eval "$class->unload; 1;" or
+ return $mc->err("Failed to unload $class: $@");
+
+ my $file = $class . ".pm";
+ $file =~ s!::!/!g;
+
+ delete $INC{$file} or
+ die $mc->err("Didn't find $file in %INC");
+
+ no warnings 'redefine';
+ eval "use $class; $class->load; 1;" or
+ return $mc->err("Failed to reload: $@");
return $mc->ok;
}

0 comments on commit 7b8acfc

Please sign in to comment.