+// See if there's some data we've lost. Ideally, we should drop to a block boundary,
+// but resync will be the mux's problem.
+void Server::skip_lost_data(Client *client)
+{
+ Stream *stream = client->stream;
+ size_t bytes_to_send = stream->bytes_received - client->stream_pos;
+ if (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_lost;
+ ++client->num_loss_events;
+
+ 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);
+ }
+}
+