From 358f2064c432e1e3ef153adeb5aed0fa2e35efde Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 7 Aug 2006 21:25:48 +0000 Subject: Bail if we couldn't bind any ports (when did this get broken?) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4774 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/socket.cpp') diff --git a/src/socket.cpp b/src/socket.cpp index 1821120f4..cbb2a213c 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -347,19 +347,21 @@ int BindPorts(bool bail) if ((Config->openSockfd[count] = OpenTCPSocket()) == ERROR) { log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[count],Config->addrs[count],Config->ports[count]); - return ERROR; - } - if (!BindSocket(Config->openSockfd[count],client,server,Config->ports[count],Config->addrs[count])) - { - log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); } else { - /* Associate the new open port with a slot in the socket engine */ - if (Config->openSockfd[count] > -1) + if (!BindSocket(Config->openSockfd[count],client,server,Config->ports[count],Config->addrs[count])) + { + log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); + } + else { - ServerInstance->SE->AddFd(Config->openSockfd[count],true,X_LISTEN); - BoundPortCount++; + /* Associate the new open port with a slot in the socket engine */ + if (Config->openSockfd[count] > -1) + { + ServerInstance->SE->AddFd(Config->openSockfd[count],true,X_LISTEN); + BoundPortCount++; + } } } } @@ -403,17 +405,18 @@ int BindPorts(bool bail) if ((Config->openSockfd[BoundPortCount] = OpenTCPSocket()) == ERROR) { log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]); - return ERROR; - } - - if (!BindSocket(Config->openSockfd[BoundPortCount],client,server,Config->ports[count],Config->addrs[count])) - { - log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); } else { - /* well we at least bound to one socket so we'll continue */ - BoundPortCount++; + if (!BindSocket(Config->openSockfd[BoundPortCount],client,server,Config->ports[count],Config->addrs[count])) + { + log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); + } + else + { + /* well we at least bound to one socket so we'll continue */ + BoundPortCount++; + } } } @@ -422,7 +425,7 @@ int BindPorts(bool bail) { log(DEFAULT,"No ports bound, bailing!"); printf("\nERROR: Could not bind any of %d ports! Please check your configuration.\n\n", PortCount); - return ERROR; + return 0; } return BoundPortCount; -- cgit v1.3.1-10-gc9f91