]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
Fix a socket leak in HTTPInput.
[cubemap] / httpinput.cpp
index 354e4b9885aa0d9be0622c4f85d1ec23e67be5d4..291b17f089578fe54b2a4ac33be06bfafc1742f4 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <unistd.h>
 #include <assert.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
@@ -113,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;
        }