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.511 by root, Wed Apr 7 18:35:56 2010 UTC vs.
Revision 1.512 by root, Sun Apr 11 04:52:07 2010 UTC

503 503
504sub sync_job(&) { 504sub sync_job(&) {
505 my ($job) = @_; 505 my ($job) = @_;
506 506
507 if ($Coro::current == $Coro::main) { 507 if ($Coro::current == $Coro::main) {
508 my $time = EV::time; 508 my $time = AE::time;
509 509
510 # this is the main coro, too bad, we have to block 510 # this is the main coro, too bad, we have to block
511 # till the operation succeeds, freezing the server :/ 511 # till the operation succeeds, freezing the server :/
512 512
513 LOG llevError, Carp::longmess "sync job";#d# 513 LOG llevError, Carp::longmess "sync job";#d#
530 } else { 530 } else {
531 EV::loop EV::LOOP_ONESHOT; 531 EV::loop EV::LOOP_ONESHOT;
532 } 532 }
533 } 533 }
534 534
535 my $time = EV::time - $time; 535 my $time = AE::time - $time;
536 536
537 $TICK_START += $time; # do not account sync jobs to server load 537 $TICK_START += $time; # do not account sync jobs to server load
538 538
539 wantarray ? @res : $res[0] 539 wantarray ? @res : $res[0]
540 } else { 540 } else {
3584 3584
3585# install some emergency cleanup handlers 3585# install some emergency cleanup handlers
3586BEGIN { 3586BEGIN {
3587 our %SIGWATCHER = (); 3587 our %SIGWATCHER = ();
3588 for my $signal (qw(INT HUP TERM)) { 3588 for my $signal (qw(INT HUP TERM)) {
3589 $SIGWATCHER{$signal} = EV::signal $signal, sub { 3589 $SIGWATCHER{$signal} = AE::signal $signal, sub {
3590 cf::cleanup "SIG$signal"; 3590 cf::cleanup "SIG$signal";
3591 }; 3591 };
3592 } 3592 }
3593} 3593}
3594 3594
3595sub write_runtime_sync { 3595sub write_runtime_sync {
3596 my $t0 = EV::time; 3596 my $t0 = AE::time;
3597 3597
3598 # first touch the runtime file to show we are still running: 3598 # first touch the runtime file to show we are still running:
3599 # the fsync below can take a very very long time. 3599 # the fsync below can take a very very long time.
3600 3600
3601 IO::AIO::aio_utime $RUNTIMEFILE, undef, undef; 3601 IO::AIO::aio_utime $RUNTIMEFILE, undef, undef;
3623 or return; 3623 or return;
3624 3624
3625 aio_rename "$RUNTIMEFILE~", $RUNTIMEFILE 3625 aio_rename "$RUNTIMEFILE~", $RUNTIMEFILE
3626 and return; 3626 and return;
3627 3627
3628 warn sprintf "runtime file written (%gs).\n", EV::time - $t0; 3628 warn sprintf "runtime file written (%gs).\n", AE::time - $t0;
3629 3629
3630 1 3630 1
3631} 3631}
3632 3632
3633our $uuid_lock; 3633our $uuid_lock;
3771 return; 3771 return;
3772 } 3772 }
3773 3773
3774 return if $RELOAD++; 3774 return if $RELOAD++;
3775 3775
3776 my $t1 = EV::time; 3776 my $t1 = AE::time;
3777 3777
3778 while ($RELOAD) { 3778 while ($RELOAD) {
3779 warn "reloading..."; 3779 warn "reloading...";
3780 3780
3781 warn "entering sync_job"; 3781 warn "entering sync_job";
3884 3884
3885 warn "reloaded"; 3885 warn "reloaded";
3886 --$RELOAD; 3886 --$RELOAD;
3887 } 3887 }
3888 3888
3889 $t1 = EV::time - $t1; 3889 $t1 = AE::time - $t1;
3890 warn "reload completed in ${t1}s\n"; 3890 warn "reload completed in ${t1}s\n";
3891}; 3891};
3892 3892
3893our $RELOAD_WATCHER; # used only during reload 3893our $RELOAD_WATCHER; # used only during reload
3894 3894
3897 # coro crashes during coro_state_free->destroy here. 3897 # coro crashes during coro_state_free->destroy here.
3898 3898
3899 $RELOAD_WATCHER ||= cf::async { 3899 $RELOAD_WATCHER ||= cf::async {
3900 Coro::AIO::aio_wait cache_extensions; 3900 Coro::AIO::aio_wait cache_extensions;
3901 3901
3902 $RELOAD_WATCHER = EV::timer $TICK * 1.5, 0, sub { 3902 $RELOAD_WATCHER = AE::timer $TICK * 1.5, 0, sub {
3903 do_reload_perl; 3903 do_reload_perl;
3904 undef $RELOAD_WATCHER; 3904 undef $RELOAD_WATCHER;
3905 }; 3905 };
3906 }; 3906 };
3907} 3907}
3948 return; 3948 return;
3949 } 3949 }
3950 3950
3951 cf::server_tick; # one server iteration 3951 cf::server_tick; # one server iteration
3952 3952
3953 #for(1..3e6){} EV::now_update; $NOW=EV::now; # generate load #d# 3953 #for(1..3e6){} AE::now_update; $NOW=AE::now; # generate load #d#
3954 3954
3955 if ($NOW >= $NEXT_RUNTIME_WRITE) { 3955 if ($NOW >= $NEXT_RUNTIME_WRITE) {
3956 $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.; 3956 $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.;
3957 Coro::async_pool { 3957 Coro::async_pool {
3958 $Coro::current->{desc} = "runtime saver"; 3958 $Coro::current->{desc} = "runtime saver";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines