… | |
… | |
3404 | cf::cleanup "SIG$signal"; |
3404 | cf::cleanup "SIG$signal"; |
3405 | }; |
3405 | }; |
3406 | } |
3406 | } |
3407 | } |
3407 | } |
3408 | |
3408 | |
3409 | sub write_runtime { |
3409 | sub write_runtime_sync { |
3410 | my $runtime = "$LOCALDIR/runtime"; |
3410 | my $runtime = "$LOCALDIR/runtime"; |
3411 | |
3411 | |
3412 | # first touch the runtime file to show we are still running: |
3412 | # first touch the runtime file to show we are still running: |
3413 | # the fsync below can take a very very long time. |
3413 | # the fsync below can take a very very long time. |
3414 | |
3414 | |
… | |
… | |
3542 | warn "reloading..."; |
3542 | warn "reloading..."; |
3543 | |
3543 | |
3544 | warn "entering sync_job"; |
3544 | warn "entering sync_job"; |
3545 | |
3545 | |
3546 | cf::sync_job { |
3546 | cf::sync_job { |
3547 | cf::write_runtime; # external watchdog should not bark |
3547 | cf::write_runtime_sync; # external watchdog should not bark |
3548 | cf::emergency_save; |
3548 | cf::emergency_save; |
3549 | cf::write_runtime; # external watchdog should not bark |
3549 | cf::write_runtime_sync; # external watchdog should not bark |
3550 | |
3550 | |
3551 | warn "syncing database to disk"; |
3551 | warn "syncing database to disk"; |
3552 | BDB::db_env_txn_checkpoint $DB_ENV; |
3552 | BDB::db_env_txn_checkpoint $DB_ENV; |
3553 | |
3553 | |
3554 | # if anything goes wrong in here, we should simply crash as we already saved |
3554 | # if anything goes wrong in here, we should simply crash as we already saved |
… | |
… | |
3709 | |
3709 | |
3710 | if ($NOW >= $NEXT_RUNTIME_WRITE) { |
3710 | if ($NOW >= $NEXT_RUNTIME_WRITE) { |
3711 | $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.; |
3711 | $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.; |
3712 | Coro::async_pool { |
3712 | Coro::async_pool { |
3713 | $Coro::current->{desc} = "runtime saver"; |
3713 | $Coro::current->{desc} = "runtime saver"; |
3714 | write_runtime |
3714 | write_runtime_sync |
3715 | or warn "ERROR: unable to write runtime file: $!"; |
3715 | or warn "ERROR: unable to write runtime file: $!"; |
3716 | }; |
3716 | }; |
3717 | } |
3717 | } |
3718 | |
3718 | |
3719 | if (my $sig = shift @WAIT_FOR_TICK_BEGIN) { |
3719 | if (my $sig = shift @WAIT_FOR_TICK_BEGIN) { |