--- deliantra/Deliantra-Client/DC/DB.pm 2007/08/28 20:07:18 1.20 +++ deliantra/Deliantra-Client/DC/DB.pm 2007/11/12 23:25:37 1.21 @@ -20,7 +20,6 @@ use Carp (); use Storable (); use Config; -use Event (); use CFPlus; @@ -151,10 +150,10 @@ our $write_buf; our $read_buf; -our $SYNC = Event->idle (min => 120, max => 180, parked => 1, cb => sub { +our $SYNC = EV::timer_ns 0, 60, sub { + $_[0]->stop; CFPlus::DB::Server::req (sync => sub { }); - $_[0]->w->stop; -}); +}; sub fh_write { my $len = syswrite $FH, $write_buf; @@ -208,7 +207,7 @@ $CB{$id} = $cb; $fh_w_watcher->start; - $SYNC->start; + $SYNC->again unless $SYNC->is_active; } sub do_sync { @@ -380,7 +379,7 @@ or die "$type: unknown database request type\n"; my $res = pack "N/a*", Storable::freeze [$id, $cb->(@args)]; (syswrite $fh, $res) == length $res - or die; + or die "DB::write: $!"; } }; @@ -393,6 +392,7 @@ Storable::store_fd [die => $error], $fh; }; + $DB_ENV->txn_checkpoint (0, 0, 0); CFPlus::_exit 0; } @@ -401,9 +401,9 @@ $CB{die} = sub { die shift }; - $fh_r_watcher = Event->io (fd => $FH, poll => 'r', nice => 1, cb => \&fh_read); - $fh_w_watcher = Event->io (fd => $FH, poll => 'w', nice => -1, parked => 1, cb => \&fh_write); - $SYNC->start; + $fh_r_watcher = EV::io $FH, EV::READ , \&fh_read; + $fh_w_watcher = EV::io $FH, EV::WRITE, \&fh_write; + $SYNC->again unless $SYNC->is_active; } sub stop {