ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.208 by root, Mon Feb 12 00:27:20 2007 UTC vs.
Revision 1.209 by root, Mon Feb 12 01:25:55 2007 UTC

2197 2197
2198=cut 2198=cut
2199 2199
2200our $DB; 2200our $DB;
2201 2201
2202sub db_load() {
2203 unless ($DB) { 2202unless ($DB) {
2204 $DB = BDB::db_create $DB_ENV; 2203 $DB = BDB::db_create $DB_ENV;
2205 2204
2205 cf::sync_job {
2206 eval {
2207 $DB->set_flags (BDB::CHKSUM);
2208
2209 BDB::db_open $DB, undef, "db", undef, BDB::BTREE,
2210 BDB::CREATE | BDB::AUTO_COMMIT, 0666;
2211 cf::cleanup "db_open(db): $!" if $!;
2212 };
2213 cf::cleanup "db_open(db): $@" if $@;
2214 };
2215
2216 my $path = cf::localdir . "/database.pst";
2217 if (stat $path) {
2206 cf::sync_job { 2218 cf::sync_job {
2207 eval { 2219 my $pst = Storable::retrieve $path;
2208 $DB->set_flags (BDB::CHKSUM);
2209 2220
2210 BDB::db_open $DB, undef, "db", undef, BDB::BTREE, 2221 cf::db_put (board => data => $pst->{board});
2211 BDB::CREATE | BDB::AUTO_COMMIT, 0666; 2222 cf::db_put (guildrules => data => $pst->{guildrules});
2212 cf::cleanup "db_open(db): $!" if $!; 2223 cf::db_put (rent => balance => $pst->{rent}{balance});
2213 }; 2224 BDB::db_env_txn_checkpoint $DB_ENV;
2214 cf::cleanup "db_open(db): $@" if $@; 2225
2226 unlink $path;
2215 }; 2227 };
2216
2217 my $path = cf::localdir . "/database.pst";
2218 if (stat $path) {
2219 cf::sync_job {
2220 my $pst = Storable::retrieve $path;
2221
2222 cf::db_put (board => data => $pst->{board});
2223 cf::db_put (guildrules => data => $pst->{guildrules});
2224 cf::db_put (rent => balance => $pst->{rent}{balance});
2225 BDB::db_env_txn_checkpoint $DB_ENV;
2226
2227 unlink $path;
2228 };
2229 }
2230 } 2228 }
2231} 2229}
2232 2230
2233sub db_get($$) { 2231sub db_get($$) {
2234 my $key = "$_[0]/$_[1]"; 2232 my $key = "$_[0]/$_[1]";
2287 Event::one_event; 2285 Event::one_event;
2288 })->prio (Coro::PRIO_MAX); 2286 })->prio (Coro::PRIO_MAX);
2289 }; 2287 };
2290 2288
2291 cfg_load; 2289 cfg_load;
2292 db_load;
2293 load_extensions; 2290 load_extensions;
2294 2291
2295 $TICK_WATCHER->start; 2292 $TICK_WATCHER->start;
2296 Event::loop; 2293 Event::loop;
2297} 2294}
2440 require cf; 2437 require cf;
2441 cf::_connect_to_perl; # nominally unnecessary, but cannot hurt 2438 cf::_connect_to_perl; # nominally unnecessary, but cannot hurt
2442 2439
2443 warn "loading config and database again"; 2440 warn "loading config and database again";
2444 cf::cfg_load; 2441 cf::cfg_load;
2445 cf::db_load;
2446 2442
2447 warn "loading extensions"; 2443 warn "loading extensions";
2448 cf::load_extensions; 2444 cf::load_extensions;
2449 2445
2450 warn "reattaching attachments to objects/players"; 2446 warn "reattaching attachments to objects/players";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines