/* * TODO: last waiter frees descriptor ? */ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cache_descr *descr) { struct page_cache *pg_cache = &ctx->pg_cache; Pvoid_t *PValue; struct pg_cache_page_index *page_index; int ret; uv_rwlock_rdlock(&pg_cache->metrics_index.lock); PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, descr->id, sizeof(uuid_t)); assert(NULL != PValue); page_index = *PValue; uv_rwlock_rdunlock(&pg_cache->metrics_index.lock); uv_rwlock_wrlock(&page_index->lock); ret = JudyLDel(&page_index->JudyL_array, (Word_t)(descr->start_time / USEC_PER_SEC), PJE0); uv_rwlock_wrunlock(&page_index->lock); if (unlikely(0 == ret)) { error("Page under deletion was not in index."); if (unlikely(debug_flags & D_RRDENGINE)) print_page_cache_descr(descr); goto destroy; } assert(1 == ret); uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock); ++ctx->stats.pg_cache_deletions; --pg_cache->page_descriptors; uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock); uv_mutex_lock(&descr->mutex); while (!pg_cache_try_get_unsafe(descr, 1)) { debug(D_RRDENGINE, "%s: Waiting for locked page:", __func__); if(unlikely(debug_flags & D_RRDENGINE)) print_page_cache_descr(descr); pg_cache_wait_event_unsafe(descr); } /* even a locked page could be dirty */ while (unlikely(descr->flags & RRD_PAGE_DIRTY)) { debug(D_RRDENGINE, "%s: Found dirty page, waiting for it to be flushed:", __func__); if (unlikely(debug_flags & D_RRDENGINE)) print_page_cache_descr(descr); pg_cache_wait_event_unsafe(descr); } uv_mutex_unlock(&descr->mutex); if (descr->flags & RRD_PAGE_POPULATED) { /* only after locking can it be safely deleted from LRU */ pg_cache_replaceQ_delete(ctx, descr); uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock); pg_cache_evict_unsafe(ctx, descr); uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock); } pg_cache_put(descr); destroy: pg_cache_destroy_descr(descr); pg_cache_update_metric_times(page_index); }
void flx_collector_t::unlink(void *fp) { // check we have a pointer to an object assert(fp!=NULL); // call the finaliser if there is one //fprintf(stderr,"Calling finaliser\n"); impl_finalise(fp); allocation_count--; gc_shape_t *shape = get_shape(fp); unsigned long n_objects = get_count(fp); unsigned long nobj = shape -> count * n_objects; std::size_t size = shape->amt * nobj; //fprintf(stderr, "Uncounting %ld bytes\n", long(size)); allocation_amt -= size; // unlink the frame from the collectors list //fprintf(stderr,"Removing address from Judy lists\n"); JudyLDel(&j_shape, (Word_t)fp, &je); JudyLDel(&j_nused, (Word_t)fp, &je); JudyLDel(&j_nalloc, (Word_t)fp, &je); //fprintf(stderr,"Finished unlinking\n"); }