Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 296:a113f4d55b12
Tests: fix hang on exit after errors in child processes.
The f781b087b7aa moved test directory removal from File::Temp, where
it was protected by a pid check, into Test::Nginx destructor. As a
result destruction triggered due to a child process death now removes
temp directory, thus preventing main process from stopping nginx as
it no longer able to read nginx.pid.
Fix is to protect destructor with pid check.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 08 Jun 2013 07:12:31 +0400 |
parents | f781b087b7aa |
children | b639e76ba923 |
comparison
equal
deleted
inserted
replaced
295:6fe0459b6668 | 296:a113f4d55b12 |
---|---|
33 | 33 |
34 sub new { | 34 sub new { |
35 my $self = {}; | 35 my $self = {}; |
36 bless $self; | 36 bless $self; |
37 | 37 |
38 $self->{_pid} = $$; | |
39 | |
38 $self->{_testdir} = tempdir( | 40 $self->{_testdir} = tempdir( |
39 'nginx-test-XXXXXXXXXX', | 41 'nginx-test-XXXXXXXXXX', |
40 TMPDIR => 1 | 42 TMPDIR => 1 |
41 ) | 43 ) |
42 or die "Can't create temp directory: $!\n"; | 44 or die "Can't create temp directory: $!\n"; |
45 return $self; | 47 return $self; |
46 } | 48 } |
47 | 49 |
48 sub DESTROY { | 50 sub DESTROY { |
49 my ($self) = @_; | 51 my ($self) = @_; |
52 return if $self->{_pid} != $$; | |
50 $self->stop(); | 53 $self->stop(); |
51 $self->stop_daemons(); | 54 $self->stop_daemons(); |
52 if ($ENV{TEST_NGINX_CATLOG}) { | 55 if ($ENV{TEST_NGINX_CATLOG}) { |
53 system("cat $self->{_testdir}/error.log"); | 56 system("cat $self->{_testdir}/error.log"); |
54 } | 57 } |