Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 96:ecff5407867c
Tests: better handle unexpected connection close from nginx.
Problem found when running test suite indefinitely against nginx with
intentionally broken malloc().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 08 Jun 2009 23:27:30 +0400 |
parents | 5276d85d5040 |
children | 9ddc18214854 |
comparison
equal
deleted
inserted
replaced
95:cbc17561ef4d | 96:ecff5407867c |
---|---|
252 | 252 |
253 sub http($;%) { | 253 sub http($;%) { |
254 my ($request, %extra) = @_; | 254 my ($request, %extra) = @_; |
255 my $reply; | 255 my $reply; |
256 eval { | 256 eval { |
257 local $SIG{ALRM} = sub { die "alarm\n" }; | 257 local $SIG{ALRM} = sub { die "timeout\n" }; |
258 local $SIG{PIPE} = sub { die "sigpipe\n" }; | |
258 alarm(2); | 259 alarm(2); |
259 my $s = IO::Socket::INET->new( | 260 my $s = IO::Socket::INET->new( |
260 Proto => 'tcp', | 261 Proto => 'tcp', |
261 PeerAddr => '127.0.0.1:8080' | 262 PeerAddr => '127.0.0.1:8080' |
262 ); | 263 ); |
269 log_in($reply); | 270 log_in($reply); |
270 alarm(0); | 271 alarm(0); |
271 }; | 272 }; |
272 alarm(0); | 273 alarm(0); |
273 if ($@) { | 274 if ($@) { |
274 log_in('(timeout)'); | 275 log_in("died: $@"); |
275 return undef; | 276 return undef; |
276 } | 277 } |
277 return $reply; | 278 return $reply; |
278 } | 279 } |
279 | 280 |