ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.18 by root, Tue Jul 11 14:24:15 2006 UTC vs.
Revision 1.21 by root, Sun Jul 16 17:51:40 2006 UTC

1package cf; 1package cf;
2 2
3use Symbol; 3use Symbol;
4use List::Util; 4use List::Util;
5use Storable; 5use Storable;
6
6use Event; 7use Event;
8$Event::Eval = 1; # no idea why this is required, but it is
7 9
8use strict; 10use strict;
9 11
10our %COMMAND; 12our %COMMAND;
11our @EVENT; 13our @EVENT;
167 169
168sub unload_extension { 170sub unload_extension {
169 my ($pkg) = @_; 171 my ($pkg) = @_;
170 172
171 warn "removing extension $pkg\n"; 173 warn "removing extension $pkg\n";
174
175 if (my $cb = $pkg->can ("on_unload")) {
176 $cb->($pkg);
177 }
172 178
173 # remove hooks 179 # remove hooks
174 for my $idx (0 .. $#EVENT) { 180 for my $idx (0 .. $#EVENT) {
175 delete $hook[$idx]{$pkg}; 181 delete $hook[$idx]{$pkg};
176 } 182 }
214 if ($who->flag (FLAG_WIZ)) { 220 if ($who->flag (FLAG_WIZ)) {
215 $who->message ("reloading..."); 221 $who->message ("reloading...");
216 222
217 warn "reloading...\n"; 223 warn "reloading...\n";
218 eval { 224 eval {
225 $_->cancel for Event::all_watchers;
226
219 unload_extension $_ for @exts; 227 unload_extension $_ for @exts;
220 delete $INC{"cf.pm"}; 228 delete $INC{"cf.pm"};
221 229
222 # don't, removes xs symbols, too 230 # don't, removes xs symbols, too
223 #Symbol::delete_package $pkg; 231 #Symbol::delete_package __PACKAGE__;
224 232
225 require cf; 233 require cf;
226 }; 234 };
227 warn $@ if $@; 235 warn $@ if $@;
228 $who->message ($@) if $@; 236 $who->message ($@) if $@;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines