… | |
… | |
349 | my $runtime = cf::localdir . "/runtime"; |
349 | my $runtime = cf::localdir . "/runtime"; |
350 | |
350 | |
351 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
351 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
352 | or return; |
352 | or return; |
353 | |
353 | |
|
|
354 | my $value = $cf::RUNTIME + 90 + 10; |
354 | my $value = $cf::RUNTIME + 1 + 10; # 10 is the runtime save interval, for a monotonic clock |
355 | # 10 is the runtime save interval, for a monotonic clock |
|
|
356 | # 60 allows for the watchdog to kill the server. |
|
|
357 | |
355 | (aio_write $fh, 0, (length $value), $value, 0) <= 0 |
358 | (aio_write $fh, 0, (length $value), $value, 0) <= 0 |
356 | and return; |
359 | and return; |
357 | |
360 | |
358 | aio_fsync $fh |
361 | aio_fsync $fh |
359 | and return; |
362 | and return; |
… | |
… | |
1339 | |
1342 | |
1340 | $map->load_header |
1343 | $map->load_header |
1341 | or return; |
1344 | or return; |
1342 | |
1345 | |
1343 | if ($map->should_reset) { |
1346 | if ($map->should_reset) { |
|
|
1347 | # doing this can freeze the server in a sync job, obviously |
1344 | $cf::WAIT_FOR_TICK->wait; |
1348 | #$cf::WAIT_FOR_TICK->wait; |
1345 | $map->reset; |
1349 | $map->reset; |
1346 | undef $guard; |
1350 | undef $guard; |
1347 | $map = find $path |
1351 | $map = find $path |
1348 | or return; |
1352 | or return; |
1349 | } |
1353 | } |
… | |
… | |
2476 | |
2480 | |
2477 | $WRITE_RUNTIME_WATCHER = Event->timer ( |
2481 | $WRITE_RUNTIME_WATCHER = Event->timer ( |
2478 | data => WF_AUTOCANCEL, |
2482 | data => WF_AUTOCANCEL, |
2479 | after => 1, |
2483 | after => 1, |
2480 | interval => 10, |
2484 | interval => 10, |
|
|
2485 | prio => 6, # keep it lowest so it acts like a watchdog |
2481 | cb => Coro::unblock_sub { |
2486 | cb => Coro::unblock_sub { |
2482 | write_runtime |
2487 | write_runtime |
2483 | or warn "ERROR: unable to write runtime file: $!"; |
2488 | or warn "ERROR: unable to write runtime file: $!"; |
2484 | }, |
2489 | }, |
2485 | ); |
2490 | ); |