]> git.sesse.net Git - cubemap/blobdiff - input_stats.cpp
Create $(libdir) on make install.
[cubemap] / input_stats.cpp
index f909113b9024a2642a7acbb5064b6bf34d9bdb92..5b7dc59ae762696f2eca6e9ad12fc4e54fc6272b 100644 (file)
@@ -31,7 +31,7 @@ void InputStatsThread::do_work()
 
                // Open a new, temporary file.
                char *filename = strdup((stats_file + ".new.XXXXXX").c_str());
-               fd = mkostemp(filename, O_WRONLY);
+               fd = mkostemp(filename, O_WRONLY | O_CLOEXEC);
                if (fd == -1) {
                        log_perror(filename);
                        free(filename);
@@ -52,7 +52,14 @@ void InputStatsThread::do_work()
                now = time(nullptr);
                for (size_t i = 0; i < inputs.size(); ++i) {
                        InputStats stats = inputs[i]->get_stats();
-                       fprintf(fp, "%s %llu %llu", stats.url.c_str(),
+                       for (const char ch : stats.url) {
+                               if (isspace(ch) || !isprint(ch)) {
+                                       putc('_', fp);
+                               } else {
+                                       putc(ch, fp);
+                               }
+                       }
+                       fprintf(fp, " %llu %llu",
                                (long long unsigned)(stats.bytes_received),
                                (long long unsigned)(stats.data_bytes_received));
                        if (stats.connect_time == -1) {