diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-02 22:48:41 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-02 22:48:41 +0000 |
commit | 7f7e508640db92ce3535afe498bc1cc5a70a1cdd (patch) | |
tree | fdd80efdde036c326a432b8df625c06f0b6a22bf /src/socket.cpp | |
parent | d555db40f4b39f10ad06c2449b42711c1e74105f (diff) |
Avoid reallocating this every new connection (patch from hottpd)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8794 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r-- | src/socket.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/socket.cpp b/src/socket.cpp index 48c0170d3..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) { @@ -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() */ |