Fix a socket leak in HTTPInput.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 13 Apr 2013 19:50:13 +0000 (21:50 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 13 Apr 2013 19:50:13 +0000 (21:50 +0200)
httpinput.cpp

index 9d39774..291b17f 100644 (file)
@@ -114,6 +114,15 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        return sock;
                }
 
+               do {
+                       err = close(sock);
+               } while (err == -1 && errno == EINTR);
+
+               if (err == -1) {
+                       perror("close");
+                       // Can still continue.
+               }
+
                ai = ai->ai_next;
        }