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; }
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(); } } }
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(); } } } }
void Helpers::uninit(void) { dropCache(); }