--- deliantra/Deliantra-Client/DC/DB.pm 2007/04/06 08:09:43 1.2 +++ deliantra/Deliantra-Client/DC/DB.pm 2007/04/16 21:06:37 1.6 @@ -19,7 +19,9 @@ use Carp (); use AnyEvent (); -use Storable (); # finally +use Storable (); + +use CFPlus; sub sync { # for debugging @@ -102,7 +104,7 @@ } } -our $SYNC_INTERVAL = 6; +our $SYNC_INTERVAL = 60; our %CB; our $FH; @@ -179,6 +181,7 @@ sub do_get { my ($db, $key) = @_; + utf8::downgrade $key; my $data; (table $db)->db_get ($key, $data) == 0 ? $data @@ -188,6 +191,8 @@ sub do_put { my ($db, $key, $data) = @_; + utf8::downgrade $key; + utf8::downgrade $data; (table $db)->db_put ($key => $data) } @@ -245,7 +250,7 @@ close $FH; unless (eval { open_db }) { - File::Path::rmtree $DB_HOME; + eval { File::Path::rmtree $DB_HOME }; open_db; } @@ -280,7 +285,7 @@ } close $fh; - fcntl $FH, F_SETFL, O_NONBLOCK; + CFPlus::fh_nonblocking $FH, 1; $CB{die} = sub { die shift }; @@ -289,6 +294,10 @@ sync_tick; } +sub stop { + close $FH; +} + 1; =back