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: chendianqiang <chendianqiang@meituan.com> Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
parent
79ac57561f
commit
a527c3e814
@ -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 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 {
|
||||
close $fd1
|
||||
close $fd2
|
||||
set ::last_port_attempted $port
|
||||
return $port
|
||||
} else {
|
||||
catch {
|
||||
close $fd1
|
||||
close $fd2
|
||||
}
|
||||
}
|
||||
incr port
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user