changeset 973:7d7aef8b9f3a

Tests: revert 313e3f1905d4 and set reuse properly. It is too late to use setsockopt(SO_REUSEADDR) after a socket is created as bind() happens during socket construction, and fails if there is a conflicting TIME-WAIT socket and SO_REUSEADDR is not set.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 10 Jul 2016 18:57:12 +0300
parents 313e3f1905d4
children 882267679006
files lib/Test/Nginx.pm
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -330,13 +330,12 @@ sub port {
 			Proto => 'tcp',
 			LocalAddr => '127.0.0.1:' . $port,
 			Listen => 1,
+			Reuse => ($^O ne 'MSWin32')
 		) and last;
 	}
 
 	die "Port limit exceeded" unless defined $s_tcp and defined $s_udp;
 
-	$s_tcp->sockopt(SO_REUSEADDR, 1) if $^O ne 'MSWin32';
-
 	$ports{$num} = {
 		port => $port,
 		socket => $opts{udp} ? $s_tcp : $s_udp