backport DXSubprocess to change serialisations
authorDirk Koopman <djk@tobit.co.uk>
Sun, 17 May 2020 10:28:40 +0000 (11:28 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Sun, 17 May 2020 10:28:40 +0000 (11:28 +0100)
Currently the internals of Mojo::IOLoop::Subprocess defaults to
using Storaable as its cross-process argument and data serialisaion
method. It can use others. This update reverts back to the
original ForkCall method of using JSON.

Changes
perl/DXCommandmode.pm
perl/DXCron.pm
perl/DXProt.pm
perl/DXSubprocess.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index 1d501d207f007638068a5a3c32528f5cef6c2d27..745ea5ff487115d80a148ae01bdbdc1ceb92e834 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,9 @@
+17May20=======================================================================
+1. Backport DXSubprocess to change serialisations.
+   Currently the internals of Mojo::IOLoop::Subprocess defaults to
+   using Storeable as its cross-process argument and data serialisaion
+   method. It can use others. This update reverts back to the
+   original ForkCall method of using JSON.
 10May20=======================================================================
 1. Added basic changes so that users *could* have multiple connections to the
    same node if it is allowed. This is work in progress and is there to see 
index 9d9f60b45e90b199fda5f5c4246d064d8ef1e412..a31cc4dee92c82b241941001d67c46530b685fe9 100644 (file)
@@ -43,7 +43,7 @@ use JSON;
 use Time::HiRes qw(gettimeofday tv_interval);
 
 use Mojo::IOLoop;
-use Mojo::IOLoop::Subprocess;
+use DXSubprocess;
 use Mojo::UserAgent;
 
 use strict;
@@ -1316,7 +1316,7 @@ sub spawn_cmd
                return @out;
        }
        
-       my $fc = Mojo::IOLoop::Subprocess->new;
+       my $fc = DXSubprocess->new;
 #      $fc->serializer(\&encode_json);
 #      $fc->deserializer(\&decode_json);
        $fc->run(
index 0c388e9d6aa77af2111dd50e4802cd40c7a68737..b0d4b1c6dc6609c158cd3568cd5ce2e168f9ce9b 100644 (file)
@@ -15,7 +15,7 @@ use DXDebug;
 use IO::File;
 use DXLog;
 use Time::HiRes qw(gettimeofday tv_interval);
-use Mojo::IOLoop::Subprocess;
+use DXSubprocess;
 
 use strict;
 
@@ -257,7 +257,7 @@ sub spawn
        my $t0 = [gettimeofday];
 
        dbg("DXCron::spawn: $line") if isdbg("cron");
-       my $fc = Mojo::IOLoop::Subprocess->new();
+       my $fc = DXSubprocess->new();
        $fc->run(
                         sub {
                                 my @res = `$line`;
@@ -286,7 +286,7 @@ sub spawn_cmd
        my $t0 = [gettimeofday];
 
        dbg("DXCron::spawn_cmd run: $line") if isdbg('cron');
-       my $fc = Mojo::IOLoop::Subprocess->new();
+       my $fc = DXSubprocess->new();
        $fc->run(
                         sub {
                                 $main::me->{_nospawn} = 1;
index dc5dc0b99e5bc08198e96831a7853db07dea0807..aae3cc77259436ffc0fb75eb5fa6651a48f2e6bc 100644 (file)
@@ -35,7 +35,7 @@ use Script;
 use DXProtHandle;
 
 use Time::HiRes qw(gettimeofday tv_interval);
-use Mojo::IOLoop::Subprocess;
+use DXSubprocess;
 
 use strict;
 
@@ -1216,7 +1216,7 @@ sub spawn_cmd
 
        no strict 'refs';
                
-       my $fc = Mojo::IOLoop::Subprocess->new;
+       my $fc = DXSubprocess->new;
 
        # just behave normally if something has set the "one-shot" _nospawn in the channel
        if ($self->{_nospawn}) {
diff --git a/perl/DXSubprocess.pm b/perl/DXSubprocess.pm
new file mode 100644 (file)
index 0000000..4442762
--- /dev/null
@@ -0,0 +1,23 @@
+#
+# A light shim over Mojo::IOLoop::Subprocess (or Mojo::IOLoop::ForkCall, if we need to go back to that)
+#
+# But we stop using Storable!
+#
+
+package DXSubprocess;
+
+use DXUtil;
+use DXDebug;
+use Mojo::IOLoop;
+use    Mojo::IOLoop::Subprocess;
+use JSON;
+
+our @ISA = qw(Mojo::IOLoop::Subprocess);
+
+sub new
+{
+       my $pkg = shift;
+       my $class = ref $pkg || __PACKAGE__;
+       my $ref = Mojo::IOLoop::Subprocess->new->serialize(\&encode_json)->deserialize(\&decode_json);
+       return bless $ref, $class;
+}