ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/DB.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/DB.pm (file contents):
Revision 1.35 by root, Sun Mar 30 06:05:52 2008 UTC vs.
Revision 1.38 by root, Fri Jul 18 22:40:51 2008 UTC

23use Config; 23use Config;
24use BDB; 24use BDB;
25 25
26use DC; 26use DC;
27 27
28our $ODBDIR = "cfplus-" . BDB::VERSION . "-$Config{archname}"; 28our $ODBDIR = "cfplus-" . BDB::VERSION_MAJOR . "." . BDB::VERSION_MINOR . "-$Config{archname}";
29our $DBDIR = "client-" . BDB::VERSION . "-$Config{archname}"; 29our $DBDIR = "client-" . BDB::VERSION_MAJOR . "." . BDB::VERSION_MINOR . "-$Config{archname}";
30our $DB_HOME = "$Deliantra::VARDIR/$DBDIR"; 30our $DB_HOME = "$Deliantra::VARDIR/$DBDIR";
31 31
32unless (-d $DB_HOME) { 32unless (-d $DB_HOME) {
33 if (-d "$Deliantra::VARDIR/$ODBDIR") { 33 if (-d "$Deliantra::VARDIR/$ODBDIR") {
34 rename "$Deliantra::VARDIR/$ODBDIR", $DB_HOME; 34 rename "$Deliantra::VARDIR/$ODBDIR", $DB_HOME;
51our $TILE_SEQ; 51our $TILE_SEQ;
52 52
53sub try_open_db { 53sub try_open_db {
54 File::Path::mkpath [$DB_HOME]; 54 File::Path::mkpath [$DB_HOME];
55 55
56 $DB_ENV = db_env_create; 56 my $env = db_env_create;
57 57
58 $DB_ENV->set_errfile (\*STDERR); 58 $env->set_errfile (\*STDERR);
59 $DB_ENV->set_msgfile (\*STDERR); 59 $env->set_msgfile (\*STDERR);
60 $DB_ENV->set_verbose (-1, 1); 60 $env->set_verbose (-1, 1);
61 61
62 $DB_ENV->set_flags (BDB::AUTO_COMMIT | BDB::LOG_AUTOREMOVE | BDB::TXN_WRITE_NOSYNC); 62 $env->set_flags (BDB::AUTO_COMMIT | BDB::LOG_AUTOREMOVE | BDB::TXN_WRITE_NOSYNC);
63 $DB_ENV->set_cachesize (0, 2048 * 1024, 0); 63 $env->set_cachesize (0, 2048 * 1024, 0);
64 64
65 db_env_open $DB_ENV, $DB_HOME, 65 db_env_open $env, $DB_HOME,
66 BDB::CREATE | BDB::REGISTER | BDB::RECOVER | BDB::INIT_MPOOL | BDB::INIT_LOCK | BDB::INIT_TXN, 66 BDB::CREATE | BDB::REGISTER | BDB::RECOVER | BDB::INIT_MPOOL | BDB::INIT_LOCK | BDB::INIT_TXN,
67 0666; 67 0666;
68 68
69 $! and die "cannot open database environment $DB_HOME: " . BDB::strerror; 69 $! and die "cannot open database environment $DB_HOME: " . BDB::strerror;
70
71 $DB_ENV = $env;
70 72
71 1 73 1
72} 74}
73 75
74sub table($) { 76sub table($) {
434 db_env_txn_checkpoint $DB_ENV, 0, 0, 0, sub { }; 436 db_env_txn_checkpoint $DB_ENV, 0, 0, 0, sub { };
435 }; 437 };
436} 438}
437 439
438END { 440END {
441 db_env_txn_checkpoint $DB_ENV, 0, 0, 0
442 if $DB_ENV;
443
439 undef $TILE_SEQ; 444 undef $TILE_SEQ;
440 %DB_TABLE = (); 445 %DB_TABLE = ();
441 undef $DB_ENV; 446 undef $DB_ENV;
442} 447}
443 448

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines