Skip to content

Instantly share code, notes, and snippets.

@calid
Last active August 29, 2015 14:16
Show Gist options
  • Save calid/2bd0d3aec4598a1257e5 to your computer and use it in GitHub Desktop.
Save calid/2bd0d3aec4598a1257e5 to your computer and use it in GitHub Desktop.
use Sys::SigAction qw(timeout_call);
my $timed_out = timeout_call 3, sub { # schedules SIGALRM
my $ctx = ZMQ::FFI->new();
my $s = $ctx->socket(ZMQ_REQ);
$s->connect("ipc:///tmp/test-zmq-ffi-$$");
$s->send('ohhai');
$s->close(); # bug here, linger not set
$ctx->destroy(); # hangs, SIGALRM breaks the hang
# end of scope, socket/ctx DEMOLISH triggers.. hangs again! woops
};
# never gets here
ok !$timed_out, 'implicit Socket cleanup done correctly (does not hang)';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment