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

Comparing deliantra/server/ext/map-random.ext (file contents):
Revision 1.9 by root, Sun Jan 21 21:28:27 2007 UTC vs.
Revision 1.10 by root, Wed Jan 24 16:29:10 2007 UTC

52 52
53 1 53 1
54} 54}
55 55
56sub clean_random_maps { 56sub clean_random_maps {
57 cf::async {
58 my $files = Coro::AIO::aio_readdir $cf::RANDOM_MAPS 57 my $files = Coro::AIO::aio_readdir $cf::RANDOM_MAPS
59 or return; 58 or return;
60 59
61 my $META_TIMEOUT = $cf::CFG{map_random_meta_timeout} || 86400 * 7; 60 my $META_TIMEOUT = $cf::CFG{map_random_meta_timeout} || 86400 * 7;
62 my $MAP_TIMEOUT = $cf::CFG{map_random_map_timeout} || 3600 * 6; 61 my $MAP_TIMEOUT = $cf::CFG{map_random_map_timeout} || 3600 * 6;
63 62
64 for my $file (@$files) { 63 for my $file (@$files) {
65 next if $file =~ /\.pst$/; 64 next if $file =~ /\.pst$/;
66 65
67 Coro::AIO::aio_stat "$cf::RANDOM_MAPS/$file" 66 Coro::AIO::aio_stat "$cf::RANDOM_MAPS/$file"
68 and next; 67 and next;
69 68
70 my $age = $cf::NOW - (stat _)[8]; 69 my $age = $cf::NOW - (stat _)[8];
71 70
72 if ($file =~ /\.meta$/) { 71 if ($file =~ /\.meta$/) {
73 if ($age > $META_TIMEOUT) { 72 if ($age > $META_TIMEOUT) {
74 warn "resetting random meta data for $file"; 73 warn "resetting random meta data for $file";
75 IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file"; 74 IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file";
76 } 75 }
77 } else { 76 } else {
78 if ($age > $MAP_TIMEOUT) { 77 if ($age > $MAP_TIMEOUT) {
79 warn "resetting random map $file"; 78 warn "resetting random map $file";
80 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file"; 79 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file";
81 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file.pst"; 80 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$cf::RANDOM_MAPS/$file.pst";
82 }
83 } 81 }
84 } 82 }
85 }; 83 }
86} 84}
87 85
88# clean up old temp maps regularly 86# clean up old temp maps regularly
89Event->timer ( 87Event->timer (
90 reentrant => 0, 88 reentrant => 0,
91 data => cf::WF_AUTOCANCEL, 89 data => cf::WF_AUTOCANCEL,
92 interval => 3600, 90 interval => 3600,
93 after => 60, 91 after => 60,
94 cb => \&clean_random_maps, 92 cb => Coro::unblock_sub { clean_random_maps },
95); 93);
96 94
971 951
98 96

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines