diff options
author | sebres <sebres@users.sourceforge.net> | 2017-05-03 10:15:02 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-05-03 10:15:02 (GMT) |
commit | 66636d4eabc4612abf1d902e53767e37cfcc7744 (patch) | |
tree | 1d001392cb6b0296c146fe6131082ea2fb2176ee /tests | |
parent | c0108dceb13e2079a9a4b662d98fa27a8c5d13c0 (diff) | |
parent | 69d1bdb95ef90f112d06b7ece0d6db57c504a030 (diff) | |
download | tcl-66636d4eabc4612abf1d902e53767e37cfcc7744.zip tcl-66636d4eabc4612abf1d902e53767e37cfcc7744.tar.gz tcl-66636d4eabc4612abf1d902e53767e37cfcc7744.tar.bz2 |
back-porting of branch "fix-1997007" to "core-8-5-branch": Closing tcl pipes prevents windows threads from starting up.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/socket.test | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/socket.test b/tests/socket.test index b390627..68949b7 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -69,7 +69,22 @@ testConstraint exec [llength [info commands exec]] # Produce a random port number in the Dynamic/Private range # from 49152 through 65535. -proc randport {} { expr {int(rand()*16383+49152)} } +proc randport {} { + # firstly try dynamic port via server-socket(0): + set port 0x7fffffff + catch { + set port [lindex [fconfigure [set s [socket -server {} 0]] -sockname] 2] + close $s + } + while {[catch { + close [socket -server {} $port] + } msg]} { + if {[incr i] > 1000} {return -code error "too many iterations to get free random port: $msg"} + # try random port: + set port [expr {int(rand()*16383+49152)}] + } + return $port +} # If remoteServerIP or remoteServerPort are not set, check in the # environment variables for externally set values. |