--- deliantra/server/lib/cf.pm 2007/10/04 23:59:07 1.379 +++ deliantra/server/lib/cf.pm 2007/10/12 19:13:26 1.385 @@ -6,13 +6,13 @@ use Symbol; use List::Util; use Socket; -use Storable; use Event; use Opcode; use Safe; use Safe::Hole; +use Storable (); -use Coro 3.64 (); +use Coro 4.1 (); use Coro::State; use Coro::Handle; use Coro::Event; @@ -29,7 +29,7 @@ use Digest::MD5; use Fcntl; use YAML::Syck (); -use IO::AIO 2.32 (); +use IO::AIO 2.51 (); use Time::HiRes; use Compress::LZF; use Digest::MD5 (); @@ -375,7 +375,7 @@ } if (@SLOT_QUEUE) { - # we do not use wait_For_tick() as it returns immediately when tick is inactive + # we do not use wait_for_tick() as it returns immediately when tick is inactive push @cf::WAIT_FOR_TICK, $signal; $signal->wait; } else { @@ -429,7 +429,7 @@ # this is the main coro, too bad, we have to block # till the operation succeeds, freezing the server :/ - LOG llevError | logBacktrace, Carp::longmess "sync job";#d# + LOG llevError, Carp::longmess "sync job";#d# # TODO: use suspend/resume instead # (but this is cancel-safe) @@ -973,11 +973,16 @@ sub _can_merge { my ($ob1, $ob2) = @_; - local $Storable::canonical = 1; - my $fob1 = Storable::freeze $ob1; - my $fob2 = Storable::freeze $ob2; + return 1;#d# - $fob1 eq $fob2 + #todo#d# kill yourself and do some recursive checking manually without storable + sync_job { + my $guard = Coro::Storable::guard; + local $Storable::canonical = 1; + my $fob1 = Storable::freeze $ob1; + my $fob2 = Storable::freeze $ob2; + $fob1 eq $fob2 + } } sub reattach { @@ -1048,7 +1053,7 @@ if (@$objs) { if (my $fh = aio_open "$filename.pst~", O_WRONLY | O_CREAT, 0600) { chmod SAVE_MODE, $fh; - my $data = Storable::nfreeze { version => 1, objs => $objs }; + my $data = Coro::Storable::blocking_nfreeze { version => 1, objs => $objs }; aio_write $fh, 0, (length $data), $data, 0; aio_fsync $fh if $cf::USE_FSYNC; close $fh; @@ -1089,7 +1094,9 @@ (aio_load "$filename.pst", $av) >= 0 or return; - $av = eval { (Storable::thaw $av)->{objs} }; + my $st = eval { Coro::Storable::thaw $av } + || eval { my $guard = Coro::Storable::guard; Storable::thaw $av }; #d# compatibility, remove + $av = $st->{objs}; } utf8::decode (my $decname = $filename); @@ -2896,7 +2903,7 @@ The following functions and methods are available within a safe environment: cf::object - contr pay_amount pay_player map x y force_find force_add + contr pay_amount pay_player map x y force_find force_add destroy insert remove name archname title slaying race decrease_ob_nr cf::object::player @@ -2913,7 +2920,7 @@ for ( ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y insert remove inv name archname title slaying race - decrease_ob_nr)], + decrease_ob_nr destroy)], ["cf::object::player" => qw(player)], ["cf::player" => qw(peaceful)], ["cf::map" => qw(trigger)], @@ -3280,6 +3287,7 @@ for my $login (keys %cf::PLAYER) { my $pl = $cf::PLAYER{$login} or next; $pl->valid or next; + delete $pl->{unclean_save}; # not strictly necessary, but cannot hurt $pl->save; } warn "end emergency player save\n";