From: Steinar H. Gunderson Date: Sun, 7 Apr 2013 21:20:16 +0000 (+0200) Subject: Fix an error where clients in asleep state would hang after a HUP. X-Git-Tag: 1.0.0~178 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=37e73170552135663151b0d4c671729ac276cd5c;hp=a54668ae3e87aade61b856ff6f088da471200bc6 Fix an error where clients in asleep state would hang after a HUP. --- diff --git a/server.cpp b/server.cpp index 7cdfd17..eeab64b 100644 --- a/server.cpp +++ b/server.cpp @@ -217,6 +217,7 @@ void Server::add_client_from_serialized(const ClientProto &client) MutexLock lock(&mutex); Stream *stream = find_stream(client.stream_id()); clients.insert(make_pair(client.sock(), Client(client, stream))); + Client *client_ptr = &clients[client.sock()]; // Start listening on data from this socket. epoll_event ev; @@ -234,7 +235,12 @@ void Server::add_client_from_serialized(const ClientProto &client) exit(1); } - process_client(&clients[client.sock()]); + if (client_ptr->state == Client::SENDING_DATA && + client_ptr->bytes_sent == client_ptr->stream->data_size) { + put_client_to_sleep(client_ptr); + } else { + process_client(client_ptr); + } } void Server::add_stream(const string &stream_id)