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

Comparing deliantra/server/ext/map-tags.ext (file contents):
Revision 1.6 by root, Thu Sep 13 12:36:25 2007 UTC vs.
Revision 1.11 by root, Wed Nov 14 10:05:16 2007 UTC

77 add_tag_target $txn, $tag, $key; 77 add_tag_target $txn, $tag, $key;
78 } 78 }
79 79
80 # we don't actually care if it succeeds or not, as we 80 # we don't actually care if it succeeds or not, as we
81 # will just retry an hour later 81 # will just retry an hour later
82 BDB::db_txn_commit $txn; 82 BDB::db_txn_finish $txn;
83 83
84# warn "tag-updated $file (= $key) $hash\n";#d# 84 warn "tag-updated $file (= $key) <@tags>\n"
85 if @tags;
85} 86}
86 87
87sub scan_static { 88sub scan_static {
88 my ($dir, $map) = @_; 89 my ($dir, $map) = @_;
89 90
101 &scan_static ("$dir/$_", "$map$_/") 102 &scan_static ("$dir/$_", "$map$_/")
102 for @$dirs; 103 for @$dirs;
103} 104}
104 105
105sub reload { 106sub reload {
107 my $guard = cf::lock_acquire "map-tags::reload";
108
106 my $start = Event::time; 109 my $start = EV::time;
107 110
108 # 1. check for maps no longer existing 111 # 1. check for maps no longer existing
109 { 112 {
110 my @delkeys; 113 my @delkeys;
111 114
126 my $txn = $cf::DB_ENV->txn_begin; 129 my $txn = $cf::DB_ENV->txn_begin;
127 BDB::db_del $db_mapinfo, $txn, $key; 130 BDB::db_del $db_mapinfo, $txn, $key;
128 for my $tag (@{ $tags || [] }) { 131 for my $tag (@{ $tags || [] }) {
129 remove_tag_target $txn, $tag, $key; 132 remove_tag_target $txn, $tag, $key;
130 } 133 }
131 BDB::db_txn_commit $txn; 134 BDB::db_txn_finish $txn;
132 } 135 }
133 } 136 }
134 137
135 # 2. scan all static maps 138 # 2. scan all static maps
136 scan_static $cf::MAPDIR, "/"; 139 scan_static $cf::MAPDIR, "/";
166# delete $map->{deny_reset}; 169# delete $map->{deny_reset};
167# } 170# }
168# } 171# }
169# } 172# }
170 173
171 warn sprintf "map-tag scan (%fs)", Event::time - $start; 174 warn sprintf "map-tag scan (%fs)", EV::time - $start;
172} 175}
173 176
174our $RELOAD_SCHEDULER = Event->timer ( 177our $RELOAD_SCHEDULER = cf::periodic $SCHEDULE_INTERVAL, Coro::unblock_sub {
175 after => 0,
176 interval => $SCHEDULE_INTERVAL,
177 data => cf::WF_AUTOCANCEL,
178 cb => Coro::unblock_sub {
179 $Coro::current->prio (Coro::PRIO_MIN); 178 $Coro::current->prio (Coro::PRIO_MIN);
179 $Coro::current->desc ("map-tag scanner");
180 reload; 180 reload;
181 }, 181};
182);
183 182
184# find all objects with the given tag, or at least try to 183# find all objects with the given tag, or at least try to
185sub find($) { 184sub find($) {
186 my ($tag) = @_; 185 my ($tag) = @_;
187 186

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines