Ignore:
Timestamp:
2013-03-05T10:34:45+13:00 (11 years ago)
Author:
jmt12
Message:

Changed client to retry connections every second, but also to timeout after five minutes of failing to connect (according to RFC793 there may be a waiting time of up to four minutes for TIME_WAIT sockets to be reaped... so after five minutes it shouldn't be an exhausted socket pool causing the issue)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/perllib/SocketsSwimmingThreadPoolClient.pm

    r25415 r26993  
    1010use warnings;
    1111
    12 my $retry_time = 5;
     12my $retry_limit = 300; # five minute
     13my $retry_time = 1;
    1314
    1415sub new
     
    5051  # (according to RFC793) we may be waiting up to 4 minutes for TIME_WAITs to
    5152  # be reaped. Sigh. Still - ever an optimist - I'll retry the socket
    52   # connection every 30 seconds.
     53  # connection every seconds.
    5354  # References:
    5455  #   http://www.perlmonks.org/?node_id=771242
     
    5758  #   http://www.isi.edu/touch/pubs/infocomm99/infocomm99-web/
    5859  #   http://www.faqs.org/rfcs/rfc793.html
    59   while(1)
     60  while($retry_limit > 0)
    6061  {
    6162    my $socket= new IO::Socket::INET(PeerAddr => $self->{host} || 'localhost',
     
    7071    print "=> Retry in " . $retry_time . " seconds.\n";
    7172    sleep($retry_time);
     73    $retry_limit--;
    7274  }
     75  print "Error! Failed to create client socket within 5 minutes timeout.\n";
    7376}
    7477
Note: See TracChangeset for help on using the changeset viewer.