X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=94350faae3ff182d93e232ea6d34bffc50f54080;hp=855e21c9767587fba2590fccadb47cdb5de852c5;hb=f3ed48479f9209e708cd17698dc9e778e07284cd;hpb=a0ad2d9d955fcb5f0aa3cf4f89999c34e8408124 diff --git a/server.cpp b/server.cpp index 855e21c..94350fa 100644 --- a/server.cpp +++ b/server.cpp @@ -231,6 +231,8 @@ void Server::add_client_from_serialized(const ClientProto &client) perror("epoll_ctl(EPOLL_CTL_ADD)"); exit(1); } + + process_client(&clients[client.sock()]); } void Server::add_stream(const string &stream_id) @@ -402,7 +404,7 @@ sending_header_or_error_again: // This is postcondition #3. client->state = Client::SENDING_DATA; client->bytes_sent = client->stream->data_size; - sleeping_clients.push_back(client); + put_client_to_sleep(client); return; } case Client::SENDING_DATA: { @@ -410,6 +412,9 @@ sending_header_or_error_again: // but resync will be the mux's problem. const Stream *stream = client->stream; size_t bytes_to_send = stream->data_size - client->bytes_sent; + if (bytes_to_send == 0) { + return; + } if (bytes_to_send > BACKLOG_SIZE) { fprintf(stderr, "WARNING: fd %d lost %lld bytes, maybe too slow connection\n", client->sock, @@ -488,7 +493,7 @@ int Server::parse_request(Client *client) } client->stream_id = request_tokens[1]; - client->stream = streams[client->stream_id]; + client->stream = find_stream(client->stream_id); client->request.clear(); return 200; // OK!