summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-11 18:38:00 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-11 18:38:00 +0000
commitbfcaef8623bb3f8faf1141eb7b3805ab75ae97dd (patch)
treef26d108a63a8d311c64b400e58d5d1b7eff39bec /src/inspircd.cpp
parentb469531385d6d65b2f9dface80fe1ab4b9e19e15 (diff)
Refactor port binding, warning not yet tested fully
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6982 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 46e469d61..c78f44f46 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -78,13 +78,13 @@ void InspIRCd::Cleanup()
std::vector<std::string> mymodnames;
int MyModCount = this->GetModuleCount();
- for (unsigned int i = 0; i < stats->BoundPortCount; i++)
+ for (unsigned int i = 0; i < Config->ports.size(); i++)
{
/* This calls the constructor and closes the listening socket */
- delete Config->openSockfd[i];
- Config->openSockfd[i] = NULL;
+ delete Config->ports[i];
}
- stats->BoundPortCount = 0;
+
+ Config->ports.clear();
/* Close all client sockets, or the new process inherits them */
for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
@@ -396,18 +396,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
sleep(20);
}
- this->Modes = new ModeParser(this);
- this->AddServerName(Config->ServerName);
- CheckDie();
- InitializeDisabledCommands(Config->DisabledCommands, this);
- stats->BoundPortCount = BindPorts(true, found_ports, pl);
-
- for(int t = 0; t < 255; t++)
- Config->global_implementation[t] = 0;
-
- memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
-
- printf("\n");
this->SetSignals();
if (!Config->nofork)
@@ -420,30 +408,44 @@ InspIRCd::InspIRCd(int argc, char** argv)
}
}
- /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
+
+ /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
* initialize the socket engine.
*/
SocketEngineFactory* SEF = new SocketEngineFactory();
SE = SEF->Create(this);
delete SEF;
+ this->Modes = new ModeParser(this);
+ this->AddServerName(Config->ServerName);
+ CheckDie();
+ InitializeDisabledCommands(Config->DisabledCommands, this);
+ int bounditems = BindPorts(true, found_ports, pl);
+
+ for(int t = 0; t < 255; t++)
+ Config->global_implementation[t] = 0;
+
+ memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
+
+ printf("\n");
+
this->Res = new DNS(this);
this->LoadAllModules();
/* Just in case no modules were loaded - fix for bug #101 */
this->BuildISupport();
- if ((stats->BoundPortCount == 0) && (found_ports > 0))
+ if ((Config->ports.size() == 0) && (found_ports > 0))
{
printf("\nERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
Log(DEFAULT,"ERROR: I couldn't bind any ports! Are you sure you didn't start InspIRCd twice?");
Exit(EXIT_STATUS_BIND);
}
- if (stats->BoundPortCount != (unsigned int)found_ports)
+ if (Config->ports.size() != (unsigned int)found_ports)
{
- printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %ld of %d client ports bound.\n\n", stats->BoundPortCount, found_ports);
- printf("The following port%s failed to bind:\n", found_ports - stats->BoundPortCount != 1 ? "s" : "");
+ printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports);
+ printf("The following port(s) failed to bind:\n");
int j = 1;
for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++)
{
@@ -451,19 +453,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
}
}
- /* Add the listening sockets used for client inbound connections
- * to the socket engine
- */
- for (unsigned long count = 0; count < stats->BoundPortCount; count++)
- {
- if (!SE->AddFd(Config->openSockfd[count]))
- {
- printf("\nEH? Could not add listener to socketengine. You screwed up, aborting.\n");
- Log(DEFAULT,"EH? Could not add listener to socketengine. You screwed up, aborting.");
- Exit(EXIT_STATUS_INTERNAL);
- }
- }
-
if (!Config->nofork)
{
if (kill(getppid(), SIGTERM) == -1)