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.29 by root, Wed Dec 26 21:03:21 2007 UTC vs.
Revision 1.30 by root, Thu Dec 27 18:35:56 2007 UTC

30if (!-e $DB_HOME and -e "$Deliantra::OLDDIR/$DBDIR") { 30if (!-e $DB_HOME and -e "$Deliantra::OLDDIR/$DBDIR") {
31 rename "$Deliantra::OLDDIR/$DBDIR", $DB_HOME; 31 rename "$Deliantra::OLDDIR/$DBDIR", $DB_HOME;
32 print STDERR "INFO: moved old database from $Deliantra::OLDDIR/$DBDIR to $DB_HOME\n"; 32 print STDERR "INFO: moved old database from $Deliantra::OLDDIR/$DBDIR to $DB_HOME\n";
33} 33}
34 34
35BDB::max_poll_time 0.03;
36
35our $DB_ENV; 37our $DB_ENV;
36our $DB_STATE; 38our $DB_STATE;
37our %DB_TABLE; 39our %DB_TABLE;
38 40
39sub open_db { 41sub open_db {
166 die "maximum number of transaction retries reached - database problems?"; 168 die "maximum number of transaction retries reached - database problems?";
167} 169}
168 170
169sub get_tile_id_sync($) { 171sub get_tile_id_sync($) {
170 my ($name) = @_; 172 my ($name) = @_;
171
172 # fetch the full face table first
173 unless ($tilemap) {
174 do_table facemap => sub {
175 $tilemap = $_[0];
176 delete $tilemap->{id};
177 my %maptile = reverse %$tilemap;#d#
178 if ((scalar keys %$tilemap) != (scalar keys %maptile)) {#d#
179 $tilemap = { };#d#
180 DC::error "FATAL: facemap is not a 1:1 mapping, please report this and delete your $DB_HOME directory!\n";#d#
181 }#d#
182 };
183 BDB::flush;
184 }
185 173
186 $tilemap->{$name} ||= do { 174 $tilemap->{$name} ||= do {
187 my $id; 175 my $id;
188 do_get_tile_id $name, sub { 176 do_get_tile_id $name, sub {
189 $id = $_[0]; 177 $id = $_[0];
224 212
225sub logprint($$$) { 213sub logprint($$$) {
226 DC::DB::Server::req (logprint => @_); 214 DC::DB::Server::req (logprint => @_);
227} 215}
228 216
217#############################################################################
218
219# fetch the full face table first
220unless ($tilemap) {
221 do_table facemap => sub {
222 $tilemap = $_[0];
223 delete $tilemap->{id};
224 my %maptile = reverse %$tilemap;#d#
225 if ((scalar keys %$tilemap) != (scalar keys %maptile)) {#d#
226 $tilemap = { };#d#
227 DC::error "FATAL: facemap is not a 1:1 mapping, please report this and delete your $DB_HOME directory!\n";#d#
228 }#d#
229 };
230}
231
229package DC::DB::Server; 232package DC::DB::Server;
230 233
231use strict; 234use strict;
232 235
233use EV (); 236use EV ();
363 my $oldfh = select $fh; $| = 1; select $oldfh; 366 my $oldfh = select $fh; $| = 1; select $oldfh;
364 367
365 my $pid = fork; 368 my $pid = fork;
366 369
367 if (defined $pid && !$pid) { 370 if (defined $pid && !$pid) {
368 local $SIG{QUIT}; 371 local $SIG{QUIT} = "IGNORE";
369 local $SIG{__DIE__}; 372 local $SIG{__DIE__};
370 local $SIG{__WARN__}; 373 local $SIG{__WARN__};
371 eval { 374 eval {
372 close $FH; 375 close $FH;
373 376

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines