X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpinput.cpp;h=291b17f089578fe54b2a4ac33be06bfafc1742f4;hb=51e357cb8decceaeab47332492962bc0175b0b13;hp=012f5bc0c4f15d2a4da0f425034a7c82a50ff763;hpb=742f56c25bdd54dc438b21cb5e422de520bc7231;p=cubemap diff --git a/httpinput.cpp b/httpinput.cpp index 012f5bc..291b17f 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,18 @@ HTTPInput::HTTPInput(const InputProto &serialized) parse_url(url, &protocol, &host, &port, &path); // Don't care if it fails. } +void HTTPInput::close_socket() +{ + int ret; + do { + ret = close(sock); + } while (ret == -1 && errno == EINTR); + + if (ret == -1) { + perror("close()"); + } +} + InputProto HTTPInput::serialize() const { InputProto serialized; @@ -101,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; } @@ -215,6 +237,7 @@ void HTTPInput::do_work() request.clear(); request_bytes_sent = 0; response.clear(); + pending_data.clear(); { string protocol; // Thrown away.