mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
test: return immediately on connect
if the connection is successfull then return immediately instead of doing all the iterations. It also solves a problem where connections are leaked since there are multiple Dial but only one Close. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -1081,15 +1081,17 @@ func WaitForFile(path string) (err error) {
|
||||
// WaitForService blocks, waiting for some service listening on given host:port
|
||||
func WaitForService(address url.URL) {
|
||||
// Wait for podman to be ready
|
||||
var conn net.Conn
|
||||
var err error
|
||||
for i := 1; i <= 5; i++ {
|
||||
var conn net.Conn
|
||||
conn, err = net.Dial("tcp", address.Host)
|
||||
if err != nil {
|
||||
// Podman not available yet...
|
||||
time.Sleep(time.Duration(i) * time.Second)
|
||||
if err == nil {
|
||||
conn.Close()
|
||||
break
|
||||
}
|
||||
|
||||
// Podman not available yet...
|
||||
time.Sleep(time.Duration(i) * time.Second)
|
||||
}
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
conn.Close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user