lestrrat/ZeroMQ-Perl — pull request #22 by clintongormley (2011-12-07 17:02:28+00:00)
Title: Ensure context destroyed after socket

Hiya

This works as a partial fix for issue #20 - it ensures that the socket is closed before the context is destroyed.

With this patch, the test code below now works:

#!/usr/bin/perl

use strict;
use warnings;

use ZeroMQ qw(:all);

my $cxt = ZeroMQ::Context->new();
my $sock = $cxt->socket(ZMQ_PUB);

However:
* it breaks one test, and I'm not sure if the breakage is actually correct or not:

xt/100_eg_hello_world.t .. 1/? [Test::TCP] Child process does not block(PID: 20310, PPID: 20309) at /opt/perl-5.12.3-unthreaded/lib/site_perl/5.12.3/Test/TCP.pm line 119.

* it doesn't work for `zmq_socket` because that doesn't have anywhere to store its context until it has been destroyed.

It may be sufficient, when creating a new raw socket, to increment the ref count for the context, then when destroying the socket, to decrement the ref count again.