"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.9/t/maxconns.t" (21 Nov 2020, 931 Bytes) of package /linux/www/memcached-1.6.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "maxconns.t": 1.6.8_vs_1.6.9.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use Test::More;
    7 use FindBin qw($Bin);
    8 use lib "$Bin/lib";
    9 use MemcachedTest;
   10 
   11 my $server = new_memcached();
   12 
   13 my $stat_sock = $server->sock;
   14 my @sockets = ();
   15 my $num_sockets;
   16 my $rejected_conns = 0;
   17 my $stats;
   18 for (1 .. 1024) {
   19   my $sock = $server->new_sock;
   20   if (defined($sock)) {
   21     push(@sockets, $sock);
   22     $stats = mem_stats($stat_sock);
   23     if ($stats->{rejected_connections} > $rejected_conns) {
   24       $rejected_conns = $stats->{rejected_connections};
   25       my $buffer = "";
   26       my $length = 31;
   27       my $res = recv($sock, $buffer, $length, 0);
   28       if (not $buffer eq '') {
   29           is($buffer, "ERROR Too many open connections", "Got expected response from the server");
   30       }
   31     }
   32   }
   33 }
   34 
   35 for my $s (@sockets) {
   36     $s->close();
   37 }
   38 cmp_ok($stats->{rejected_connections}, '>', '1', 'rejected connections recorded');
   39 $server->stop;
   40 $stat_sock->close();
   41 done_testing();