]> jfr.im git - irc/evilnet/mod.chanfix.git/commitdiff
Increased speed of reops, no longer use min_score if the channels max score is below...
authorbuzlip01 <redacted>
Wed, 6 Sep 2006 13:35:54 +0000 (13:35 +0000)
committerbuzlip01 <redacted>
Wed, 6 Sep 2006 13:35:54 +0000 (13:35 +0000)
chanfix.cc
chanfix.h

index 4afaeaf3c5ab1ef81a03c53fac2c8b6b1ab77560..c1a7b53a265ba3676319ec14860a3ae7d7d8b8be 100644 (file)
@@ -38,6 +38,8 @@
 #include       <utility>
 #include       <vector>
 
+#include       <sys/resource.h>
+
 #include       "libpq++.h"
 
 #include       "gnuworld_config.h"
@@ -487,6 +489,7 @@ MyUplink->RegisterEvent( EVT_BURST_CMPLT, this );
 MyUplink->RegisterEvent( EVT_NETJOIN, this );
 MyUplink->RegisterEvent( EVT_NETBREAK, this );
 MyUplink->RegisterEvent( EVT_NICK, this );
+MyUplink->RegisterEvent( EVT_SERVERMODE, this );
 
 /**
  * Register for all channel events
@@ -802,6 +805,11 @@ switch( whichEvent )
                lostOp(theChan->getName(), theClient, NULL);
                break ;
                }
+       case EVT_SERVERMODE:
+               {
+               elog << "chanfix: GOT SERVER MODE EVENT!" << std::endl;
+               break ;
+               }
        default:
                break ;
        }
@@ -1973,6 +1981,16 @@ int min_score = min_score_abs;
 if (min_score_rel > min_score)
   min_score = min_score_rel;
 
+/* We need to check to see if the highest scoring ops score for the chan
+ * is less than min_score, if so, adjust min_score so we wont have
+ * to wait forever for the first op! */
+
+if (myOps.begin() != myOps.end())
+  sqlChan->setMaxScore((*myOps.begin())->getPoints());
+
+if (sqlChan->getMaxScore() < min_score)
+  min_score = sqlChan->getMaxScore();
+
 elog << "chanfix::fixChan> [" << netChan->getName() << "] start "
        << sqlChan->getFixStart() << ", delta " << time_since_start
        << ", max " << maxScore << ", minabs " << min_score_abs
@@ -2506,7 +2524,7 @@ void chanfix::prepareUpdate(bool)
   } else
 #endif /* CHANFIX_HAVE_BOOST_THREAD */
     updateDB();
-
+    printResourceStats();
   return;
 }
 
@@ -2653,6 +2671,15 @@ void chanfix::updateDB()
   return;
 }
 
+void chanfix::printResourceStats()
+{
+  int who = RUSAGE_SELF;
+  struct rusage usage;
+  int ret;
+  ret = getrusage(who, &usage);
+  logDebugMessage("Max. resident size used by chanfix (kB): %ld", usage.ru_maxrss);
+}
+
 bool chanfix::isTempBlocked(const std::string& theChan)
 {
   tempBlockType::iterator ptr = tempBlockList.find(theChan);
index d0cfad48065a154ff4a402985fe245479378f8c1..6e1f851837bf680e23609fcba6e907079fb94b2e 100644 (file)
--- a/chanfix.h
+++ b/chanfix.h
@@ -206,6 +206,8 @@ public:
        void precacheChannels();
        void precacheUsers();
 
+       void printResourceStats();
+
        void changeState(STATE);
 
        time_t currentTime() { return ::time(0); }