When logging losses, log loss percentage, too.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 18 Apr 2013 23:33:33 +0000 (01:33 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 18 Apr 2013 23:33:33 +0000 (01:33 +0200)
server.cpp

index 640f10a..74a20c8 100644 (file)
@@ -376,13 +376,17 @@ sending_data_again:
                        return;
                }
                if (bytes_to_send > stream->backlog_size) {
-                       log(WARNING, "[%s] Client lost %lld bytes, maybe too slow connection",
-                               client->remote_addr.c_str(),
-                               (long long int)(bytes_to_send - stream->backlog_size));
+                       size_t bytes_lost = bytes_to_send - stream->backlog_size;
                        client->stream_pos = stream->bytes_received - stream->backlog_size;
-                       client->bytes_lost += bytes_to_send - stream->backlog_size;
+                       client->bytes_lost += bytes_lost;
                        ++client->num_loss_events;
                        bytes_to_send = stream->backlog_size;
+
+                       double loss_fraction = double(client->bytes_lost) / double(client->bytes_lost + client->bytes_sent);
+                       log(WARNING, "[%s] Client lost %lld bytes (total loss: %.2f%%), maybe too slow connection",
+                               client->remote_addr.c_str(),
+                               (long long int)(bytes_lost),
+                               100.0 * loss_fraction);
                }
 
                // See if we need to split across the circular buffer.