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.385 by root, Fri Oct 12 19:13:26 2007 UTC vs.
Revision 1.390 by root, Thu Oct 25 09:01:24 2007 UTC

444 warn $@ if $@; 444 warn $@ if $@;
445 undef $busy; 445 undef $busy;
446 })->prio (Coro::PRIO_MAX); 446 })->prio (Coro::PRIO_MAX);
447 447
448 while ($busy) { 448 while ($busy) {
449 if (Coro::nready) {
450 Coro::cede_notself;
451 } else {
449 Coro::cede or Event::one_event; 452 Event::one_event;
453 }
450 } 454 }
451 455
452 $time = Event::time - $time; 456 $time = Event::time - $time;
453 457
454 LOG llevError | logBacktrace, Carp::longmess "long sync job" 458 LOG llevError | logBacktrace, Carp::longmess "long sync job"
966 970
967=cut 971=cut
968 972
969############################################################################# 973#############################################################################
970# object support 974# object support
971#
972 975
976sub _object_equal($$);
977sub _object_equal($$) {
978 my ($a, $b) = @_;
979
980 return 0 unless (ref $a) eq (ref $b);
981
982 if ("HASH" eq ref $a) {
983 my @ka = keys %$a;
984 my @kb = keys %$b;
985
986 return 0 if @ka != @kb;
987
988 for (0 .. $#ka) {
989 return 0 unless $ka[$_] eq $kb[$_];
990 return 0 unless _object_equal $a->{$ka[$_]}, $b->{$kb[$_]};
991 }
992
993 } elsif ("ARRAY" eq ref $a) {
994
995 return 0 if @$a != @$b;
996
997 for (0 .. $#$a) {
998 return 0 unless _object_equal $a->[$_], $b->[$_];
999 }
1000
1001 } elsif ($a ne $b) {
1002 return 0;
1003 }
1004
1005 1
1006}
1007
1008our $SLOW_MERGES;#d#
973sub _can_merge { 1009sub _can_merge {
974 my ($ob1, $ob2) = @_; 1010 my ($ob1, $ob2) = @_;
975 1011
976 return 1;#d# 1012 ++$SLOW_MERGES;#d#
977 1013
978 #todo#d# kill yourself and do some recursive checking manually without storable 1014 # we do the slow way here
979 sync_job { 1015 return _object_equal $ob1, $ob2
980 my $guard = Coro::Storable::guard;
981 local $Storable::canonical = 1;
982 my $fob1 = Storable::freeze $ob1;
983 my $fob2 = Storable::freeze $ob2;
984 $fob1 eq $fob2
985 }
986} 1016}
987 1017
988sub reattach { 1018sub reattach {
989 # basically do the same as instantiate, without calling instantiate 1019 # basically do the same as instantiate, without calling instantiate
990 my ($obj) = @_; 1020 my ($obj) = @_;
1051 close $fh; 1081 close $fh;
1052 1082
1053 if (@$objs) { 1083 if (@$objs) {
1054 if (my $fh = aio_open "$filename.pst~", O_WRONLY | O_CREAT, 0600) { 1084 if (my $fh = aio_open "$filename.pst~", O_WRONLY | O_CREAT, 0600) {
1055 chmod SAVE_MODE, $fh; 1085 chmod SAVE_MODE, $fh;
1056 my $data = Coro::Storable::blocking_nfreeze { version => 1, objs => $objs }; 1086 my $data = Coro::Storable::nfreeze { version => 1, objs => $objs };
1057 aio_write $fh, 0, (length $data), $data, 0; 1087 aio_write $fh, 0, (length $data), $data, 0;
1058 aio_fsync $fh if $cf::USE_FSYNC; 1088 aio_fsync $fh if $cf::USE_FSYNC;
1059 close $fh; 1089 close $fh;
1060 aio_rename "$filename.pst~", "$filename.pst"; 1090 aio_rename "$filename.pst~", "$filename.pst";
1061 } 1091 }
1092 1122
1093 unless (aio_stat "$filename.pst") { 1123 unless (aio_stat "$filename.pst") {
1094 (aio_load "$filename.pst", $av) >= 0 1124 (aio_load "$filename.pst", $av) >= 0
1095 or return; 1125 or return;
1096 1126
1097 my $st = eval { Coro::Storable::thaw $av } 1127 my $st = eval { Coro::Storable::thaw $av };
1098 || eval { my $guard = Coro::Storable::guard; Storable::thaw $av }; #d# compatibility, remove
1099 $av = $st->{objs}; 1128 $av = $st->{objs};
1100 } 1129 }
1101 1130
1102 utf8::decode (my $decname = $filename); 1131 utf8::decode (my $decname = $filename);
1103 warn sprintf "loading %s (%d,%d)\n", 1132 warn sprintf "loading %s (%d,%d)\n",
2650 id => "infobox", 2679 id => "infobox",
2651 title => "Examine", 2680 title => "Examine",
2652 reply => undef, 2681 reply => undef,
2653 tooltip => "Signs and other items you examined", 2682 tooltip => "Signs and other items you examined",
2654 }, 2683 },
2684 "c/book" => {
2685 id => "infobox",
2686 title => "Book",
2687 reply => undef,
2688 tooltip => "The contents of a note or book",
2689 },
2655 "c/lookat" => { 2690 "c/lookat" => {
2656 id => "infobox", 2691 id => "infobox",
2657 title => "Look", 2692 title => "Look",
2658 reply => undef, 2693 reply => undef,
2659 tooltip => "What you saw there", 2694 tooltip => "What you saw there",
2695 },
2696 "c/who" => {
2697 id => "infobox",
2698 title => "Players",
2699 reply => undef,
2700 tooltip => "Shows players who are currently online",
2701 },
2702 "c/body" => {
2703 id => "infobox",
2704 title => "Body Parts",
2705 reply => undef,
2706 tooltip => "Shows which body parts you posess and are available",
2707 },
2708 "c/uptime" => {
2709 id => "infobox",
2710 title => "Uptime",
2711 reply => undef,
2712 tooltip => "How long the server has been running sicne last restart",
2713 },
2714 "c/mapinfo" => {
2715 id => "infobox",
2716 title => "Map Info",
2717 reply => undef,
2718 tooltip => "Information related to the maps",
2660 }, 2719 },
2661); 2720);
2662 2721
2663sub cf::client::send_msg { 2722sub cf::client::send_msg {
2664 my ($self, $channel, $msg, $color, @extra) = @_; 2723 my ($self, $channel, $msg, $color, @extra) = @_;
3343 3402
3344 warn "flushing outstanding aio requests"; 3403 warn "flushing outstanding aio requests";
3345 for (;;) { 3404 for (;;) {
3346 BDB::flush; 3405 BDB::flush;
3347 IO::AIO::flush; 3406 IO::AIO::flush;
3348 Coro::cede; 3407 Coro::cede_notself;
3349 last unless IO::AIO::nreqs || BDB::nreqs; 3408 last unless IO::AIO::nreqs || BDB::nreqs;
3350 warn "iterate..."; 3409 warn "iterate...";
3351 } 3410 }
3352 3411
3353 ++$RELOAD; 3412 ++$RELOAD;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines