summaryrefslogtreecommitdiff
path: root/src/listensocket.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-21 20:47:02 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-21 20:47:02 +0000
commitd29ca254a4a9062ecaffe9395454f3a654d4e06a (patch)
treeb4af3499f3e3a341f1fcadaf21228b592a84dd78 /src/listensocket.cpp
parent8a11f8ecddaaf6c8162d93a28d924fe0b566332c (diff)
Remove unneeded save of errno
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12309 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/listensocket.cpp')
-rw-r--r--src/listensocket.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index e77a585ef..6ae598ad3 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -17,40 +17,34 @@
#include "socket.h"
#include "socketengine.h"
-ListenSocket::ListenSocket(ConfigTag* tag, const std::string& addr, int port)
+ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to)
: bind_tag(tag)
{
- irc::sockets::sockaddrs bind_to;
-
- // canonicalize address if it is defined
- if (!irc::sockets::aptosa(addr, port, bind_to))
- {
- fd = -1;
- return;
- }
irc::sockets::satoap(bind_to, bind_addr, bind_port);
bind_desc = irc::sockets::satouser(bind_to);
fd = socket(bind_to.sa.sa_family, SOCK_STREAM, 0);
- if (this->fd > -1)
- {
- ServerInstance->SE->SetReuse(fd);
- int rv = ServerInstance->SE->Bind(this->fd, bind_to);
- if (rv >= 0)
- rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn);
+ if (this->fd == -1)
+ return;
- if (rv < 0)
- {
- ServerInstance->SE->Shutdown(this, 2);
- ServerInstance->SE->Close(this);
- this->fd = -1;
- }
- else
- {
- ServerInstance->SE->NonBlocking(this->fd);
- ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
- }
+ ServerInstance->SE->SetReuse(fd);
+ int rv = ServerInstance->SE->Bind(this->fd, bind_to);
+ if (rv >= 0)
+ rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn);
+
+ if (rv < 0)
+ {
+ int errstore = errno;
+ ServerInstance->SE->Shutdown(this, 2);
+ ServerInstance->SE->Close(this);
+ this->fd = -1;
+ errno = errstore;
+ }
+ else
+ {
+ ServerInstance->SE->NonBlocking(this->fd);
+ ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
}
}