X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input_stats.cpp;h=92a6718c4cc8cc987b1753fc5b90123a08ff7131;hp=ce3841469c3ee0f92dcd06c9951cd611e75d0629;hb=6544fa0ec3f3a501bcb89ea977756911bd7f3ebd;hpb=bd694fdd3dd1417399aecead2c8b91fc4fe95ce8 diff --git a/input_stats.cpp b/input_stats.cpp index ce38414..92a6718 100644 --- a/input_stats.cpp +++ b/input_stats.cpp @@ -7,10 +7,9 @@ #include #include -#include "client.h" -#include "log.h" #include "input.h" #include "input_stats.h" +#include "log.h" #include "util.h" using namespace std; @@ -27,7 +26,7 @@ void InputStatsThread::do_work() while (!should_stop()) { int fd; FILE *fp; - vector client_stats; + time_t now; // Open a new, temporary file. char *filename = strdup((stats_file + ".new.XXXXXX").c_str()); @@ -49,11 +48,19 @@ void InputStatsThread::do_work() goto sleep; } + now = time(NULL); for (size_t i = 0; i < inputs.size(); ++i) { InputStats stats = inputs[i]->get_stats(); - fprintf(fp, "%s %llu %llu\n", stats.url.c_str(), - (long long unsigned)(stats.bytes_received), - (long long unsigned)(stats.data_bytes_received)); + if (stats.connect_time == -1) { + fprintf(fp, "%s %llu %llu -\n", stats.url.c_str(), + (long long unsigned)(stats.bytes_received), + (long long unsigned)(stats.data_bytes_received)); + } else { + fprintf(fp, "%s %llu %llu %d\n", stats.url.c_str(), + (long long unsigned)(stats.bytes_received), + (long long unsigned)(stats.data_bytes_received), + int(now - stats.connect_time)); + } } if (fclose(fp) == EOF) { log_perror("fclose");