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.256 by root, Sat Apr 21 16:56:32 2007 UTC vs.
Revision 1.263 by root, Sat May 5 05:40:27 2007 UTC

371sub write_runtime { 371sub write_runtime {
372 my $guard = cf::lock_acquire "write_runtime"; 372 my $guard = cf::lock_acquire "write_runtime";
373 373
374 my $runtime = "$LOCALDIR/runtime"; 374 my $runtime = "$LOCALDIR/runtime";
375 375
376 warn "starting to write runtime...\n";#d#
376 my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 377 my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644
377 or return; 378 or return;
378 379
379 my $value = $cf::RUNTIME + 90 + 10; 380 my $value = $cf::RUNTIME + 90 + 10;
380 # 10 is the runtime save interval, for a monotonic clock 381 # 10 is the runtime save interval, for a monotonic clock
390 close $fh 391 close $fh
391 or return; 392 or return;
392 393
393 aio_rename "$runtime~", $runtime 394 aio_rename "$runtime~", $runtime
394 and return; 395 and return;
396
397 warn "... done writing runtime.\n";#d#
395 398
396 1 399 1
397} 400}
398 401
399=item cf::datalog type => key => value, ... 402=item cf::datalog type => key => value, ...
1535 Coro::cede; 1538 Coro::cede;
1536 $self->activate; 1539 $self->activate;
1537 } 1540 }
1538 1541
1539 $self->in_memory (cf::MAP_IN_MEMORY); 1542 $self->in_memory (cf::MAP_IN_MEMORY);
1540
1541 undef $guard;
1542 } 1543 }
1543 1544
1544 $self->post_load; 1545 $self->post_load;
1545} 1546}
1546 1547
2437 2438
2438 die $$res unless "ARRAY" eq ref $res; 2439 die $$res unless "ARRAY" eq ref $res;
2439 2440
2440 return wantarray ? @$res : $res->[-1]; 2441 return wantarray ? @$res : $res->[-1];
2441 } else { 2442 } else {
2443 reset_signals;
2442 local $SIG{__WARN__}; 2444 local $SIG{__WARN__};
2445 local $SIG{__DIE__};
2443 eval { 2446 eval {
2444 local $SIG{__DIE__};
2445 close $fh1; 2447 close $fh1;
2446 2448
2447 my @res = eval { $cb->(@args) }; 2449 my @res = eval { $cb->(@args) };
2448 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); 2450 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res);
2449 }; 2451 };
2925 prio => 6, 2927 prio => 6,
2926 cb => \&IO::AIO::poll_cb, 2928 cb => \&IO::AIO::poll_cb,
2927 ); 2929 );
2928} 2930}
2929 2931
2932my $_log_backtrace;
2933
2934sub _log_backtrace {
2935 my ($msg, @addr) = @_;
2936
2937 $msg =~ s/\n//;
2938
2939 # limit the # of concurrent backtraces
2940 if ($_log_backtrace < 2) {
2941 ++$_log_backtrace;
2942 async {
2943 my @bt = fork_call {
2944 @addr = map { sprintf "%x", $_ } @addr;
2945 my $self = (-f "/proc/$$/exe") ? "/proc/$$/exe" : $^X;
2946 open my $fh, "exec addr2line -C -f -i -e \Q$self\E @addr 2>&1 |"
2947 or die "addr2line: $!";
2948
2949 my @funcs;
2950 my @res = <$fh>;
2951 chomp for @res;
2952 while (@res) {
2953 my ($func, $line) = splice @res, 0, 2, ();
2954 push @funcs, "[$func] $line";
2955 }
2956
2957 @funcs
2958 };
2959
2960 LOG llevInfo, "[ABT] $msg\n";
2961 LOG llevInfo, "[ABT] $_\n" for @bt;
2962 --$_log_backtrace;
2963 };
2964 } else {
2965 LOG llevInfo, "[ABT] $msg\n";
2966 LOG llevInfo, "[ABT] [suppressed]\n";
2967 }
2968}
2969
2930# load additional modules 2970# load additional modules
2931use cf::pod; 2971use cf::pod;
2932 2972
2933END { cf::emergency_save } 2973END { cf::emergency_save }
2934 2974

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines