From 276b84df68ce8655947f2870d835cac4eecf6a98 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 11 Jul 2006 10:03:09 +0000 Subject: Move openSockfd[] into ServerConfig git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4322 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/configreader.h | 4 ++++ src/inspircd.cpp | 17 +---------------- src/socket.cpp | 17 ++++++++--------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/configreader.h b/include/configreader.h index 723ce881b..598fbef81 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -301,6 +301,10 @@ class ServerConfig : public Extensible */ int ports[255]; + /** A list of the file descriptors for the listening client ports + */ + int openSockfd[MAX_DESCRIPTORS]; + /** Boolean sets of which modules implement which functions */ char implement_lists[255][255]; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1a12b7039..05761237b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -70,9 +70,6 @@ InspIRCd* ServerInstance; -int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'stale' -int WHOWAS_MAX = 100; // default 100 people maximum in the WHOWAS list - extern ModuleList modules; extern FactoryList factory; @@ -81,12 +78,9 @@ std::vector local_users; extern int MODCOUNT; extern char LOG_FILE[MAXBUF]; -int openSockfd[MAX_DESCRIPTORS]; -int yield_depth; int iterations = 0; insp_sockaddr client, server; - socklen_t length; extern InspSocket* socket_ref[MAX_DESCRIPTORS]; @@ -694,11 +688,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) insp_sockaddr sock_us; // our port number socklen_t uslen; // length of our port number - if (yield_depth > 100) - return; - - yield_depth++; - /* time() seems to be a pretty expensive syscall, so avoid calling it too much. * Once per loop iteration is pleanty. */ @@ -731,7 +720,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) } TickMissedTimers(TIME); expire_run = true; - yield_depth--; return; } else if ((TIME % 5) == 1) @@ -772,10 +760,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) * servers... so its nice and easy, just one call. */ if (!(numberactive = SE->Wait(activefds))) - { - yield_depth--; return; - } /** * Now process each of the fd's. For users, we have a fast @@ -929,7 +914,7 @@ int InspIRCd::Run() * to the socket engine */ for (int count = 0; count < stats->BoundPortCount; count++) - SE->AddFd(openSockfd[count],true,X_LISTEN); + SE->AddFd(Config->openSockfd[count],true,X_LISTEN); this->WritePID(Config->PID); diff --git a/src/socket.cpp b/src/socket.cpp index a6847fce1..793e930ff 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -26,7 +26,6 @@ extern InspIRCd* ServerInstance; extern ServerConfig* Config; extern time_t TIME; -extern int openSockfd[MAX_DESCRIPTORS]; /** This will bind a socket to a port. It works for UDP/TCP. * If a hostname is given to bind to, the function will first @@ -165,21 +164,21 @@ int BindPorts(bool bail) { for (int count = InitialPortCount; count < InitialPortCount + PortCount; count++) { - if ((openSockfd[count] = OpenTCPSocket()) == ERROR) + if ((Config->openSockfd[count] = OpenTCPSocket()) == ERROR) { - log(DEBUG,"Bad fd %d binding port [%s:%d]",openSockfd[count],Config->addrs[count],Config->ports[count]); + log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[count],Config->addrs[count],Config->ports[count]); return ERROR; } - if (!BindSocket(openSockfd[count],client,server,Config->ports[count],Config->addrs[count])) + 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 (openSockfd[count] > -1) + if (Config->openSockfd[count] > -1) { - ServerInstance->SE->AddFd(openSockfd[count],true,X_LISTEN); + ServerInstance->SE->AddFd(Config->openSockfd[count],true,X_LISTEN); BoundPortCount++; } } @@ -221,13 +220,13 @@ int BindPorts(bool bail) for (int count = 0; count < PortCount; count++) { - if ((openSockfd[BoundPortCount] = OpenTCPSocket()) == ERROR) + if ((Config->openSockfd[BoundPortCount] = OpenTCPSocket()) == ERROR) { - log(DEBUG,"Bad fd %d binding port [%s:%d]",openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]); + log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]); return ERROR; } - if (!BindSocket(openSockfd[BoundPortCount],client,server,Config->ports[count],Config->addrs[count])) + 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)); } -- cgit v1.2.3