Lines Matching defs:cleaner
144 isc_event_t *resched_event; /* Sent by cleaner task to
193 acache_cleaner_t cleaner;
256 acache_cleaner_t *cleaner);
316 * If the cleaner holds this entry, it will be unlinked and
317 * freed in the cleaner later.
319 if (acache->cleaner.current_entry != entry)
330 if (acache->cleaner.current_entry != entry)
439 if (acache->cleaner.overmem_event != NULL)
440 isc_event_free(&acache->cleaner.overmem_event);
442 if (acache->cleaner.resched_event != NULL)
443 isc_event_free(&acache->cleaner.resched_event);
454 DESTROYLOCK(&acache->cleaner.lock);
540 acache_cleaner_t *cleaner)
544 ATRACE("acache cleaner init");
546 result = isc_mutex_init(&cleaner->lock);
550 cleaner->increment = DNS_ACACHE_CLEANERINCREMENT;
551 cleaner->state = cleaner_s_idle;
552 cleaner->acache = acache;
553 cleaner->overmem = ISC_FALSE;
555 cleaner->cleaning_timer = NULL;
556 cleaner->resched_event = NULL;
557 cleaner->overmem_event = NULL;
558 cleaner->current_entry = NULL;
561 cleaner->acache->live_cleaners++;
568 "acache cleaner: "
574 cleaner->cleaning_interval = 0; /* Initially turned off. */
575 isc_stdtime_get(&cleaner->last_cleanup_time);
580 cleaner, &cleaner->cleaning_timer);
589 cleaner->resched_event =
590 isc_event_allocate(acache->mctx, cleaner,
593 cleaner, sizeof(isc_event_t));
594 if (cleaner->resched_event == NULL) {
599 cleaner->overmem_event =
600 isc_event_allocate(acache->mctx, cleaner,
603 cleaner, sizeof(isc_event_t));
604 if (cleaner->overmem_event == NULL) {
613 if (cleaner->overmem_event != NULL)
614 isc_event_free(&cleaner->overmem_event);
615 if (cleaner->resched_event != NULL)
616 isc_event_free(&cleaner->resched_event);
617 if (cleaner->cleaning_timer != NULL)
618 isc_timer_detach(&cleaner->cleaning_timer);
619 cleaner->acache->live_cleaners--;
620 DESTROYLOCK(&cleaner->lock);
626 begin_cleaning(acache_cleaner_t *cleaner) {
628 dns_acache_t *acache = cleaner->acache;
631 * This function does not have to lock the cleaner, since critical
636 REQUIRE(CLEANER_IDLE(cleaner));
638 INSIST(cleaner->current_entry == NULL);
643 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
649 dns_acache_attachentry(head, &cleaner->current_entry);
653 if (cleaner->current_entry != NULL) {
654 cleaner->ncleaned = 0;
655 cleaner->state = cleaner_s_busy;
656 isc_task_send(acache->task, &cleaner->resched_event);
663 end_cleaning(acache_cleaner_t *cleaner, isc_event_t *event) {
664 dns_acache_t *acache = cleaner->acache;
666 REQUIRE(CLEANER_BUSY(cleaner));
668 REQUIRE(DNS_ACACHEENTRY_VALID(cleaner->current_entry));
670 /* No need to lock the cleaner (see begin_cleaning()). */
675 * Even if the cleaner has the last reference to the entry, which means
679 if (isc_refcount_current(&cleaner->current_entry->references) == 1) {
680 INSIST(cleaner->current_entry->callback == NULL);
682 if (ISC_LINK_LINKED(cleaner->current_entry, link)) {
684 cleaner->current_entry, link);
687 dns_acache_detachentry(&cleaner->current_entry);
689 if (cleaner->overmem)
691 acache->stats.cleaned += cleaner->ncleaned;
709 isc_stdtime_get(&cleaner->last_cleanup_time);
713 dns_acache_setcleaninginterval(cleaner->acache,
714 cleaner->cleaning_interval);
719 cleaner->ncleaned,
720 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
722 if (cleaner->overmem) {
729 cleaner->ncleaned = 0;
730 cleaner->state = cleaner_s_idle;
731 cleaner->resched_event = event;
740 acache_cleaner_t *cleaner = event->ev_arg;
748 "cleaner state = %d", cleaner->state);
750 if (cleaner->state == cleaner_s_idle)
751 begin_cleaning(cleaner);
758 entry_stale(acache_cleaner_t *cleaner, dns_acacheentry_t *entry,
768 if (interval > cleaner->cleaning_interval)
769 interval = cleaner->cleaning_interval;
779 if (cleaner->overmem) {
804 acache_cleaner_t *cleaner = event->ev_arg;
805 dns_acache_t *acache = cleaner->acache;
816 if (cleaner->state == cleaner_s_done) {
817 cleaner->state = cleaner_s_busy;
818 end_cleaning(cleaner, event);
822 INSIST(CLEANER_BUSY(cleaner));
824 n_entries = cleaner->increment;
831 entry = cleaner->current_entry;
832 isc_stdtime_convert32(cleaner->last_cleanup_time, &last32);
848 is_stale = entry_stale(cleaner, entry, now32, interval);
856 cleaner->ncleaned++;
866 if (cleaner->overmem) {
881 "acache cleaner: "
890 end_cleaning(cleaner, event);
904 dns_acache_detachentry(&cleaner->current_entry);
905 dns_acache_attachentry(next, &cleaner->current_entry);
910 ISC_LOG_DEBUG(1), "acache cleaner: checked %d entries, "
911 "mem inuse %lu, sleeping", cleaner->increment,
912 (unsigned long)isc_mem_inuse(cleaner->acache->mctx));
915 INSIST(CLEANER_BUSY(cleaner));
926 acache_cleaner_t *cleaner = event->ev_arg;
932 INSIST(cleaner->overmem_event == NULL);
936 "overmem = %d, state = %d", cleaner->overmem,
937 cleaner->state);
939 LOCK(&cleaner->lock);
941 if (cleaner->overmem) {
942 if (cleaner->state == cleaner_s_idle)
945 if (cleaner->state == cleaner_s_busy)
948 * then both cleaner->overmem_event and
949 * cleaner->resched_event will point to this
954 cleaner->state = cleaner_s_done;
957 cleaner->overmem_event = event;
959 UNLOCK(&cleaner->lock);
962 begin_cleaning(cleaner);
978 LOCK(&acache->cleaner.lock);
980 if (acache->cleaner.overmem != overmem) {
981 acache->cleaner.overmem = overmem;
983 if (acache->cleaner.overmem_event != NULL)
985 &acache->cleaner.overmem_event);
989 UNLOCK(&acache->cleaner.lock);
993 * The cleaner task is shutting down; do the necessary cleanup.
1004 ATRACE("acache cleaner shutdown");
1006 if (CLEANER_BUSY(&acache->cleaner))
1007 end_cleaning(&acache->cleaner, event);
1026 if (acache->cleaner.cleaning_timer != NULL)
1027 isc_timer_detach(&acache->cleaner.cleaning_timer);
1121 result = acache_cleaner_init(acache, timermgr, &acache->cleaner);
1190 * If we're exiting and the cleaner task exists, let it free the cache.
1319 if (acache->cleaner.current_entry != entry)
1330 if (acache->cleaner.current_entry != entry)
1338 if (acache->cleaner.current_entry != entry)
1349 if (acache->cleaner.current_entry != entry)
1387 * example, if the cleaner does not run aggressively enough),
1390 * XXXSK: It might be better to lock the acache->cleaner->lock,
1397 if (acache->cleaner.overmem) {
1749 if (acache->cleaner.cleaning_timer == NULL)
1752 acache->cleaner.cleaning_interval = t;
1755 result = isc_timer_reset(acache->cleaner.cleaning_timer,
1759 isc_interval_set(&interval, acache->cleaner.cleaning_interval,
1761 result = isc_timer_reset(acache->cleaner.cleaning_timer,