From: Dirk Koopman Date: Fri, 18 Jul 2014 15:29:37 +0000 (+0100) Subject: use JSON as the ForkCall serialiser X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e50c4fa111795e0cea2325d68bf1d2a9ce14f18;p=spider.git use JSON as the ForkCall serialiser It appears that perl 5.10.1 has "issues" with Storable freeze/thaw and, as we aren't doing anything clever with Mojo::IOLoop::Forkcall in DXCommandmode, we will use JSON instead. --- diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 403dd134..a8f0131a 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -37,6 +37,7 @@ use DB_File; use VE7CC; use DXXml; use AsyncMsg; +use JSON; use Mojo::IOLoop; use Mojo::IOLoop::ForkCall; @@ -1273,6 +1274,8 @@ sub spawn_cmd no strict 'refs'; my $fc = Mojo::IOLoop::ForkCall->new; + $fc->serializer(\&encode_json); + $fc->deserializer(\&decode_json); $fc->run( sub {my @args = @_; my @res = $cmdref->(@args); return @res}, $args, diff --git a/perl/DXCron.pm b/perl/DXCron.pm index 70c8e660..29b35ca4 100644 --- a/perl/DXCron.pm +++ b/perl/DXCron.pm @@ -249,6 +249,8 @@ sub spawn # in child, unset warnings, disable debugging and general clean up from us $^W = 0; eval "{ package DB; sub DB {} }"; + dbgclose(); + Logclose(); DXChannel::closeall(); for (@main::listeners) { $_->close_server; diff --git a/perl/DXDebug.pm b/perl/DXDebug.pm index 5bf2470d..1207492d 100644 --- a/perl/DXDebug.pm +++ b/perl/DXDebug.pm @@ -116,9 +116,11 @@ sub dbgclose sub dbgdump { + return unless $fp; + my $l = shift; my $m = shift; - if ($fp && ($dbglevel{$l} || $l eq 'err')) { + if ($dbglevel{$l} || $l eq 'err') { foreach my $l (@_) { for (my $o = 0; $o < length $l; $o += 16) { my $c = substr $l, $o, 16; diff --git a/perl/DXLog.pm b/perl/DXLog.pm index e8d289b0..0327a7c7 100644 --- a/perl/DXLog.pm +++ b/perl/DXLog.pm @@ -206,6 +206,8 @@ sub DESTROY # The user is responsible for making sense of this! sub Log { + return unless $log; + my $t = time; $log->writeunix($t, join('^', $t, @_) ); } @@ -219,5 +221,6 @@ sub LogDbg sub Logclose { $log->close(); + undef $log; } 1;