]> git.sesse.net Git - cubemap/commitdiff
Fix an error where clients in asleep state would hang after a HUP.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 Apr 2013 21:20:16 +0000 (23:20 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 Apr 2013 21:20:16 +0000 (23:20 +0200)
server.cpp

index 7cdfd1736f4f1aa98827c7674026d8eacddfd9f8..eeab64bb64fbf7bb790d89b14150e4eb97f42251 100644 (file)
@@ -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)));
        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;
 
        // 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);
        }
 
                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)
 }
 
 void Server::add_stream(const string &stream_id)