Пример #1
0
void LogFileFlusher::recordWriteAndMaybeDropCaches(int fd, int bytes) {
  int oldBytesWritten = m_bytesWritten.fetch_add(bytes);
  int newBytesWritten = oldBytesWritten + bytes;

  if (!(newBytesWritten > DropCacheChunkSize &&
        oldBytesWritten <= DropCacheChunkSize)) {
    return;
  }

  off_t offset = lseek(fd, 0, SEEK_CUR);
  if (offset > kDropCacheTail) {
    dropCache(fd, offset - kDropCacheTail);
  }

  m_bytesWritten = 0;
}
Пример #2
0
void HttpServer::watchDog() {
  int count = 0;
  while (!m_stopped) {
    if (RuntimeOption::DropCacheCycle > 0 &&
        (count % RuntimeOption::DropCacheCycle) == 0) { // every hour
      dropCache();
    }

    sleep(1);
    ++count;

    if (RuntimeOption::MaxRSSPollingCycle > 0 &&
        (count % RuntimeOption::MaxRSSPollingCycle) == 0) { // every minute
      checkMemory();
    }
  }
}
Пример #3
0
void HttpServer::watchDog() {
  int count = 0;
  bool noneed = false;
  while (!m_stopped && !noneed) {
    noneed = true;

    if (RuntimeOption::DropCacheCycle > 0) {
      noneed = false;
      if ((count % RuntimeOption::DropCacheCycle) == 0) { // every hour
        dropCache();
      }
    }

    sleep(1);
    ++count;

    if (RuntimeOption::MaxRSSPollingCycle > 0) {
      noneed = false;
      if ((count % RuntimeOption::MaxRSSPollingCycle) == 0) { // every minute
        checkMemory();
      }
    }
  }
}
Пример #4
0
void Helpers::uninit(void)
{
    dropCache();
}