diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-29 00:19:35 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-29 00:19:35 +0000 |
commit | 0bf908e49c957ce35ac194a0c9b739f22d76182e (patch) | |
tree | 839be4613f600d34ff5c3285ba3f5840aac24b11 /src/inspircd.cpp | |
parent | bbad4e536234949a1ce480e6c6f901c884621c5e (diff) |
Optimizing to not use so much cpu with high user loads
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2691 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 6d21e3677..993348aff 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -410,7 +410,7 @@ bool InspIRCd::LoadModule(const char* filename) int InspIRCd::Run() { bool expire_run = false; - std::vector<int> activefds; + int activefds[65535]; int incomingSockfd; int in_port; userrec* cu = NULL; @@ -462,19 +462,26 @@ int InspIRCd::Run() expire_run = true; continue; } - if ((TIME % 8) == 1) + else if ((TIME % 8) == 1) + { expire_run = false; + } /* Once a second, do the background processing */ - if (TIME != OLDTIME) - while (DoBackgroundUserStuff(TIME)); + if ((TIME != OLDTIME) && ((TIME % 2) == 0)) + DoBackgroundUserStuff(TIME); /* Call the socket engine to wait on the active * file descriptors. The socket engine has everything's * descriptors in its list... dns, modules, users, * servers... so its nice and easy, just one call. */ - SE->Wait(activefds); + numberactive = SE->Wait(activefds); + + if (!numberactive) + continue; + + log(DEBUG,"%d active fds this time around",numberactive); /** * Now process each of the fd's. For users, we have a fast @@ -483,7 +490,6 @@ int InspIRCd::Run() * listening ports or module sockets though, things could get * ugly. */ - numberactive = activefds.size(); for (unsigned int activefd = 0; activefd < numberactive; activefd++) { int socket_type = SE->GetType(activefds[activefd]); |