use JSON as the ForkCall serialiser
authorDirk Koopman <djk@tobit.co.uk>
Fri, 18 Jul 2014 15:29:37 +0000 (16:29 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 18 Jul 2014 15:29:37 +0000 (16:29 +0100)
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.

perl/DXCommandmode.pm
perl/DXCron.pm
perl/DXDebug.pm
perl/DXLog.pm

index 403dd134072841269777a6eda12e8f01d5561559..a8f0131a39975369a37e7038cb105f657b53cfb2 100644 (file)
@@ -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,
index 70c8e6606515015731646ccc4a3e6490cb51c0ef..29b35ca4811d737743e8c35336487bda088e99e0 100644 (file)
@@ -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;
index 5bf2470dbf8526282902c7592eab9234654f4ade..1207492dbb0ec77209edb8816b4d574b95f8177a 100644 (file)
@@ -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;
index e8d289b0995079b531eb0ce8ff1431626583db3a..0327a7c7d251913200acc69ee2e015aad9975503 100644 (file)
@@ -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;