void item_unlink(item *it) { it->it_flags &= ~ITEM_LINKED; assoc_delete(it->key); item_unlink_q(it); stats.curr_bytes -= it->ntotal; stats.curr_items -= 1; if (it->usecount == 0) free(it); return; }
void item_unlink(item *it) { if (it->it_flags & ITEM_LINKED) { it->it_flags &= ~ITEM_LINKED; stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; assoc_delete(ITEM_key(it)); item_unlink_q(it); } if (it->refcount == 0) item_free(it); }
void item_reuse(struct item *it) { assert(pthread_mutex_trylock(&cache_lock) != 0); assert(it->magic == ITEM_MAGIC); assert(!item_is_slabbed(it)); assert(item_is_linked(it)); assert(it->refcount == 0); it->flags &= ~ITEM_LINKED; assoc_delete(item_key(it), it->nkey); item_unlink_q(it); }
void do_item_unlink(item *it) { // MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items--; assoc_delete(ITEM_key(it), it->nkey); item_unlink_q(it); if (it->refcount == 0) item_free(it); } }
void do_item_unlink(item *it) { if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey); item_unlink_q(it); if (it->refcount == 0) item_free(it); } }
static void _item_unlink(struct item *it) { assert(it->magic == ITEM_MAGIC); assert(item_is_linked(it)); if (item_is_linked(it)) { it->flags &= ~ITEM_LINKED; assoc_delete(item_key(it), it->nkey); item_unlink_q(it); if (it->refcount == 0) { item_free(it); } } }
/* FIXME: Is it necessary to keep this copy/pasted code? */ void do_item_unlink_nolock(item *it, const uint32_t hv) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv); item_unlink_q(it); do_item_remove(it); } }
/* slawek */ void do_item_unlink_nolock_nostat(item *it, const uint32_t hv, uint64_t *items_removed, uint64_t *bytes_removed) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; *items_removed += 1; *bytes_removed += ITEM_ntotal(it); assoc_delete(ITEM_key(it), it->nkey, hv); item_unlink_q(it); do_item_remove(it); } }
/* FIXME: Is it necessary to keep this copy/pasted code? */ void do_item_unlink_nolock(item *it, const uint32_t hv) { syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__); MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv); item_unlink_q(it); do_item_remove(it); } }
//将item从hashtable和LRU链中移除,而且还释放掉 item 所占的内存 (其实只是把 item 放到空闲链表中),是do_item_link的逆操作 void do_item_unlink(item *it, const uint32_t hv) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); mutex_lock(&cache_lock);//执行同步 if ((it->it_flags & ITEM_LINKED) != 0) {//判断状态值,保证item还在LRU队列中 it->it_flags &= ~ITEM_LINKED;//修改状态值 STATS_LOCK();//更新统计信息 stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv);//从Hash表中删除 item_unlink_q(it);//将item从slabclass对应的LRU队列摘除 do_item_remove(it);//释放 item 所占的内存 } mutex_unlock(&cache_lock); }
void do_item_unlink(item *it, const uint32_t hv) { syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__); MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); mutex_lock(&cache_lock); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED;//设置为非linked STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv); //从hash表中删除 item_unlink_q(it); //从LRU链中删除 do_item_remove(it); } mutex_unlock(&cache_lock); }
void do_item_unlink(item *it) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey); item_unlink_q(it); #ifndef MOXI_ITEM_MALLOC if (it->refcount == 0) item_free(it); #endif } }
void do_item_unlink(struct default_engine *engine, hash_item *it) { MEMCACHED_ITEM_UNLINK(item_get_key(it), it->nkey, it->nbytes); if ((it->iflag & ITEM_LINKED) != 0) { it->iflag &= ~ITEM_LINKED; pthread_mutex_lock(&engine->stats.lock); engine->stats.curr_bytes -= ITEM_ntotal(engine, it); engine->stats.curr_items -= 1; pthread_mutex_unlock(&engine->stats.lock); assoc_delete(engine, engine->server.core->hash(item_get_key(it), it->nkey, 0), item_get_key(it), it->nkey); item_unlink_q(engine, it); if (it->refcount == 0) { item_free(engine, it); } } }
//从哈希表和LRU中删除 void do_item_unlink(item *it, const uint32_t hv) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); mutex_lock(&cache_lock); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); //从哈希表中删除 assoc_delete(ITEM_key(it), it->nkey, hv); //从链表中删除 item_unlink_q(it); //向slab归还这个item do_item_remove(it); } mutex_unlock(&cache_lock); }
void do_item_unlink(struct default_engine *engine, hash_item *it) { const hash_key* key = item_get_key(it); MEMCACHED_ITEM_UNLINK(hash_key_get_client_key(key), hash_key_get_client_key_len(key), it->nbytes); if ((it->iflag & ITEM_LINKED) != 0) { it->iflag &= ~ITEM_LINKED; cb_mutex_enter(&engine->stats.lock); engine->stats.curr_bytes -= ITEM_ntotal(engine, it); engine->stats.curr_items -= 1; cb_mutex_exit(&engine->stats.lock); assoc_delete(engine, crc32c(hash_key_get_key(key), hash_key_get_key_len(key), 0), key); item_unlink_q(engine, it); if (it->refcount == 0 || engine->scrubber.force_delete) { item_free(engine, it); } } }
void ffi_server_table_delete(struct server_pool *pool, const char *name) { return assoc_delete(pool->server_table, name, strlen(name)); }