X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=6dcddf0b4431e983909e012cb863636f6ccab635;hp=f5c117b6dcbad54ac13ac30e89e861f8c5943130;hb=771355dc2b3ac9d076482148a03591debb97f62e;hpb=f3e2d52ccf79454ee157917f9017263a8f4c50c3 diff --git a/server.cpp b/server.cpp index f5c117b..6dcddf0 100644 --- a/server.cpp +++ b/server.cpp @@ -21,6 +21,14 @@ using namespace std; +Client::Client(int sock) + : state(Client::READING_REQUEST), + header_bytes_sent(0), + bytes_sent(0) +{ + request.reserve(1024); +} + Server::Server() { pthread_mutex_init(&mutex, NULL); @@ -96,14 +104,7 @@ void Server::do_work() void Server::add_client(int sock) { MutexLock lock(&mutex); - Client new_client; - new_client.sock = sock; - new_client.request.reserve(1024); - new_client.state = Client::READING_REQUEST; - new_client.header_bytes_sent = 0; - new_client.bytes_sent = 0; - - clients.insert(make_pair(sock, new_client)); + clients.insert(make_pair(sock, Client(sock))); // Start listening on data from this socket. epoll_event ev;