Unverified Commit a527c3e8 authored by chendianqiang's avatar chendianqiang Committed by GitHub
Browse files

Test suite - user server socket to optimize port detection (#9663)



Optimized port detection for tcl, use 'socket -server' instead of 'socket' to rule out port on TIME_WAIT
Co-authored-by: default avatarchendianqiang <chendianqiang@meituan.com>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
parent 79ac5756
......@@ -443,15 +443,17 @@ proc find_available_port {start count} {
if {$port < $start || $port >= $start+$count} {
set port $start
}
if {[catch {set fd1 [socket 127.0.0.1 $port]}] &&
[catch {set fd2 [socket 127.0.0.1 [expr $port+10000]]}]} {
set ::last_port_attempted $port
return $port
set fd1 -1
if {[catch {set fd1 [socket -server 127.0.0.1 $port]}] ||
[catch {set fd2 [socket -server 127.0.0.1 [expr $port+10000]]}]} {
if {$fd1 != -1} {
close $fd1
}
} else {
catch {
close $fd1
close $fd2
}
set ::last_port_attempted $port
return $port
}
incr port
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment