From 54157bc49ebf7b49a1d2a95c7b09b4e3ce56e2a6 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 30 Jun 2014 12:07:26 +0200 Subject: [PATCH] Test: find_available_port: check that cluster port is free as well. The function will only return ports that have also port+10000 free, so that Redis Cluster instances can be executed at the returned port. --- tests/support/util.tcl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/support/util.tcl b/tests/support/util.tcl index e49ea229..8ef6e1bc 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -315,12 +315,14 @@ proc roundFloat f { proc find_available_port start { for {set j $start} {$j < $start+1024} {incr j} { - if {[catch { - set fd [socket 127.0.0.1 $j] - }]} { + if {[catch {set fd1 [socket 127.0.0.1 $j]}] && + [catch {set fd2 [socket 127.0.0.1 [expr $j+10000]]}]} { return $j } else { - close $fd + catch { + close $fd1 + close $fd2 + } } } if {$j == $start+1024} {