--- deliantra/server/lib/cf.pm 2010/05/04 23:32:29 1.540 +++ deliantra/server/lib/cf.pm 2010/05/06 22:35:41 1.545 @@ -126,7 +126,7 @@ our $BDB_TRICKLE_WATCHER; our $DB_ENV; -our @EXTRA_MODULES = qw(pod match mapscript); +our @EXTRA_MODULES = qw(pod match mapscript incloader); our %CFG; @@ -1453,7 +1453,6 @@ if (length $@) { error "$v->{path}: $@\n"; - undef $@; # work around perl 5.10.0 utf-8 caching bug cf::cleanup "mandatory extension '$k' failed to load, exiting." if exists $v->{meta}{mandatory}; @@ -1872,7 +1871,7 @@ sub normalise { my ($path, $base) = @_; - $path = "$path"; # make sure its a string + $path = "$path"; # make sure it's a string $path =~ s/\.map$//; @@ -1921,7 +1920,7 @@ } } - Carp::cluck "unable to resolve path '$path' (base '$base')."; + Carp::cluck "unable to resolve path '$path' (base '$base')"; () } @@ -2054,6 +2053,8 @@ sub find { my ($path, $origin) = @_; + cf::cede_to_tick; + $path = normalise $path, $origin && $origin->path; my $guard1 = cf::lock_acquire "map_data:$path";#d#remove @@ -3360,49 +3361,6 @@ ############################################################################# # the server's init and main functions -# async inc loader. yay. -sub inc_loader { - my $mod = $_[1]; - - if (in_main && !tick_inhibit) { - Carp::cluck "ERROR: attempted synchronous perl module load ($mod)"; - } else { - debug "loading perl module $mod\n"; - } - - # 1. find real file - for my $dir (@ORIG_INC) { - warn "$dir/$mod\n";#d# - ref $dir and next; - 0 <= Coro::AIO::aio_load "$dir/$mod", my $data - or next; - - $data = "#line 1 $dir/$mod\n$data"; - - open my $fh, "<", \$data or die; - - return $fh; - } - - () -} - -sub init_inc { - # save original @INC - @ORIG_INC = ($LIBDIR, @INC) unless @ORIG_INC; - - # make sure we can do scalar-opens - open my $dummy, "<", \my $dummy2; - - # execute some stuff so perl load's some of the core modules - /Ü/ =~ /ü/i; - eval { &Storable::nstore_fd }; - - @INC = (\&inc_loader, @ORIG_INC); # @ORIG_INC is needed for DynaLoader, AutoLoad etc. - - debug "module loading will be asynchronous from this point on."; -} - sub load_facedata($) { my ($path) = @_; @@ -3569,6 +3527,8 @@ sub reload_resources { trace "reloading resource files...\n"; + reload_exp_table; + reload_materials; reload_facedata; reload_sound; reload_archetypes; @@ -3653,15 +3613,13 @@ evthread_start IO::AIO::poll_fileno; cf::sync_job { - init_inc; + cf::incloader::init (); - cf::init_experience; cf::init_anim; cf::init_attackmess; cf::init_dynamic; cf::load_settings; - cf::load_materials; reload_resources; reload_config; @@ -3905,7 +3863,7 @@ sub do_reload_perl() { # can/must only be called in main - if (in_main) { + unless (in_main) { error "can only reload from main coroutine"; return; } @@ -3915,12 +3873,13 @@ my $t1 = AE::time; while ($RELOAD) { + cf::get_slot 0.1, -1, "reload_perl"; info "reloading..."; trace "entering sync_job"; cf::sync_job { - cf::emergency_save; + #cf::emergency_save; trace "cancelling all extension coros"; $_->cancel for values %EXT_CORO;