]> jfr.im git - irc/evilnet/mod.chanfix.git/commitdiff
Set default intervals to more reasonable times. Remove unused MAX_*FIX defines. Send...
authorr33d <redacted>
Wed, 18 Jan 2006 22:29:41 +0000 (22:29 +0000)
committerr33d <redacted>
Wed, 18 Jan 2006 22:29:41 +0000 (22:29 +0000)
chanfix.cc
chanfix_config.h

index aa0c878af455266056f0fc90b78e56aa98f2ded7..2fb645aeda5964f4d72cd3dde18059c573a567a6 100644 (file)
@@ -100,7 +100,7 @@ std::string dbString = "host=" + sqlHost + " dbname=" + sqlDB
 theManager = sqlManager::getInstance(dbString);
 
 /* Get our logfiles open */
-adminLog.open(adminLogFile.c_str());
+adminLog.open(adminLogFile.c_str(), std::ios::out | std::ios::app);
 
 /* Register the commands we want to use */
 RegisterCommand(new ADDFLAGCommand(this, "ADDFLAG",
@@ -404,7 +404,6 @@ MyUplink->RegisterChannelEvent( xServer::CHANNEL_ALL, this );
 xClient::OnAttach() ;
 }
 
-
 /**
  * Thread class only used for score updates, updates on reload and shutdown are not threaded
  */
@@ -462,6 +461,7 @@ else if (theTimer == tidRotateDB) {
   tidRotateDB = MyUplink->RegisterTimer(theTime, this, NULL);
 }
 else if (theTimer == tidUpdateDB) {
+  /* Prepare to synchronize the database in a thread */
   prepareUpdate(true);
 
   /* Refresh Timer */
@@ -489,6 +489,10 @@ commandMap.clear();
 /* Delete our sqlManager */
 theManager->removeManager();
 
+/* Finally, close our admin log */
+if (adminLog.is_open())
+  adminLog.close();
+
 xClient::OnDetach( reason ) ;
 }
 
@@ -2003,7 +2007,7 @@ void chanfix::prepareUpdate(bool threaded)
         curStruct.day[i] = curOp->getDay(i);
       }
       
-      snapShot.insert(DBMapType::value_type(curChan,curStruct));
+      snapShot.insert(DBMapType::value_type(curChan, curStruct));
     }
   }
 
@@ -2050,55 +2054,29 @@ void chanfix::updateDB()
   std::stringstream theLine;
   int chanOpsProcessed = 0;
 
-  for (sqlChanOpsType::iterator ptr = sqlChanOps.begin();
-       ptr != sqlChanOps.end(); ptr++) {
-    /* curChan = escapeSQLChars(ptr->first); */
-    curChan = ptr->first;
-    for (sqlChanOpsType::mapped_type::iterator chanOp = ptr->second.begin();
-        chanOp != ptr->second.end(); chanOp++) {
-      curOp = chanOp->second;
-                
-      /* Fill the structures and maps */
-      tmpStruct.account = curOp->getAccount();
-      tmpStruct.lastSeenAs = curOp->getLastSeenAs();
-      tmpStruct.firstOpped = curOp->getTimeFirstOpped();
-      tmpStruct.lastOpped = curOp->getTimeLastOpped();
-      
-      for (i = 0; i < DAYSAMPLES; i++) {
-        tmpStruct.day[i] = curOp->getDay(i);
-      }
-      
-      tmpSnapShot.insert(tmpDBMapType::value_type(curChan,tmpStruct));
-      
-      /*
-      acct = escapeSQLChars (curOp->getAccount ()).c_str ();
-      lsa = escapeSQLChars (curOp->getLastSeenAs ()).c_str ();
-
-      theLine.str("");
-      theLine  << curChan << "\t"
-               << acct << "\t"
-               << lsa << "\t"
-               << curOp->getTimeFirstOpped() << "\t"
-               << curOp->getTimeLastOpped()
-               ;
+  for (DBMapType::iterator ptr = snapShot.begin();
+       ptr != snapShot.end(); ptr++) {
+    curChan = escapeSQLChars(ptr->first);
 
-      int i;
-      for (i = 0; i < DAYSAMPLES; i++) {
-        theLine        << "\t" << curOp->getDay(i)
+    theLine.str("");
+    theLine    << curChan << "\t"
+               << escapeSQLChars(ptr->second.account) << "\t"
+               << escapeSQLChars(ptr->second.lastSeenAs) << "\t"
+               << ptr->second.firstOpped << "\t"
+               << ptr->second.lastOpped
                ;
-      }
 
-      theLine  << "\n"
+    int i;
+    for (i = 0; i < DAYSAMPLES; i++) {
+      theLine  << "\t" << ptr->second.day[i]
                ;
+    }
 
-      bytes += strlen (acct) + strlen (lsa) 
-               + (sizeof (short) * DAYSAMPLES)
-               + (sizeof (time_t) * 2);
+    theLine    << "\n"
+               ;
 
-      cacheCon->PutLine(theLine.str().c_str());
-      */
-      chanOpsProcessed++;
-    }
+    cacheCon->PutLine(theLine.str().c_str());
+    chanOpsProcessed++;
   }
   
   /* Send completion string for the end of the data. */
index 1197f5c4919caff439af5dff7c53dc1db18f8091..9e74c7da55c2bdd0bdcdefcd1ae8ae8ff079eb87 100644 (file)
 /**
  * Interval between two consecutive checks for opless channels.
  */
-#define CHECK_CHANS_TIME       10
+#define CHECK_CHANS_TIME       600
 
 /**
  * Interval between two consecutive processing of the queues.
  */
-#define PROCESS_QUEUE_TIME     5
+#define PROCESS_QUEUE_TIME     300
 
 /**
  * Maximum score a client can obtain.
  */
 #define MAXNOTECOUNT   50
 
-/**
- * The maximum number of automatic fixes to retain in history per
- * channel. (default: 10)
- * NOTE: Not used (yet).
- */
-#define MAXAUTOFIX     10
-
-/**
- * The maximum number of manual fixes to retain in history per channel.
- * (default: 10)
- * NOTE: Not used (yet).
- */
-#define MAXMANUALFIX   10
-
 /**
  * Do you want to remember (and never expire) old channel entries that
  * have notes or flags associated with them?