From 9e0882ba98feff82f4ffa1f8701cdc139bbcd0f1 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 25 Oct 2005 13:15:11 +0000
Subject: [PATCH] close the existing socket when trying next IP, as otherwise
 we leak one! bug #1326306

---
 lib/connect.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/connect.c b/lib/connect.c
index 23c192c7db..18c40f9acf 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -472,6 +472,9 @@ static bool trynextip(struct connectdata *conn,
   if(sockindex != FIRSTSOCKET)
     return TRUE; /* no next */
 
+  /* first close the failed socket */
+  sclose(conn->sock[sockindex]);
+
   /* try the next address */
   ai = conn->ip_addr->ai_next;
 
-- 
GitLab