Lines Matching defs:cleaner
154 isc_event_t *resched_event; /* Sent by cleaner task to
203 acache_cleaner_t cleaner;
270 acache_cleaner_t *cleaner);
330 * If the cleaner holds this entry, it will be unlinked and
331 * freed in the cleaner later.
333 if (acache->cleaner.current_entry != entry)
344 if (acache->cleaner.current_entry != entry)
453 if (acache->cleaner.overmem_event != NULL)
454 isc_event_free(&acache->cleaner.overmem_event);
456 if (acache->cleaner.resched_event != NULL)
457 isc_event_free(&acache->cleaner.resched_event);
468 DESTROYLOCK(&acache->cleaner.lock);
553 acache_cleaner_t *cleaner)
557 ATRACE("acache cleaner init");
559 result = isc_mutex_init(&cleaner->lock);
563 cleaner->increment = DNS_ACACHE_CLEANERINCREMENT;
564 cleaner->state = cleaner_s_idle;
565 cleaner->acache = acache;
566 cleaner->overmem = ISC_FALSE;
568 cleaner->cleaning_timer = NULL;
569 cleaner->resched_event = NULL;
570 cleaner->overmem_event = NULL;
571 cleaner->current_entry = NULL;
574 cleaner->acache->live_cleaners++;
581 "acache cleaner: "
587 cleaner->cleaning_interval = 0; /* Initially turned off. */
588 isc_stdtime_get(&cleaner->last_cleanup_time);
593 cleaner, &cleaner->cleaning_timer);
602 cleaner->resched_event =
603 isc_event_allocate(acache->mctx, cleaner,
606 cleaner, sizeof(isc_event_t));
607 if (cleaner->resched_event == NULL) {
612 cleaner->overmem_event =
613 isc_event_allocate(acache->mctx, cleaner,
616 cleaner, sizeof(isc_event_t));
617 if (cleaner->overmem_event == NULL) {
626 if (cleaner->overmem_event != NULL)
627 isc_event_free(&cleaner->overmem_event);
628 if (cleaner->resched_event != NULL)
629 isc_event_free(&cleaner->resched_event);
630 if (cleaner->cleaning_timer != NULL)
631 isc_timer_detach(&cleaner->cleaning_timer);
632 cleaner->acache->live_cleaners--;
633 DESTROYLOCK(&cleaner->lock);
639 begin_cleaning(acache_cleaner_t *cleaner) {
641 dns_acache_t *acache = cleaner->acache;
644 * This function does not have to lock the cleaner, since critical
649 REQUIRE(CLEANER_IDLE(cleaner));
651 INSIST(cleaner->current_entry == NULL);
656 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
662 dns_acache_attachentry(head, &cleaner->current_entry);
666 if (cleaner->current_entry != NULL) {
667 cleaner->ncleaned = 0;
668 cleaner->state = cleaner_s_busy;
669 isc_task_send(acache->task, &cleaner->resched_event);
676 end_cleaning(acache_cleaner_t *cleaner, isc_event_t *event) {
677 dns_acache_t *acache = cleaner->acache;
679 REQUIRE(CLEANER_BUSY(cleaner));
681 REQUIRE(DNS_ACACHEENTRY_VALID(cleaner->current_entry));
683 /* No need to lock the cleaner (see begin_cleaning()). */
688 * Even if the cleaner has the last reference to the entry, which means
692 if (isc_refcount_current(&cleaner->current_entry->references) == 1) {
693 INSIST(cleaner->current_entry->callback == NULL);
695 if (ISC_LINK_LINKED(cleaner->current_entry, link)) {
697 cleaner->current_entry, link);
700 dns_acache_detachentry(&cleaner->current_entry);
702 if (cleaner->overmem)
704 acache->stats.cleaned += cleaner->ncleaned;
722 isc_stdtime_get(&cleaner->last_cleanup_time);
726 dns_acache_setcleaninginterval(cleaner->acache,
727 cleaner->cleaning_interval);
732 cleaner->ncleaned,
733 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
735 if (cleaner->overmem) {
742 cleaner->ncleaned = 0;
743 cleaner->state = cleaner_s_idle;
744 cleaner->resched_event = event;
753 acache_cleaner_t *cleaner = event->ev_arg;
761 "cleaner state = %d", cleaner->state);
763 if (cleaner->state == cleaner_s_idle)
764 begin_cleaning(cleaner);
771 entry_stale(acache_cleaner_t *cleaner, dns_acacheentry_t *entry,
781 if (interval > cleaner->cleaning_interval)
782 interval = cleaner->cleaning_interval;
792 if (cleaner->overmem) {
817 acache_cleaner_t *cleaner = event->ev_arg;
818 dns_acache_t *acache = cleaner->acache;
829 if (cleaner->state == cleaner_s_done) {
830 cleaner->state = cleaner_s_busy;
831 end_cleaning(cleaner, event);
835 INSIST(CLEANER_BUSY(cleaner));
837 n_entries = cleaner->increment;
844 entry = cleaner->current_entry;
845 isc_stdtime_convert32(cleaner->last_cleanup_time, &last32);
861 is_stale = entry_stale(cleaner, entry, now32, interval);
869 cleaner->ncleaned++;
879 if (cleaner->overmem) {
894 "acache cleaner: "
903 end_cleaning(cleaner, event);
917 dns_acache_detachentry(&cleaner->current_entry);
918 dns_acache_attachentry(next, &cleaner->current_entry);
923 ISC_LOG_DEBUG(1), "acache cleaner: checked %d entries, "
924 "mem inuse %lu, sleeping", cleaner->increment,
925 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
928 INSIST(CLEANER_BUSY(cleaner));
939 acache_cleaner_t *cleaner = event->ev_arg;
945 INSIST(cleaner->overmem_event == NULL);
949 "overmem = %d, state = %d", cleaner->overmem,
950 cleaner->state);
952 LOCK(&cleaner->lock);
954 if (cleaner->overmem) {
955 if (cleaner->state == cleaner_s_idle)
958 if (cleaner->state == cleaner_s_busy)
961 * then both cleaner->overmem_event and
962 * cleaner->resched_event will point to this
967 cleaner->state = cleaner_s_done;
970 cleaner->overmem_event = event;
972 UNLOCK(&cleaner->lock);
975 begin_cleaning(cleaner);
991 LOCK(&acache->cleaner.lock);
993 if (acache->cleaner.overmem != overmem) {
994 acache->cleaner.overmem = overmem;
996 if (acache->cleaner.overmem_event != NULL)
998 &acache->cleaner.overmem_event);
1002 UNLOCK(&acache->cleaner.lock);
1006 * The cleaner task is shutting down; do the necessary cleanup.
1017 ATRACE("acache cleaner shutdown");
1019 if (CLEANER_BUSY(&acache->cleaner))
1020 end_cleaning(&acache->cleaner, event);
1039 if (acache->cleaner.cleaning_timer != NULL)
1040 isc_timer_detach(&acache->cleaner.cleaning_timer);
1134 result = acache_cleaner_init(acache, timermgr, &acache->cleaner);
1203 * If we're exiting and the cleaner task exists, let it free the cache.
1331 if (acache->cleaner.current_entry != entry)
1342 if (acache->cleaner.current_entry != entry)
1350 if (acache->cleaner.current_entry != entry)
1361 if (acache->cleaner.current_entry != entry)
1400 * example, if the cleaner does not run aggressively enough),
1403 * XXXSK: It might be better to lock the acache->cleaner->lock,
1410 if (acache->cleaner.overmem) {
1762 if (acache->cleaner.cleaning_timer == NULL)
1765 acache->cleaner.cleaning_interval = t;
1768 result = isc_timer_reset(acache->cleaner.cleaning_timer,
1772 isc_interval_set(&interval, acache->cleaner.cleaning_interval,
1774 result = isc_timer_reset(acache->cleaner.cleaning_timer,