set-socket-timeouts-for-ipserv.patch 1001 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Patch by Maciej S. Szmigiero to prevent ipserv from hanging when the
  2. other end of the connection goes AWOL.
  3. Gentoo-Bug: 602216
  4. --- a/scripts/ipserv.pl.in 2005-03-06 22:21:36.000000000 +0100
  5. +++ b/scripts/ipserv.pl.in 2017-01-14 19:39:25.583277538 +0100
  6. @@ -20,6 +20,7 @@
  7. use strict;
  8. use IO::Socket;
  9. +use IO::Socket::Timeout qw(IO::Socket::INET);
  10. my $ipv4_rex = qr/(?:\d{1,3}\.){3}\d{1,3}/imosx;
  11. @@ -128,7 +129,8 @@
  12. $socket = IO::Socket::INET->new(PeerAddr => $target->{url},
  13. PeerPort => $target->{port},
  14. Proto => "tcp",
  15. - Type => SOCK_STREAM)
  16. + Type => SOCK_STREAM,
  17. + Timeout => 2 * 60)
  18. or $retries--;
  19. } while(!defined($socket) && $retries != 0);
  20. @@ -137,6 +139,10 @@
  21. die "could not connect to $target->{url}: $!";
  22. }
  23. + IO::Socket::Timeout->enable_timeouts_on($socket);
  24. + $socket->read_timeout(2 * 60);
  25. + $socket->write_timeout(2 * 60);
  26. +
  27. if(defined($target->{request})) {
  28. print($socket $target->{request});
  29. }