X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=httpinput.cpp;h=1e607d4efc50ebbb9ed3936f4990e6b07d14c30c;hp=012f5bc0c4f15d2a4da0f425034a7c82a50ff763;hb=e4637f55fbd4671089b6700fdd17c3110587436f;hpb=742f56c25bdd54dc438b21cb5e422de520bc7231 diff --git a/httpinput.cpp b/httpinput.cpp index 012f5bc..1e607d4 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -1,30 +1,26 @@ +#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include -#include #include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include -#include "metacube.h" -#include "mutexlock.h" #include "httpinput.h" -#include "server.h" -#include "serverpool.h" +#include "metacube.h" #include "parse.h" -#include "version.h" +#include "serverpool.h" #include "state.pb.h" +#include "version.h" using namespace std; @@ -57,6 +53,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 +109,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 +232,8 @@ void HTTPInput::do_work() request.clear(); request_bytes_sent = 0; response.clear(); + pending_data.clear(); + servers->set_header(stream_id, ""); { string protocol; // Thrown away.