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.542 by root, Wed May 5 09:05:03 2010 UTC vs.
Revision 1.543 by root, Wed May 5 23:23:29 2010 UTC

124our $BDB_DEADLOCK_WATCHER; 124our $BDB_DEADLOCK_WATCHER;
125our $BDB_CHECKPOINT_WATCHER; 125our $BDB_CHECKPOINT_WATCHER;
126our $BDB_TRICKLE_WATCHER; 126our $BDB_TRICKLE_WATCHER;
127our $DB_ENV; 127our $DB_ENV;
128 128
129our @EXTRA_MODULES = qw(pod match mapscript); 129our @EXTRA_MODULES = qw(pod match mapscript incloader);
130 130
131our %CFG; 131our %CFG;
132 132
133our $UPTIME; $UPTIME ||= time; 133our $UPTIME; $UPTIME ||= time;
134our $RUNTIME; 134our $RUNTIME;
1869} 1869}
1870 1870
1871sub normalise { 1871sub normalise {
1872 my ($path, $base) = @_; 1872 my ($path, $base) = @_;
1873 1873
1874 $path = "$path"; # make sure its a string 1874 $path = "$path"; # make sure it's a string
1875 1875
1876 $path =~ s/\.map$//; 1876 $path =~ s/\.map$//;
1877 1877
1878 # map plan: 1878 # map plan:
1879 # 1879 #
1918 $self->init; # pass $1 etc. 1918 $self->init; # pass $1 etc.
1919 return $self; 1919 return $self;
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 Carp::cluck "unable to resolve path '$path' (base '$base')."; 1923 Carp::cluck "unable to resolve path '$path' (base '$base')";
1924 () 1924 ()
1925} 1925}
1926 1926
1927sub init { 1927sub init {
1928 my ($self) = @_; 1928 my ($self) = @_;
2050} 2050}
2051 2051
2052sub find; 2052sub find;
2053sub find { 2053sub find {
2054 my ($path, $origin) = @_; 2054 my ($path, $origin) = @_;
2055
2056 cf::cede_to_tick;
2055 2057
2056 $path = normalise $path, $origin && $origin->path; 2058 $path = normalise $path, $origin && $origin->path;
2057 2059
2058 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove 2060 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove
2059 my $guard2 = cf::lock_acquire "map_find:$path"; 2061 my $guard2 = cf::lock_acquire "map_find:$path";
3357=cut 3359=cut
3358 3360
3359############################################################################# 3361#############################################################################
3360# the server's init and main functions 3362# the server's init and main functions
3361 3363
3362# async inc loader. yay.
3363sub inc_loader {
3364 my $mod = $_[1];
3365
3366 if (in_main && !tick_inhibit) {
3367 Carp::cluck "ERROR: attempted synchronous perl module load ($mod)";
3368 } else {
3369 debug "loading perl module $mod\n";
3370 }
3371
3372 # 1. find real file
3373 for my $dir (@ORIG_INC) {
3374 ref $dir and next;
3375 0 <= Coro::AIO::aio_load "$dir/$mod", my $data
3376 or next;
3377
3378 $data = "#line 1 $dir/$mod\n$data";
3379
3380 open my $fh, "<", \$data or die;
3381
3382 return $fh;
3383 }
3384
3385 ()
3386}
3387
3388sub init_inc {
3389 # save original @INC
3390 @ORIG_INC = ($LIBDIR, @INC) unless @ORIG_INC;
3391
3392 # make sure we can do scalar-opens
3393 open my $dummy, "<", \my $dummy2;
3394
3395 # execute some stuff so perl load's some of the core modules
3396 /Ü/ =~ /ü/i;
3397 eval { &Storable::nstore_fd };
3398
3399 @INC = (\&inc_loader, @ORIG_INC); # @ORIG_INC is needed for DynaLoader, AutoLoad etc.
3400
3401 debug "module loading will be asynchronous from this point on.";
3402}
3403
3404sub load_facedata($) { 3364sub load_facedata($) {
3405 my ($path) = @_; 3365 my ($path) = @_;
3406 3366
3407 # HACK to clear player env face cache, we need some signal framework 3367 # HACK to clear player env face cache, we need some signal framework
3408 # for this (global event?) 3368 # for this (global event?)
3649 }; 3609 };
3650 3610
3651 evthread_start IO::AIO::poll_fileno; 3611 evthread_start IO::AIO::poll_fileno;
3652 3612
3653 cf::sync_job { 3613 cf::sync_job {
3654 init_inc; 3614 cf::incloader::init ();
3655 3615
3656 cf::init_experience; 3616 cf::init_experience;
3657 cf::init_anim; 3617 cf::init_anim;
3658 cf::init_attackmess; 3618 cf::init_attackmess;
3659 cf::init_dynamic; 3619 cf::init_dynamic;
3901 } 3861 }
3902} 3862}
3903 3863
3904sub do_reload_perl() { 3864sub do_reload_perl() {
3905 # can/must only be called in main 3865 # can/must only be called in main
3906 if (in_main) { 3866 unless (in_main) {
3907 error "can only reload from main coroutine"; 3867 error "can only reload from main coroutine";
3908 return; 3868 return;
3909 } 3869 }
3910 3870
3911 return if $RELOAD++; 3871 return if $RELOAD++;
3912 3872
3913 my $t1 = AE::time; 3873 my $t1 = AE::time;
3914 3874
3915 while ($RELOAD) { 3875 while ($RELOAD) {
3876 cf::get_slot 0.1, -1, "reload_perl";
3916 info "reloading..."; 3877 info "reloading...";
3917 3878
3918 trace "entering sync_job"; 3879 trace "entering sync_job";
3919 3880
3920 cf::sync_job { 3881 cf::sync_job {
3921 cf::emergency_save; 3882 #cf::emergency_save;
3922 3883
3923 trace "cancelling all extension coros"; 3884 trace "cancelling all extension coros";
3924 $_->cancel for values %EXT_CORO; 3885 $_->cancel for values %EXT_CORO;
3925 %EXT_CORO = (); 3886 %EXT_CORO = ();
3926 3887

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines