]> git.sesse.net Git - cubemap/commitdiff
Remove unneeded default Client constructor.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Apr 2013 19:08:08 +0000 (21:08 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Apr 2013 19:08:08 +0000 (21:08 +0200)
client.h
server.cpp

index d511698550f2d4d5af9234f2eb0671600a72da4e..9a189c0a9af709365944d11e6db37f75868161f0 100644 (file)
--- a/client.h
+++ b/client.h
@@ -23,7 +23,6 @@ struct ClientStats {
 };
 
 struct Client {
 };
 
 struct Client {
-       Client() {}
        Client(int sock);
 
        // Serialization/deserialization.
        Client(int sock);
 
        // Serialization/deserialization.
index a000d9c6d08f0f3d799c07f3bfec1902f68fc141..b5f58d4c56711968db64a8d6c63e7d9eb08d0e25 100644 (file)
@@ -147,18 +147,21 @@ void Server::add_client_deferred(int sock)
 
 void Server::add_client(int sock)
 {
 
 void Server::add_client(int sock)
 {
-       clients.insert(make_pair(sock, Client(sock)));
+       pair<map<int, Client>::iterator, bool> ret =
+               clients.insert(make_pair(sock, Client(sock)));
+       assert(ret.second == true);  // Should not already exist.
+       Client *client_ptr = &ret.first->second;
 
        // Start listening on data from this socket.
        epoll_event ev;
        ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP;
 
        // Start listening on data from this socket.
        epoll_event ev;
        ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP;
-       ev.data.u64 = reinterpret_cast<uint64_t>(&clients[sock]);
+       ev.data.u64 = reinterpret_cast<uint64_t>(client_ptr);
        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) == -1) {
                log_perror("epoll_ctl(EPOLL_CTL_ADD)");
                exit(1);
        }
 
        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) == -1) {
                log_perror("epoll_ctl(EPOLL_CTL_ADD)");
                exit(1);
        }
 
-       process_client(&clients[sock]);
+       process_client(client_ptr);
 }
 
 void Server::add_client_from_serialized(const ClientProto &client)
 }
 
 void Server::add_client_from_serialized(const ClientProto &client)
@@ -171,8 +174,10 @@ void Server::add_client_from_serialized(const ClientProto &client)
        } else {
                stream = stream_it->second;
        }
        } else {
                stream = stream_it->second;
        }
-       clients.insert(make_pair(client.sock(), Client(client, stream)));
-       Client *client_ptr = &clients[client.sock()];
+       pair<map<int, Client>::iterator, bool> ret =
+               clients.insert(make_pair(client.sock(), Client(client, stream)));
+       assert(ret.second == true);  // Should not already exist.
+       Client *client_ptr = &ret.first->second;
 
        // Start listening on data from this socket.
        epoll_event ev;
 
        // Start listening on data from this socket.
        epoll_event ev;