Mercurial > hg > nginx-tests
comparison stream_upstream_least_conn.t @ 805:b8db75ef1f00
Tests: stream_upstream_least_conn.t cleanup.
No functional changes.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 14 Dec 2015 16:19:08 +0300 |
parents | 824754da4afc |
children | 77359b849cd5 |
comparison
equal
deleted
inserted
replaced
804:6b2512f859a0 | 805:b8db75ef1f00 |
---|---|
82 for (1 .. $count) { | 82 for (1 .. $count) { |
83 if (stream_get($data, $peer) =~ /(\d+)/) { | 83 if (stream_get($data, $peer) =~ /(\d+)/) { |
84 $ports{$1} = 0 unless defined $ports{$1}; | 84 $ports{$1} = 0 unless defined $ports{$1}; |
85 $ports{$1}++; | 85 $ports{$1}++; |
86 } | 86 } |
87 } | |
88 | |
89 return join ', ', map { $_ . ": " . $ports{$_} } sort keys %ports; | |
90 } | |
91 | |
92 sub parallel { | |
93 my ($data, $count, %opts) = @_; | |
94 my (@sockets, %ports, $peer); | |
95 | |
96 $peer = $opts{peer} || undef; | |
97 | |
98 for (1 .. $count) { | |
99 my $s = stream_connect($peer); | |
100 push @sockets, $s; | |
101 stream_write($s, $data); | |
102 select undef, undef, undef, 0.2; | |
103 } | |
104 | |
105 for (1 .. $count) { | |
106 my $s = pop @sockets; | |
107 if (stream_read($s) =~ /(\d+)/) { | |
108 $ports{$1} = 0 unless defined $ports{$1}; | |
109 $ports{$1}++; | |
110 } | |
111 close $s; | |
112 } | 87 } |
113 | 88 |
114 return join ', ', map { $_ . ": " . $ports{$_} } sort keys %ports; | 89 return join ', ', map { $_ . ": " . $ports{$_} } sort keys %ports; |
115 } | 90 } |
116 | 91 |