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.254 by root, Thu Apr 19 11:12:45 2007 UTC vs.
Revision 1.262 by root, Sat Apr 28 05:55:55 2007 UTC

161 my $msg = join "", @_; 161 my $msg = join "", @_;
162 162
163 $msg .= "\n" 163 $msg .= "\n"
164 unless $msg =~ /\n$/; 164 unless $msg =~ /\n$/;
165 165
166 $msg =~ s/([\x00-\x09\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge; 166 $msg =~ s/([\x00-\x08\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge;
167 167
168 utf8::encode $msg; 168 utf8::encode $msg;
169 LOG llevError, $msg; 169 LOG llevError, $msg;
170 }; 170 };
171} 171}
1490 my ($self) = @_; 1490 my ($self) = @_;
1491 1491
1492 local $self->{deny_reset} = 1; # loading can take a long time 1492 local $self->{deny_reset} = 1; # loading can take a long time
1493 1493
1494 my $path = $self->{path}; 1494 my $path = $self->{path};
1495
1496 {
1495 my $guard = cf::lock_acquire "map_load:$path"; 1497 my $guard = cf::lock_acquire "map_load:$path";
1496 1498
1497 return if $self->in_memory != cf::MAP_SWAPPED; 1499 return if $self->in_memory != cf::MAP_SWAPPED;
1498 1500
1499 $self->in_memory (cf::MAP_LOADING); 1501 $self->in_memory (cf::MAP_LOADING);
1500 1502
1501 $self->alloc; 1503 $self->alloc;
1502 1504
1503 $self->pre_load; 1505 $self->pre_load;
1504 Coro::cede;
1505
1506 $self->_load_objects ($self->{load_path}, 1)
1507 or return;
1508
1509 $self->set_object_flag (cf::FLAG_OBJ_ORIGINAL, 1)
1510 if delete $self->{load_original};
1511
1512 if (my $uniq = $self->uniq_path) {
1513 utf8::encode $uniq;
1514 if (aio_open $uniq, O_RDONLY, 0) {
1515 $self->clear_unique_items;
1516 $self->_load_objects ($uniq, 0);
1517 }
1518 }
1519
1520 Coro::cede;
1521 # now do the right thing for maps
1522 $self->link_multipart_objects;
1523 Coro::cede;
1524
1525 unless ($self->{deny_activate}) {
1526 $self->decay_objects;
1527 $self->fix_auto_apply;
1528 $self->update_buttons;
1529 Coro::cede; 1506 Coro::cede;
1530 $self->set_darkness_map; 1507
1508 $self->_load_objects ($self->{load_path}, 1)
1509 or return;
1510
1511 $self->set_object_flag (cf::FLAG_OBJ_ORIGINAL, 1)
1512 if delete $self->{load_original};
1513
1514 if (my $uniq = $self->uniq_path) {
1515 utf8::encode $uniq;
1516 if (aio_open $uniq, O_RDONLY, 0) {
1517 $self->clear_unique_items;
1518 $self->_load_objects ($uniq, 0);
1519 }
1520 }
1521
1522 Coro::cede;
1523 # now do the right thing for maps
1524 $self->link_multipart_objects;
1531 $self->difficulty ($self->estimate_difficulty) 1525 $self->difficulty ($self->estimate_difficulty)
1532 unless $self->difficulty; 1526 unless $self->difficulty;
1533 Coro::cede; 1527 Coro::cede;
1528
1529 unless ($self->{deny_activate}) {
1530 $self->decay_objects;
1531 $self->fix_auto_apply;
1532 $self->update_buttons;
1533 Coro::cede;
1534 $self->set_darkness_map;
1535 Coro::cede;
1534 $self->activate; 1536 $self->activate;
1535 Coro::cede; 1537 }
1538
1539 $self->in_memory (cf::MAP_IN_MEMORY);
1536 } 1540 }
1537 1541
1538 $self->post_load; 1542 $self->post_load;
1539 Coro::cede;
1540
1541 $self->in_memory (cf::MAP_IN_MEMORY);
1542} 1543}
1543 1544
1544sub customise_for { 1545sub customise_for {
1545 my ($self, $ob) = @_; 1546 my ($self, $ob) = @_;
1546 1547
2434 2435
2435 die $$res unless "ARRAY" eq ref $res; 2436 die $$res unless "ARRAY" eq ref $res;
2436 2437
2437 return wantarray ? @$res : $res->[-1]; 2438 return wantarray ? @$res : $res->[-1];
2438 } else { 2439 } else {
2440 reset_signals;
2439 local $SIG{__WARN__}; 2441 local $SIG{__WARN__};
2442 local $SIG{__DIE__};
2440 eval { 2443 eval {
2441 local $SIG{__DIE__};
2442 close $fh1; 2444 close $fh1;
2443 2445
2444 my @res = eval { $cb->(@args) }; 2446 my @res = eval { $cb->(@args) };
2445 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); 2447 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res);
2446 }; 2448 };
2922 prio => 6, 2924 prio => 6,
2923 cb => \&IO::AIO::poll_cb, 2925 cb => \&IO::AIO::poll_cb,
2924 ); 2926 );
2925} 2927}
2926 2928
2929my $_log_backtrace;
2930
2931sub _log_backtrace {
2932 my ($msg, @addr) = @_;
2933
2934 $msg =~ s/\n//;
2935
2936 # limit the # of concurrent backtraces
2937 if ($_log_backtrace < 2) {
2938 ++$_log_backtrace;
2939 async {
2940 my @bt = fork_call {
2941 @addr = map { sprintf "%x", $_ } @addr;
2942 my $self = (-f "/proc/$$/exe") ? "/proc/$$/exe" : $^X;
2943 open my $fh, "exec addr2line -C -f -i -e \Q$self\E @addr 2>&1 |"
2944 or die "addr2line: $!";
2945
2946 my @funcs;
2947 my @res = <$fh>;
2948 chomp for @res;
2949 while (@res) {
2950 my ($func, $line) = splice @res, 0, 2, ();
2951 push @funcs, "[$func] $line";
2952 }
2953
2954 @funcs
2955 };
2956
2957 LOG llevInfo, "[ABT] $msg\n";
2958 LOG llevInfo, "[ABT] $_\n" for @bt;
2959 --$_log_backtrace;
2960 };
2961 } else {
2962 LOG llevInfo, "[ABT] $msg\n";
2963 LOG llevInfo, "[ABT] [suppressed]\n";
2964 }
2965}
2966
2927# load additional modules 2967# load additional modules
2928use cf::pod; 2968use cf::pod;
2929 2969
2930END { cf::emergency_save } 2970END { cf::emergency_save }
2931 2971

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines