X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=client.cpp;h=5d5c179be0e6df019930fb2924cf22be2e7bcab1;hp=05b8e7d88fcd0b622e2386e84b83abedf0687a24;hb=7c23f706733b12405c0cb8793866b57ba5800c98;hpb=061988af511f42da3cd584b4d983177504ddc177 diff --git a/client.cpp b/client.cpp index 05b8e7d..5d5c179 100644 --- a/client.cpp +++ b/client.cpp @@ -1,8 +1,10 @@ #include #include +#include #include #include #include +#include #include "client.h" #include "log.h" @@ -20,11 +22,6 @@ Client::Client(int sock) { request.reserve(1024); - if (clock_gettime(CLOCK_MONOTONIC_COARSE, &connect_time) == -1) { - log_perror("clock_gettime(CLOCK_MONOTONIC_COARSE)"); - return; - } - // Find the remote address, and convert it to ASCII. sockaddr_in6 addr; socklen_t addr_len = sizeof(addr); @@ -59,10 +56,13 @@ Client::Client(const ClientProto &serialized, const vectorpacing_rate, sizeof(stream->pacing_rate)) == -1) { if (stream->pacing_rate != ~0U) { @@ -117,11 +121,16 @@ Client::Client(const ClientProto &serialized, const vector *short_response_pool) const { + // Unset the close-on-exec flag for the socket. + // (This can't leak into a child, since there's only one thread left.) + fcntl(sock, F_SETFD, 0); + ClientProto serialized; serialized.set_sock(sock); serialized.set_remote_addr(remote_addr); serialized.set_referer(referer); serialized.set_user_agent(user_agent); + serialized.set_x_playback_session_id(x_playback_session_id); serialized.set_connect_time_sec(connect_time.tv_sec); serialized.set_connect_time_nsec(connect_time.tv_nsec); serialized.set_state(state); @@ -135,12 +144,14 @@ ClientProto Client::serialize(unordered_map *short_respo serialized.set_header_or_short_response_index(iterator_and_inserted.first->second); } - serialized.set_header_or_short_response_bytes_sent(serialized.header_or_short_response_bytes_sent()); + serialized.set_header_or_short_response_bytes_sent(header_or_short_response_bytes_sent); serialized.set_stream_pos(stream_pos); serialized.set_stream_pos_end(stream_pos_end); serialized.set_bytes_sent(bytes_sent); serialized.set_bytes_lost(bytes_lost); serialized.set_num_loss_events(num_loss_events); + serialized.set_http_11(http_11); + serialized.set_close_after_response(close_after_response); if (tls_context != nullptr) { bool small_version = false; @@ -218,5 +229,6 @@ ClientStats Client::get_stats() const stats.bytes_sent = bytes_sent; stats.bytes_lost = bytes_lost; stats.num_loss_events = num_loss_events; + stats.hls_zombie_key = get_hls_zombie_key(); return stats; }