Close new connections that fail for e.g. ban reason.
[umurmur.git] / src / server.c
index d41aab10e231bb64133ec15b6399c7f34ebac924..77e59aa3dff6b6139a0b198c59516a9147224740 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (C) 2009-2010, Martin Johansson <martin@fatbob.nu>
-   Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-2011, Martin Johansson <martin@fatbob.nu>
+   Copyright (C) 2005-2011, Thorvald Natvig <thorvald@natvig.com>
 
    All rights reserved.
 
@@ -173,7 +173,8 @@ void Server_run()
                        setsockopt(tcpfd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
                        Log_debug("Connection from %s port %d\n", inet_ntoa(remote.sin_addr),
                                          ntohs(remote.sin_port));
-                       Client_add(tcpfd, &remote);
+                       if (Client_add(tcpfd, &remote) < 0)
+                               close(tcpfd);
                }
 
                if (pollfds[UDP_SOCK].revents) {