Commit 5b446313 authored by Oran Agra's avatar Oran Agra
Browse files

testsuite: fix fd leak, prevent port clashing when using --baseport

when using --baseport to run two tests suite in parallel (different
folders), we need to also make sure the port used by the testsuite to
communicate with it's workers is unique. otherwise the attept to find a
free port connects to the other test suite and messes it.

maybe one day we need to attempt to bind, instead of connect when tring
to find a free port.
parent c31055db
...@@ -109,6 +109,7 @@ proc ::redis::__dispatch__raw__ {id method argv} { ...@@ -109,6 +109,7 @@ proc ::redis::__dispatch__raw__ {id method argv} {
} }
::redis::redis_write $fd $cmd ::redis::redis_write $fd $cmd
if {[catch {flush $fd}]} { if {[catch {flush $fd}]} {
catch {close $fd}
set ::redis::fd($id) {} set ::redis::fd($id) {}
return -code error "I/O error reading reply" return -code error "I/O error reading reply"
} }
...@@ -251,6 +252,7 @@ proc ::redis::redis_read_reply {id fd} { ...@@ -251,6 +252,7 @@ proc ::redis::redis_read_reply {id fd} {
% {redis_read_map $id $fd} % {redis_read_map $id $fd}
default { default {
if {$type eq {}} { if {$type eq {}} {
catch {close $fd}
set ::redis::fd($id) {} set ::redis::fd($id) {}
return -code error "I/O error reading reply" return -code error "I/O error reading reply"
} }
......
...@@ -180,6 +180,10 @@ proc reconnect {args} { ...@@ -180,6 +180,10 @@ proc reconnect {args} {
set port [dict get $srv "port"] set port [dict get $srv "port"]
set config [dict get $srv "config"] set config [dict get $srv "config"]
set client [redis $host $port 0 $::tls] set client [redis $host $port 0 $::tls]
if {[dict exists $srv "client"]} {
set old [dict get $srv "client"]
$old close
}
dict set srv "client" $client dict set srv "client" $client
# select the right db when we don't have to authenticate # select the right db when we don't have to authenticate
...@@ -257,7 +261,7 @@ proc test_server_main {} { ...@@ -257,7 +261,7 @@ proc test_server_main {} {
set tclsh [info nameofexecutable] set tclsh [info nameofexecutable]
# Open a listening socket, trying different ports in order to find a # Open a listening socket, trying different ports in order to find a
# non busy one. # non busy one.
set clientport [find_available_port 11111 32] set clientport [find_available_port [expr {$::baseport - 32}] 32]
if {!$::quiet} { if {!$::quiet} {
puts "Starting test server at port $clientport" puts "Starting test server at port $clientport"
} }
......
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