X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocket.cpp;h=bd8147b3fa08e2ebc74fdf4b2be751b036cbaaae;hb=af7e1a1ca8b36064593becf62b1a91468ad32237;hp=2aa2c73b0b1259053ac4c57b6479b355f81f262d;hpb=e4acbc95b8b6cd5b28d38a2242c02e8ff4991e4a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socket.cpp b/src/socket.cpp index 2aa2c73b0..bd8147b3f 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -65,13 +65,24 @@ ListenSocket::~ListenSocket() } } + +// XXX this is a bit of an untidy way to avoid reallocating this constantly. also, we leak it on shutdown.. but that's kinda minor - w +static sockaddr *sock_us; +static sockaddr *client; +static bool setup_sock = false; + void ListenSocket::HandleEvent(EventType, int) { - sockaddr* sock_us = new sockaddr[2]; // our port number - sockaddr* client = new sockaddr[2]; socklen_t uslen, length; // length of our port number int incomingSockfd, in_port; + if (!setup_sock) + { + sock_us = new sockaddr[2]; + client = new sockaddr[2]; + setup_sock = true; + } + #ifdef IPV6 if (this->family == AF_INET6) { @@ -117,7 +128,7 @@ void ListenSocket::HandleEvent(EventType, int) } } ServerInstance->stats->statsAccept++; - User::AddClient(ServerInstance, incomingSockfd, in_port, false, this->family, client); + ServerInstance->Users->AddClient(ServerInstance, incomingSockfd, in_port, false, this->family, client); } else { @@ -125,8 +136,6 @@ void ListenSocket::HandleEvent(EventType, int) ServerInstance->SE->Close(incomingSockfd); ServerInstance->stats->statsRefused++; } - delete[] client; - delete[] sock_us; } /* Match raw bytes using CIDR bit matching, used by higher level MatchCIDR() */