X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=730bb4463c7433c7734a49d19a9e5ea9d08331fd;hp=949d6a4d6958eff742c6c75783ed18f48d7f49c2;hb=bb0f713d1bc0b41d6a22e9990816ab4d11e642ed;hpb=1071b76d8e60d51d88d4e1310e7d6261b628a454 diff --git a/server.cpp b/server.cpp index 949d6a4..730bb44 100644 --- a/server.cpp +++ b/server.cpp @@ -153,7 +153,13 @@ void Server::add_client(int sock) void Server::add_client_from_serialized(const ClientProto &client) { MutexLock lock(&mutex); - Stream *stream = find_stream(client.stream_id()); + Stream *stream; + map::iterator stream_it = streams.find(client.stream_id()); + if (stream_it == streams.end()) { + stream = NULL; + } else { + stream = stream_it->second; + } clients.insert(make_pair(client.sock(), Client(client, stream))); Client *client_ptr = &clients[client.sock()]; @@ -357,6 +363,8 @@ sending_data_again: client->sock, (long long int)(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->num_loss_events; bytes_to_send = stream->backlog_size; } @@ -386,6 +394,7 @@ sending_data_again: return; } client->stream_pos += ret; + client->bytes_sent += ret; if (client->stream_pos == stream->bytes_received) { // We don't have any more data for this client, so put it to sleep.