… | |
… | |
371 | sub write_runtime { |
371 | sub 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, ... |
… | |
… | |
1862 | } |
1865 | } |
1863 | |
1866 | |
1864 | sub cf::object::player::enter_link { |
1867 | sub cf::object::player::enter_link { |
1865 | my ($self) = @_; |
1868 | my ($self) = @_; |
1866 | |
1869 | |
|
|
1870 | $self->deactivate_recursive; |
|
|
1871 | |
1867 | return if UNIVERSAL::isa $self->map, "ext::map_link"; |
1872 | return if UNIVERSAL::isa $self->map, "ext::map_link"; |
1868 | |
1873 | |
1869 | $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] |
1874 | $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] |
1870 | if $self->map; |
1875 | if $self->map; |
1871 | |
1876 | |
… | |
… | |
2433 | |
2438 | |
2434 | die $$res unless "ARRAY" eq ref $res; |
2439 | die $$res unless "ARRAY" eq ref $res; |
2435 | |
2440 | |
2436 | return wantarray ? @$res : $res->[-1]; |
2441 | return wantarray ? @$res : $res->[-1]; |
2437 | } else { |
2442 | } else { |
|
|
2443 | reset_signals; |
2438 | local $SIG{__WARN__}; |
2444 | local $SIG{__WARN__}; |
|
|
2445 | local $SIG{__DIE__}; |
2439 | eval { |
2446 | eval { |
2440 | local $SIG{__DIE__}; |
|
|
2441 | close $fh1; |
2447 | close $fh1; |
2442 | |
2448 | |
2443 | my @res = eval { $cb->(@args) }; |
2449 | my @res = eval { $cb->(@args) }; |
2444 | syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); |
2450 | syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); |
2445 | }; |
2451 | }; |
… | |
… | |
2921 | prio => 6, |
2927 | prio => 6, |
2922 | cb => \&IO::AIO::poll_cb, |
2928 | cb => \&IO::AIO::poll_cb, |
2923 | ); |
2929 | ); |
2924 | } |
2930 | } |
2925 | |
2931 | |
|
|
2932 | my $_log_backtrace; |
|
|
2933 | |
|
|
2934 | sub _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 | |
2926 | # load additional modules |
2970 | # load additional modules |
2927 | use cf::pod; |
2971 | use cf::pod; |
2928 | |
2972 | |
2929 | END { cf::emergency_save } |
2973 | END { cf::emergency_save } |
2930 | |
2974 | |