ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.297 by root, Thu Jul 5 08:10:30 2007 UTC vs.
Revision 1.298 by root, Sun Jul 8 14:50:07 2007 UTC

421 421
422 if (my $pid = fork) { 422 if (my $pid = fork) {
423 close $fh2; 423 close $fh2;
424 424
425 my $res = (Coro::Handle::unblock $fh1)->readline (undef); 425 my $res = (Coro::Handle::unblock $fh1)->readline (undef);
426 warn "pst<$res>" unless $res =~ /^pst/;
426 $res = Coro::Storable::thaw $res; 427 $res = Coro::Storable::thaw $res;
427 428
428 waitpid $pid, 0; # should not block anymore, we expect the child to simply behave 429 waitpid $pid, 0; # should not block anymore, we expect the child to simply behave
429 430
430 die $$res unless "ARRAY" eq ref $res; 431 Carp::confess $$res unless "ARRAY" eq ref $res;
431 432
432 return wantarray ? @$res : $res->[-1]; 433 return wantarray ? @$res : $res->[-1];
433 } else { 434 } else {
434 reset_signals; 435 reset_signals;
435 local $SIG{__WARN__}; 436 local $SIG{__WARN__};
436 local $SIG{__DIE__}; 437 local $SIG{__DIE__};
438 local $Coro::idle;
439 $Coro::current->prio (Coro::PRIO_MAX);
437 eval { 440 eval {
438 close $fh1; 441 close $fh1;
439 442
440 my @res = eval { $cb->(@args) }; 443 my @res = eval { $cb->(@args) };
441 syswrite $fh2, Coro::Storable::freeze +($@ ? \"$@" : \@res); 444
445 open my $fh, ">", \my $buf
446 or die "fork_call: cannot open fh-to-buf in child : $!";
447 Storable::store_fd +($@ ? \"$@" : \@res), $fh;
448 close $fh;
449
450 warn "writing ", length $buf;
451 my $x;
452 (length $buf) == ($x = syswrite $fh2, $buf)
453 or warn "error writing ".(length $buf)." != $x\n";
454 close $fh2;
442 }; 455 };
443 456
444 warn $@ if $@; 457 warn $@ if $@;
445 _exit 0; 458 _exit 0;
446 } 459 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines