From 37e73170552135663151b0d4c671729ac276cd5c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 7 Apr 2013 23:20:16 +0200 Subject: [PATCH] Fix an error where clients in asleep state would hang after a HUP. --- server.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) -- 2.39.2