From: Dirk Koopman <djk@tobit.co.uk>
Date: Fri, 15 May 2020 15:52:03 +0000 (+0100)
Subject: various (hopeful) stability changes
X-Git-Url: http://dxspider.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd533381ad4e4cb991dd1b46a0be938c93bbadc7;p=spider.git

various (hopeful) stability changes

1. Remove Storable from subprocessing, introduce DXSubcommand as
   a light shim over Mojo::IOLoop::Subprocess.
2. Try to prevent user->put when in a spawned process. Which will
   likely need more thinking about and more work.
3. Make it clearer where the spawns are coming from.
---

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;
+}