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.15 by root, Mon Aug 6 02:11:45 2007 UTC vs.
Revision 1.19 by root, Mon Aug 20 16:16:06 2007 UTC

49 CFPlus::DB::Server::req (put => @_); 49 CFPlus::DB::Server::req (put => @_);
50} 50}
51 51
52sub unlink($$) { 52sub unlink($$) {
53 CFPlus::DB::Server::req (unlink => @_); 53 CFPlus::DB::Server::req (unlink => @_);
54}
55
56sub read_file($$) {
57 CFPlus::DB::Server::req (read_file => @_);
54} 58}
55 59
56sub write_file($$$) { 60sub write_file($$$) {
57 CFPlus::DB::Server::req (write_file => @_); 61 CFPlus::DB::Server::req (write_file => @_);
58} 62}
106 -Cachesize => 8_000_000, 110 -Cachesize => 8_000_000,
107 -ErrFile => "$DB_HOME/errorlog.txt", 111 -ErrFile => "$DB_HOME/errorlog.txt",
108# -ErrPrefix => "DATABASE", 112# -ErrPrefix => "DATABASE",
109 -Verbose => 1, 113 -Verbose => 1,
110 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | $recover, 114 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | $recover,
111 -SetFlags => DB_AUTO_COMMIT | DB_LOG_AUTOREMOVE, 115 -SetFlags => DB_AUTO_COMMIT | DB_LOG_AUTOREMOVE | DB_TXN_WRITE_NOSYNC,
112 or die "unable to create/open database home $DB_HOME: $BerkeleyDB::Error"; 116 or die "unable to create/open database home $DB_HOME: $BerkeleyDB::Error";
113 117
114 1 118 1
115} 119}
116 120
124 -Env => $DB_ENV, 128 -Env => $DB_ENV,
125 -Filename => $table, 129 -Filename => $table,
126# -Filename => "database", 130# -Filename => "database",
127# -Subname => $table, 131# -Subname => $table,
128 -Property => DB_CHKSUM, 132 -Property => DB_CHKSUM,
129 -Flags => DB_CREATE | DB_UPGRADE, 133 -Flags => DB_AUTO_COMMIT | DB_CREATE | DB_UPGRADE,
130 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error" 134 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"
131 } 135 }
132} 136}
133 137
134our %CB; 138our %CB;
137our ($fh_r_watcher, $fh_w_watcher); 141our ($fh_r_watcher, $fh_w_watcher);
138our $sync_timer; 142our $sync_timer;
139our $write_buf; 143our $write_buf;
140our $read_buf; 144our $read_buf;
141 145
142our $SYNC = Event->idle (min => 5, max => 60, parked => 1, cb => sub { 146our $SYNC = Event->idle (min => 120, max => 180, parked => 1, cb => sub {
143 CFPlus::DB::Server::req (sync => sub { }); 147 CFPlus::DB::Server::req (sync => sub { });
144 $_[0]->w->stop; 148 $_[0]->w->stop;
145}); 149});
146 150
147sub fh_write { 151sub fh_write {
265 269
266 return $id; 270 return $id;
267 } 271 }
268 } 272 }
269 $txn->txn_abort; 273 $txn->txn_abort;
274 select undef, undef, undef, 0.01 * rand;
270 } 275 }
271 276
272 die "maximum number of transaction retries reached - database problems?"; 277 die "maximum number of transaction retries reached - database problems?";
273} 278}
274 279
275sub do_unlink { 280sub do_unlink {
276 unlink $_[0]; 281 unlink $_[0];
277} 282}
278 283
284sub do_read_file {
285 my ($path) = @_;
286
287 utf8::downgrade $path;
288 open my $fh, "<:raw", $path
289 or return;
290 sysread $fh, my $buf, -s $fh;
291
292 $buf
293}
294
279sub do_write_file { 295sub do_write_file {
280 my ($file, $data) = @_; 296 my ($path, $data) = @_;
281 297
282 utf8::downgrade $file; 298 utf8::downgrade $path;
283 utf8::downgrade $data; 299 utf8::downgrade $data;
284 open my $fh, ">:raw", $file 300 open my $fh, ">:raw", $path
285 or return; 301 or return;
286 print $fh $data; 302 syswrite $fh, $data;
287 close $fh; 303 close $fh;
288 304
289 1 305 1
290} 306}
291 307
292sub do_prefetch_file { 308sub do_prefetch_file {
293 my ($file, $size) = @_; 309 my ($path, $size) = @_;
294 310
295 utf8::downgrade $file; 311 utf8::downgrade $path;
296 open my $fh, "<:raw", $file 312 open my $fh, "<:raw", $path
297 or return; 313 or return;
298 sysread $fh, my $buf, $size; 314 sysread $fh, my $buf, $size;
299 315
300 1 316 1
301} 317}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines