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.14 by root, Sun Jul 29 19:32:29 2007 UTC vs.
Revision 1.15 by root, Mon Aug 6 02:11:45 2007 UTC

57 CFPlus::DB::Server::req (write_file => @_); 57 CFPlus::DB::Server::req (write_file => @_);
58} 58}
59 59
60sub prefetch_file($$$) { 60sub prefetch_file($$$) {
61 CFPlus::DB::Server::req (prefetch_file => @_); 61 CFPlus::DB::Server::req (prefetch_file => @_);
62}
63
64sub logprint($$$) {
65 CFPlus::DB::Server::req (logprint => @_);
62} 66}
63 67
64our $tilemap; 68our $tilemap;
65 69
66sub get_tile_id_sync($) { 70sub get_tile_id_sync($) {
294 sysread $fh, my $buf, $size; 298 sysread $fh, my $buf, $size;
295 299
296 1 300 1
297} 301}
298 302
303our %LOG_FH;
304
305sub do_logprint {
306 my ($path, $line) = @_;
307
308 $LOG_FH{$path} ||= do {
309 open my $fh, ">>:utf8", $path
310 or warn "Couldn't open logfile $path: $!";
311
312 $fh->autoflush (1);
313
314 $fh
315 };
316
317 my ($sec, $min, $hour, $mday, $mon, $year) = localtime time;
318
319 my $ts = sprintf "%04d-%02d-%02d %02d:%02d:%02d",
320 $year + 1900, $mon + 1, $mday, $hour, $min, $sec;
321
322 print { $LOG_FH{$path} } "$ts $line\n"
323}
324
299sub run { 325sub run {
300 ($FH, my $fh) = CFPlus::socketpipe; 326 ($FH, my $fh) = CFPlus::socketpipe;
301 327
302 my $oldfh = select $FH; $| = 1; select $oldfh; 328 my $oldfh = select $FH; $| = 1; select $oldfh;
303 my $oldfh = select $fh; $| = 1; select $oldfh; 329 my $oldfh = select $fh; $| = 1; select $oldfh;
304 330
305 my $pid = fork; 331 my $pid = fork;
306 332
307 if (defined $pid && !$pid) { 333 if (defined $pid && !$pid) {
334 local $SIG{QUIT};
308 local $SIG{__DIE__}; 335 local $SIG{__DIE__};
336 local $SIG{__WARN__};
309 eval { 337 eval {
310 close $FH; 338 close $FH;
311 339
312 unless (eval { open_db }) { 340 unless (eval { open_db }) {
313 eval { File::Path::rmtree $DB_HOME }; 341 eval { File::Path::rmtree $DB_HOME };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines