From 3bd31c400d7cb546c5583fbee8d998e232eef5c2 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 1 Jan 2021 12:09:37 +0000 Subject: [PATCH] Avoid needless socket close --- src/src/ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/src/ip.c b/src/src/ip.c index c09962a38..96a6c29f2 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -463,8 +463,8 @@ for (host_item * h = &shost; h; h = h->next) for (int port = portlo; port <= porthi; port++) if (ip_connect(fd, af, h->address, port, timeout, fastopen_blob) == 0) { - if (fd != fd6) close(fd6); - if (fd != fd4) close(fd4); + if (fd6 >= 0 && fd != fd6) close(fd6); + if (fd4 >= 0 && fd != fd4) close(fd4); if (connhost) { h->port = port; -- 2.30.2