Exemplo n.º 1
0
struct cache_object *cache_update_force(struct cache *c, void *ptr)
{
	struct cache_object *obj;
	int id;

	obj = cache_find(c, ptr, &id);
	if (obj) {
		if (obj->status != C_OBJ_DEAD) {
			cache_update(c, obj, id, ptr);
			return obj;
		} else {
			cache_del(c, obj);
			cache_object_free(obj);
		}
	}
	obj = cache_object_new(c, ptr);
	if (obj == NULL)
		return NULL;

	if (cache_add(c, obj, id) == -1) {
		cache_object_free(obj);
		return NULL;
	}

	return obj;
}
Exemplo n.º 2
0
static int do_flush(void *data, void *n)
{
	struct cache *c = data;
	struct cache_object *obj = n;

	cache_del(c, obj);
	cache_object_free(obj);
	return 0;
}
Exemplo n.º 3
0
int cache_object_put(struct cache_object *obj)
{
	if (--obj->refcnt == 0) {
		cache_del(obj->cache, obj);
		cache_object_free(obj);
		return 1;
	}
	return 0;
}
Exemplo n.º 4
0
static void external_cache_del(struct nf_conntrack *ct)
{
	struct cache_object *obj;
	int id;

	obj = cache_find(external, ct, &id);
	if (obj) {
		cache_del(external, obj);
		cache_object_free(obj);
	}
}
Exemplo n.º 5
0
static void external_cache_new(struct nf_conntrack *ct)
{
	struct cache_object *obj;
	int id;

	obj = cache_find(external, ct, &id);
	if (obj == NULL) {
retry:
		obj = cache_object_new(external, ct);
		if (obj == NULL)
			return;

		if (cache_add(external, obj, id) == -1) {
			cache_object_free(obj);
			return;
		}
	} else {
		cache_del(external, obj);
		cache_object_free(obj);
		goto retry;
	}
}