X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input_stats.cpp;h=e3e89e635d24b392c23d1ac3b02e3564878aad44;hp=1edfbde52379b062407dfd8e31804e51733ef64a;hb=74cd48ffef90d7d0752e37a4515e4ecfb68f7c9d;hpb=d4bc12548cd825607e257cbe01f3136ed524cb10 diff --git a/input_stats.cpp b/input_stats.cpp index 1edfbde..e3e89e6 100644 --- a/input_stats.cpp +++ b/input_stats.cpp @@ -27,6 +27,7 @@ void InputStatsThread::do_work() while (!should_stop()) { int fd; FILE *fp; + time_t now; // Open a new, temporary file. char *filename = strdup((stats_file + ".new.XXXXXX").c_str()); @@ -48,11 +49,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");