コード例 #1
0
 /**
  * Initializes logger and database.
  */
 function ProxyFramework($dbFile, $proxyChecker, $snapshotInterval, $proxyCheckInterval, $quarantineCheckInterval, $checkingThreadCap, $maxQuarantineRetries, $pidFile)
 {
     $this->logger = new LoggingImpl();
     Helper::checkString("dbFile", $dbFile, $this->logger);
     Helper::checkNull("proxyChecker", $proxyChecker, $this->logger);
     $db = new DatabaseImpl($dbFile, array(100, 5, 15, 3, 13, 1, 1, 1, 1, 10, 6, 6, 4));
     $db->cacheEntries();
     //preemptively cache entries to make sure the db state is the same across all threads
     $uniqueIP = new UniqueIPDatabase();
     // set up mutexes and shared data, as well as the signal handler
     $this->init();
     $this->setVar(__INDEX_DATA, $db);
     $this->setVar(__INDEX_PIDS, array());
     $this->setVar(__INDEX_CHECKING_THREAD_COUNT, 0);
     $this->setVar(__INDEX_UDATA, $uniqueIP);
     $this->proxyChecker = $proxyChecker;
     $this->snapshotInterval = $snapshotInterval;
     $this->proxyCheckInterval = $proxyCheckInterval;
     $this->quarantineCheckInterval = $quarantineCheckInterval;
     $this->checkingThreadCap = $checkingThreadCap;
     $this->maxQuarantineRetries = $maxQuarantineRetries;
     ProxyFramework::$pidFile = $pidFile;
     ProxyFramework::$instance = $this;
     ProxyFramework::$mainPid = posix_getpid();
 }