Skip to content

Commit

Permalink
Make sure enabling culling/shm vivifies pid/tid
Browse files Browse the repository at this point in the history
Fixes #679
  • Loading branch information
exodist committed Jun 7, 2016
1 parent 3cc4ea8 commit 1168c17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@
{{$NEXT}}

- Make sure enabling culling/shm sets pid and tid (Fix #679)

1.302024 2016-06-02 20:27:35-07:00 America/Los_Angeles (TRIAL RELEASE)

- Add Generic event type
Expand Down
6 changes: 6 additions & 0 deletions lib/Test2/API/Instance.pm
Expand Up @@ -270,6 +270,9 @@ sub add_ipc_driver {
sub enable_ipc_polling {
my $self = shift;

$self->{+_PID} = $$ unless defined $self->{+_PID};
$self->{+_TID} = get_tid() unless defined $self->{+_TID};

$self->add_context_init_callback(
# This is called every time a context is created, it needs to be fast.
# $_[0] is a context object
Expand Down Expand Up @@ -297,6 +300,9 @@ sub ipc_enable_shm {

return 1 if defined $self->{+IPC_SHM_ID};

$self->{+_PID} = $$ unless defined $self->{+_PID};
$self->{+_TID} = get_tid() unless defined $self->{+_TID};

my ($ok, $err) = try {
require IPC::SysV;

Expand Down
3 changes: 3 additions & 0 deletions t/Test2/modules/API/Instance.t
Expand Up @@ -428,6 +428,7 @@ if (CAN_REALLY_FORK) {

{
$one->reset;

ok(!@{$one->context_init_callbacks}, "no callbacks");
is($one->ipc_polling, undef, "no polling, undef");

Expand All @@ -441,6 +442,8 @@ if (CAN_REALLY_FORK) {
use warnings;

$one->enable_ipc_polling;
ok(defined($one->{_pid}), "pid is defined");
ok(defined($one->{_tid}), "tid is defined");
is(@{$one->context_init_callbacks}, 1, "added the callback");
is($one->ipc_polling, 1, "polling on");
$one->set_ipc_shm_last('abc1');
Expand Down

0 comments on commit 1168c17

Please sign in to comment.