Remove unneeded save of errno

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12309 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
danieldg 2010-01-21 20:47:02 +00:00
parent 8a11f8ecdd
commit d29ca254a4
4 changed files with 26 additions and 36 deletions

View File

@ -138,7 +138,7 @@ class CoreExport ListenSocket : public EventHandler
std::string bind_desc;
/** Create a new listening socket
*/
ListenSocket(ConfigTag* tag, const std::string& addr, int port);
ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to);
/** Handle an I/O event
*/
void HandleEvent(EventType et, int errornum = 0);

View File

@ -118,11 +118,6 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs&
void StreamSocket::Close()
{
/* Save this, so we dont lose it,
* otherise on failure, error messages
* might be inaccurate.
*/
int save = errno;
if (this->fd > -1)
{
if (IOHook)
@ -142,7 +137,6 @@ void StreamSocket::Close()
ServerInstance->SE->Close(this);
fd = -1;
}
errno = save;
}
CullResult StreamSocket::cull()

View File

@ -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);
}
}

View File

@ -86,8 +86,9 @@ int InspIRCd::BindPorts(FailedPortList &failed_ports)
while (0 != (portno = portrange.GetToken()))
{
irc::sockets::sockaddrs bindspec;
irc::sockets::aptosa(Addr, portno, bindspec);
std::string bind_readable = irc::sockets::satouser(bindspec);
if (!irc::sockets::aptosa(Addr, portno, bindspec))
continue;
std::string bind_readable = bindspec.str();
bool skip = false;
for (std::vector<ListenSocket*>::iterator n = old_ports.begin(); n != old_ports.end(); ++n)
@ -101,7 +102,8 @@ int InspIRCd::BindPorts(FailedPortList &failed_ports)
}
if (!skip)
{
ListenSocket *ll = new ListenSocket(tag, Addr, portno);
ListenSocket* ll = new ListenSocket(tag, bindspec);
if (ll->GetFd() > -1)
{
bound++;