From 9d190c7619d08c4d2e82b8ec3a9e5c84dac9b26a Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sun, 17 May 2020 11:28:40 +0100 Subject: [PATCH] backport DXSubprocess to change serialisations 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 | 6 ++++++ perl/DXCommandmode.pm | 4 ++-- perl/DXCron.pm | 6 +++--- perl/DXProt.pm | 4 ++-- perl/DXSubprocess.pm | 23 +++++++++++++++++++++++ 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 perl/DXSubprocess.pm diff --git a/Changes b/Changes index 1d501d20..745ea5ff 100644 --- 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 diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 9d9f60b4..a31cc4de 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -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( diff --git a/perl/DXCron.pm b/perl/DXCron.pm index 0c388e9d..b0d4b1c6 100644 --- a/perl/DXCron.pm +++ b/perl/DXCron.pm @@ -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; diff --git a/perl/DXProt.pm b/perl/DXProt.pm index dc5dc0b9..aae3cc77 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -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 index 00000000..44427621 --- /dev/null +++ b/perl/DXSubprocess.pm @@ -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; +} -- 2.34.1