Mercurial > hg > nginx-tests
comparison spdy.t @ 377:ba95a443ff1f
Tests: improved spdy test robustness.
Give raw_read() a little more chance to complete.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 24 Feb 2014 14:09:16 +0400 |
parents | ab2d8abea393 |
children | f42de3a9fd74 |
comparison
equal
deleted
inserted
replaced
376:ab2d8abea393 | 377:ba95a443ff1f |
---|---|
587 raw_write($sess->{socket}, $buf); | 587 raw_write($sess->{socket}, $buf); |
588 } | 588 } |
589 | 589 |
590 sub spdy_read { | 590 sub spdy_read { |
591 my ($sess, %extra) = @_; | 591 my ($sess, %extra) = @_; |
592 my ($skip, $length, @got); | 592 my ($skip, $length, $buf, @got); |
593 my $tries = 0; | |
594 my $maxtried = 3; | |
593 | 595 |
594 again: | 596 again: |
595 my $buf = raw_read($sess->{socket}) or return undef; | 597 do { |
598 $buf = raw_read($sess->{socket}); | |
599 } until (defined $buf || $tries++ >= $maxtried); | |
596 | 600 |
597 for ($skip = 0; $skip < length $buf; $skip += $length + 8) { | 601 for ($skip = 0; $skip < length $buf; $skip += $length + 8) { |
598 my $type = unpack("\@$skip B", $buf); | 602 my $type = unpack("\@$skip B", $buf); |
599 $length = hex unpack("\@$skip x5 H6", $buf); | 603 $length = hex unpack("\@$skip x5 H6", $buf); |
600 if ($type == 0) { | 604 if ($type == 0) { |
605 | 609 |
606 my $ctype = unpack("\@$skip x2 n", $buf); | 610 my $ctype = unpack("\@$skip x2 n", $buf); |
607 push @got, $cframe{$ctype}($sess, $skip, $buf); | 611 push @got, $cframe{$ctype}($sess, $skip, $buf); |
608 test_fin($got[-1], $extra{all}); | 612 test_fin($got[-1], $extra{all}); |
609 } | 613 } |
610 goto again if %extra && @{$extra{all}}; | 614 goto again if %extra && @{$extra{all}} && $tries < $maxtried; |
611 return \@got; | 615 return \@got; |
612 } | 616 } |
613 | 617 |
614 sub test_fin { | 618 sub test_fin { |
615 my ($frame, $all) = @_; | 619 my ($frame, $all) = @_; |