[libmessage-passing-zeromq-perl] 09/78: Does replacing fork like this even work, at all?

Jonas Smedegaard js at alioth.debian.org
Mon Sep 30 09:28:17 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libmessage-passing-zeromq-perl.

commit eb6fabfa7a831b89c298d934deccd0f7260dd30a
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sat Feb 25 21:27:55 2012 +0000

    Does replacing fork like this even work, at all?
---
 lib/Log/Stash/Input/ZeroMQ.pm  |    6 +-----
 lib/Log/Stash/Output/ZeroMQ.pm |    8 +-------
 lib/Log/Stash/ZeroMQ.pm        |   26 +++++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/lib/Log/Stash/Input/ZeroMQ.pm b/lib/Log/Stash/Input/ZeroMQ.pm
index ff0e0b7..a7a4c8b 100644
--- a/lib/Log/Stash/Input/ZeroMQ.pm
+++ b/lib/Log/Stash/Input/ZeroMQ.pm
@@ -14,11 +14,7 @@ has socket_bind => (
     default => 'tcp://*:5558',
 );
 
-has _ctx => (
-    is => 'ro',
-    isa => 'ZeroMQ::Context',
-    default => sub { ZeroMQ::Context->new() },
-);
+with 'Log::Stash::ZeroMQ::Role::HasAContext';
 
 has _socket => (
     is => 'ro',
diff --git a/lib/Log/Stash/Output/ZeroMQ.pm b/lib/Log/Stash/Output/ZeroMQ.pm
index 0981e66..91a9b50 100644
--- a/lib/Log/Stash/Output/ZeroMQ.pm
+++ b/lib/Log/Stash/Output/ZeroMQ.pm
@@ -3,13 +3,7 @@ use Moose;
 use ZeroMQ ':all';
 use namespace::autoclean;
 
-has _ctx => (
-    is => 'ro',
-    isa => 'ZeroMQ::Context',
-    lazy => 1,
-    default => sub { ZeroMQ::Context->new() },
-    clearer => '_clear_ctx',
-);
+with 'Log::Stash::ZeroMQ::Role::HasAContext';
 
 has connect => (
     isa => 'Str',
diff --git a/lib/Log/Stash/ZeroMQ.pm b/lib/Log/Stash/ZeroMQ.pm
index 2d9e2db..8647b8c 100644
--- a/lib/Log/Stash/ZeroMQ.pm
+++ b/lib/Log/Stash/ZeroMQ.pm
@@ -1,11 +1,35 @@
 package Log::Stash::ZeroMQ;
-use Moose;
+use Moose ();
 use ZeroMQ;
 use namespace::autoclean;
 
 our $VERSION = "0.001";
 $VERSION = eval $VERSION;
 
+use base 'Exporter';
+
+our @EXPORT = qw/
+    fork
+/;
+
+our @CONTEXTS;
+
+our $FORK;
+sub import {
+    $FORK ||= *{'CORE::GLOBAL::fork'};
+    # Test this even works?
+    *{'CORE::GLOBAL::fork'} = \⋔
+    shift->SUPER::import(@_);
+}
+
+sub fork {
+    foreach my $ctx (grep { defined $_ } @CONTEXTS) {
+        $ctx->term;
+    }
+    # FIXME - What if fork has already been replaced?
+    $FORK->(@_);
+}
+
 1;
 
 =head1 NAME

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmessage-passing-zeromq-perl.git



More information about the Pkg-perl-cvs-commits mailing list