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.257 by root, Sat Apr 21 17:34:24 2007 UTC vs.
Revision 1.264 by root, Sun May 6 05:44:48 2007 UTC

367 367
368 $coro 368 $coro
369} 369}
370 370
371sub write_runtime { 371sub write_runtime {
372 my $runtime = "$LOCALDIR/runtime";
373
374 # first touch the runtime file to show we are still running:
375 # the fsync below can take a very very long time.
376
377 warn "touching runtime...\n";#d#
378 if (my $fh = aio_open $runtime, O_WRONLY, 0) {
379 utime undef, undef, $fh;
380 }
381
372 my $guard = cf::lock_acquire "write_runtime"; 382 my $guard = cf::lock_acquire "write_runtime";
373 383
374 my $runtime = "$LOCALDIR/runtime"; 384 warn "starting to write runtime...\n";#d#
375
376 my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 385 my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644
377 or return; 386 or return;
378 387
379 my $value = $cf::RUNTIME + 90 + 10; 388 my $value = $cf::RUNTIME + 90 + 10;
380 # 10 is the runtime save interval, for a monotonic clock 389 # 10 is the runtime save interval, for a monotonic clock
385 394
386 # always fsync - this file is important 395 # always fsync - this file is important
387 aio_fsync $fh 396 aio_fsync $fh
388 and return; 397 and return;
389 398
399 # touch it again to show we are up-to-date
400 utime undef, undef, $fh;
401
390 close $fh 402 close $fh
391 or return; 403 or return;
392 404
393 aio_rename "$runtime~", $runtime 405 aio_rename "$runtime~", $runtime
394 and return; 406 and return;
407
408 warn "... done writing runtime.\n";#d#
395 409
396 1 410 1
397} 411}
398 412
399=item cf::datalog type => key => value, ... 413=item cf::datalog type => key => value, ...
1862} 1876}
1863 1877
1864sub cf::object::player::enter_link { 1878sub cf::object::player::enter_link {
1865 my ($self) = @_; 1879 my ($self) = @_;
1866 1880
1881 $self->deactivate_recursive;
1882
1867 return if UNIVERSAL::isa $self->map, "ext::map_link"; 1883 return if UNIVERSAL::isa $self->map, "ext::map_link";
1868 1884
1869 $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] 1885 $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y]
1870 if $self->map; 1886 if $self->map;
1871 1887
2433 2449
2434 die $$res unless "ARRAY" eq ref $res; 2450 die $$res unless "ARRAY" eq ref $res;
2435 2451
2436 return wantarray ? @$res : $res->[-1]; 2452 return wantarray ? @$res : $res->[-1];
2437 } else { 2453 } else {
2454 reset_signals;
2438 local $SIG{__WARN__}; 2455 local $SIG{__WARN__};
2456 local $SIG{__DIE__};
2439 eval { 2457 eval {
2440 local $SIG{__DIE__};
2441 close $fh1; 2458 close $fh1;
2442 2459
2443 my @res = eval { $cb->(@args) }; 2460 my @res = eval { $cb->(@args) };
2444 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); 2461 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res);
2445 }; 2462 };
2921 prio => 6, 2938 prio => 6,
2922 cb => \&IO::AIO::poll_cb, 2939 cb => \&IO::AIO::poll_cb,
2923 ); 2940 );
2924} 2941}
2925 2942
2943my $_log_backtrace;
2944
2945sub _log_backtrace {
2946 my ($msg, @addr) = @_;
2947
2948 $msg =~ s/\n//;
2949
2950 # limit the # of concurrent backtraces
2951 if ($_log_backtrace < 2) {
2952 ++$_log_backtrace;
2953 async {
2954 my @bt = fork_call {
2955 @addr = map { sprintf "%x", $_ } @addr;
2956 my $self = (-f "/proc/$$/exe") ? "/proc/$$/exe" : $^X;
2957 open my $fh, "exec addr2line -C -f -i -e \Q$self\E @addr 2>&1 |"
2958 or die "addr2line: $!";
2959
2960 my @funcs;
2961 my @res = <$fh>;
2962 chomp for @res;
2963 while (@res) {
2964 my ($func, $line) = splice @res, 0, 2, ();
2965 push @funcs, "[$func] $line";
2966 }
2967
2968 @funcs
2969 };
2970
2971 LOG llevInfo, "[ABT] $msg\n";
2972 LOG llevInfo, "[ABT] $_\n" for @bt;
2973 --$_log_backtrace;
2974 };
2975 } else {
2976 LOG llevInfo, "[ABT] $msg\n";
2977 LOG llevInfo, "[ABT] [suppressed]\n";
2978 }
2979}
2980
2926# load additional modules 2981# load additional modules
2927use cf::pod; 2982use cf::pod;
2928 2983
2929END { cf::emergency_save } 2984END { cf::emergency_save }
2930 2985

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines