X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpinput.cpp;h=2fe68061b44c89e7b8a2811df8c5aff3369cb3bd;hb=2a2689e25c5906f66c5154803aae1d705dbf33af;hp=1bd14dee87c7d022de1bea1d128059f43428aa8c;hpb=d4bc12548cd825607e257cbe01f3136ed524cb10;p=cubemap diff --git a/httpinput.cpp b/httpinput.cpp index 1bd14de..2fe6806 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -39,6 +39,7 @@ HTTPInput::HTTPInput(const string &url) stats.url = url; stats.bytes_received = 0; stats.data_bytes_received = 0; + stats.connect_time = -1; } HTTPInput::HTTPInput(const InputProto &serialized) @@ -68,6 +69,11 @@ HTTPInput::HTTPInput(const InputProto &serialized) stats.url = url; stats.bytes_received = serialized.bytes_received(); stats.data_bytes_received = serialized.data_bytes_received(); + if (serialized.has_connect_time()) { + stats.connect_time = serialized.connect_time(); + } else { + stats.connect_time = time(NULL); + } } void HTTPInput::close_socket() @@ -75,6 +81,9 @@ void HTTPInput::close_socket() if (sock != -1) { safe_close(sock); } + + MutexLock lock(&stats_mutex); + stats.connect_time = -1; } InputProto HTTPInput::serialize() const @@ -91,6 +100,7 @@ InputProto HTTPInput::serialize() const serialized.set_sock(sock); serialized.set_bytes_received(stats.bytes_received); serialized.set_data_bytes_received(stats.data_bytes_received); + serialized.set_connect_time(stats.connect_time); return serialized; } @@ -301,6 +311,9 @@ void HTTPInput::do_work() request = "GET " + path + " HTTP/1.0\r\nUser-Agent: cubemap\r\n\r\n"; request_bytes_sent = 0; } + + MutexLock lock(&stats_mutex); + stats.connect_time = time(NULL); } break; case SENDING_REQUEST: { @@ -526,6 +539,12 @@ void HTTPInput::drop_pending_data(size_t num_bytes) pending_data.erase(pending_data.begin(), pending_data.begin() + num_bytes); } +void HTTPInput::add_destination(int stream_index) +{ + stream_indices.push_back(stream_index); + servers->set_header(stream_index, http_header, ""); +} + InputStats HTTPInput::get_stats() const { MutexLock lock(&stats_mutex);