]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
Create $(libdir) on make install.
[cubemap] / httpinput.cpp
index 62ed663611402cef5d4517cef00d8033300391bc..b2b620706ad368983e37aafd8ae1e1f101e784f6 100644 (file)
@@ -80,7 +80,9 @@ HTTPInput::HTTPInput(const InputProto &serialized)
 {
        // Set back the close-on-exec flag for the socket.
        // (This can't leak into a child, since we haven't been started yet.)
-       fcntl(sock, F_SETFD, O_CLOEXEC);
+       if (sock != -1) {
+               fcntl(sock, F_SETFD, FD_CLOEXEC);
+       }
 
        pending_data.resize(serialized.pending_data().size());
        memcpy(&pending_data[0], serialized.pending_data().data(), serialized.pending_data().size());
@@ -167,6 +169,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        log(WARNING, "[%s] Lookup of '%s' failed (%s).",
                                url.c_str(), host.c_str(), gai_strerror(err));
                }
+               freeaddrinfo(ai);
                return -1;
        }
 
@@ -198,6 +201,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        bool complete = wait_for_activity(sock, POLLIN | POLLOUT, nullptr);
                        if (should_stop()) {
                                safe_close(sock);
+                               freeaddrinfo(base_ai);
                                return -1;
                        }
                        if (complete) {