ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-scheduler.ext
(Generate patch)

Comparing deliantra/server/ext/map-scheduler.ext (file contents):
Revision 1.34 by root, Fri May 11 07:59:59 2007 UTC vs.
Revision 1.35 by root, Sun Jun 10 04:05:47 2007 UTC

11our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load 11our $SWAP_LOAD1 = $cf::CFG{swap_load1} || .1; # start aggressively swapping at this load
12our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load 12our $SWAP_LOAD2 = $cf::CFG{swap_load2} || .4; # swap as fast as possible at this load
13 13
14cf::async_ext { 14cf::async_ext {
15 $Coro::current->prio (Coro::PRIO_MIN); 15 $Coro::current->prio (Coro::PRIO_MIN);
16
16 # load the header of swapped-out maps. 17 # load the header of swapped-out maps.
17 # this is not a correctness issue, it simply saves diskspace 18 # this is not a correctness issue, it simply saves diskspace
18 # because old files will get cleaned up on reset time 19 # because old files will get cleaned up on reset time
19 Coro::Timer::sleep 1; 20 Coro::Timer::sleep 0.25;
20 21
21 my $files = Coro::AIO::aio_readdir $cf::TMPDIR; 22 for my $map (@{ cf::map::tmp_maps or [] }) {
22
23 for my $map (@$files) {
24 utf8::decode $map;
25 next if $map =~ /\.(?:pst|meta)$/;
26 cf::map::find $map; 23 cf::map::find $map;
27 cf::wait_for_tick; 24 cf::wait_for_tick; Coro::cede;
28 } 25 }
29 26
30 #TODO: should also preload random maps... 27 #TODO: should also preload random maps...
28
29 # now hunt for resettable per-player maps
30 for my $login (@{ cf::player::list_logins or [] }) {
31 for my $path (@{ cf::player::maps $login or [] }) {
32 Coro::cede;
33
34 $path =~ /^~[^\/]+(\/.*)$/
35 or next; # doh
36
37 my $base = cf::map::find $1;
38
39 # skip maps without base maps on the assumption
40 # that those are old, unresettable maps
41 next unless $base;
42
43 # skip unresettable maps, for speed
44 next if $base->{deny_reset};
45
46 my $map = cf::map::find $path;
47 cf::wait_for_tick;
48
49 if ($map->{deny_reset}) {
50 warn "found noreset map with resettable base map, resetting: $path\n";
51 delete $map->{deny_reset};
52 }
53 }
54 }
31}; 55};
32 56
33our $SCHEDULER = cf::async_ext { 57our $SCHEDULER = cf::async_ext {
34 while () { 58 while () {
35 Coro::Event::do_timer (after => $SCHEDULE_INTERVAL) 59 Coro::Event::do_timer (after => $SCHEDULE_INTERVAL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines