lib/libvarnishapi/vsl_dispatch.c
static void
vtx_retire(struct VSLQ *vslq, struct vtx **pvtx)
{
	struct vtx *vtx;
	struct vtx *child;
	struct synth *synth;
	struct chunk *chunk;

	AN(vslq);
	TAKE_OBJ_NOTNULL(vtx, pvtx, VTX_MAGIC);

	AN(vtx->flags & VTX_F_COMPLETE);
	AN(vtx->flags & VTX_F_READY);
	AZ(vtx->parent);

	while (!VTAILQ_EMPTY(&vtx->child)) {
		child = VTAILQ_FIRST(&vtx->child);
		assert(child->parent == vtx);
		AN(vtx->n_child);
		assert(vtx->n_descend >= child->n_descend + 1);
		VTAILQ_REMOVE(&vtx->child, child, list_child);
		child->parent = NULL;
		vtx->n_child--;
		vtx->n_descend -= child->n_descend + 1;
		vtx_retire(vslq, &child);
		AZ(child);
	}
	AZ(vtx->n_child);
	AZ(vtx->n_descend);
	vtx->n_childready = 0;
	AN(VRBT_REMOVE(vtx_tree, &vslq->tree, &vtx->key));
	vtx->key.vxid = 0;
	vtx->flags = 0;

	while (!VTAILQ_EMPTY(&vtx->synth)) {
		synth = VTAILQ_FIRST(&vtx->synth);
		CHECK_OBJ_NOTNULL(synth, SYNTH_MAGIC);
		VTAILQ_REMOVE(&vtx->synth, synth, list);
		FREE_OBJ(synth);
	}

	while (!VTAILQ_EMPTY(&vtx->chunks)) {
		chunk = VTAILQ_FIRST(&vtx->chunks);
		CHECK_OBJ_NOTNULL(chunk, CHUNK_MAGIC);
		VTAILQ_REMOVE(&vtx->chunks, chunk, list);
		if (chunk->type == chunk_t_shm) {
			VTAILQ_REMOVE(&vslq->shmrefs, chunk, shm.shmref);
			VTAILQ_INSERT_HEAD(&vtx->shmchunks_free, chunk, list);
		} else {
			assert(chunk->type == chunk_t_buf);
			chunk_freebuf(&chunk);
			AZ(chunk);
		}
	}
	vtx->len = 0;
	AN(vslq->n_outstanding);
	vslq->n_outstanding--;

	if (vslq->n_cache < VTX_CACHE) {
		VTAILQ_INSERT_HEAD(&vslq->cache, vtx, list_child);
		vslq->n_cache++;
	} else
		FREE_OBJ(vtx);

}
/* Disuse a vtx and all it's children, freeing any resources held. Free or
   cache the vtx for later use */
Disuse a vtx and all it's children, freeing any resources held. Free or
cache the vtx for later use
Disuse a vtx and all it ' s children freeing any resources held . Free or cache the vtx for later use
static void
vtx_retire(struct VSLQ *vslq, struct vtx **pvtx)
{
	struct vtx *vtx;
	struct vtx *child;
	struct synth *synth;
	struct chunk *chunk;
	AN(vslq);
	TAKE_OBJ_NOTNULL(vtx, pvtx, VTX_MAGIC);
	AN(vtx->flags & VTX_F_COMPLETE);
	AN(vtx->flags & VTX_F_READY);
	AZ(vtx->parent);
	while (!VTAILQ_EMPTY(&vtx->child)) {
		child = VTAILQ_FIRST(&vtx->child);
		assert(child->parent == vtx);
		AN(vtx->n_child);
		assert(vtx->n_descend >= child->n_descend + 1);
		VTAILQ_REMOVE(&vtx->child, child, list_child);
		child->parent = NULL;
		vtx->n_child--;
		vtx->n_descend -= child->n_descend + 1;
		vtx_retire(vslq, &child);
		AZ(child);
	}
	AZ(vtx->n_child);
	AZ(vtx->n_descend);
	vtx->n_childready = 0;
	AN(VRBT_REMOVE(vtx_tree, &vslq->tree, &vtx->key));
	vtx->key.vxid = 0;
	vtx->flags = 0;
	while (!VTAILQ_EMPTY(&vtx->synth)) {
		synth = VTAILQ_FIRST(&vtx->synth);
		CHECK_OBJ_NOTNULL(synth, SYNTH_MAGIC);
		VTAILQ_REMOVE(&vtx->synth, synth, list);
		FREE_OBJ(synth);
	}
	while (!VTAILQ_EMPTY(&vtx->chunks)) {
		chunk = VTAILQ_FIRST(&vtx->chunks);
		CHECK_OBJ_NOTNULL(chunk, CHUNK_MAGIC);
		VTAILQ_REMOVE(&vtx->chunks, chunk, list);
		if (chunk->type == chunk_t_shm) {
			VTAILQ_REMOVE(&vslq->shmrefs, chunk, shm.shmref);
			VTAILQ_INSERT_HEAD(&vtx->shmchunks_free, chunk, list);
		} else {
			assert(chunk->type == chunk_t_buf);
			chunk_freebuf(&chunk);
			AZ(chunk);
		}
	}
	vtx->len = 0;
	AN(vslq->n_outstanding);
	vslq->n_outstanding--;
	if (vslq->n_cache < VTX_CACHE) {
		VTAILQ_INSERT_HEAD(&vslq->cache, vtx, list_child);
		vslq->n_cache++;
	} else
		FREE_OBJ(vtx);
}
static void vtx_retire ( struct VSLQ * vslq , struct vtx * * pvtx ) { struct vtx * vtx ; struct vtx * child ; struct synth * synth ; struct chunk * chunk ; AN ( vslq ) ; TAKE_OBJ_NOTNULL ( vtx , pvtx , VTX_MAGIC ) ; AN ( vtx -> flags & VTX_F_COMPLETE ) ; AN ( vtx -> flags & VTX_F_READY ) ; AZ ( vtx -> parent ) ; while ( ! VTAILQ_EMPTY ( & vtx -> child ) ) { child = VTAILQ_FIRST ( & vtx -> child ) ; assert ( child -> parent == vtx ) ; AN ( vtx -> n_child ) ; assert ( vtx -> n_descend >= child -> n_descend + 1 ) ; VTAILQ_REMOVE ( & vtx -> child , child , list_child ) ; child -> parent = NULL ; vtx -> n_child -- ; vtx -> n_descend -= child -> n_descend + 1 ; vtx_retire ( vslq , & child ) ; AZ ( child ) ; } AZ ( vtx -> n_child ) ; AZ ( vtx -> n_descend ) ; vtx -> n_childready = 0 ; AN ( VRBT_REMOVE ( vtx_tree , & vslq -> tree , & vtx -> key ) ) ; vtx -> key . vxid = 0 ; vtx -> flags = 0 ; while ( ! VTAILQ_EMPTY ( & vtx -> synth ) ) { synth = VTAILQ_FIRST ( & vtx -> synth ) ; CHECK_OBJ_NOTNULL ( synth , SYNTH_MAGIC ) ; VTAILQ_REMOVE ( & vtx -> synth , synth , list ) ; FREE_OBJ ( synth ) ; } while ( ! VTAILQ_EMPTY ( & vtx -> chunks ) ) { chunk = VTAILQ_FIRST ( & vtx -> chunks ) ; CHECK_OBJ_NOTNULL ( chunk , CHUNK_MAGIC ) ; VTAILQ_REMOVE ( & vtx -> chunks , chunk , list ) ; if ( chunk -> type == chunk_t_shm ) { VTAILQ_REMOVE ( & vslq -> shmrefs , chunk , shm . shmref ) ; VTAILQ_INSERT_HEAD ( & vtx -> shmchunks_free , chunk , list ) ; } else { assert ( chunk -> type == chunk_t_buf ) ; chunk_freebuf ( & chunk ) ; AZ ( chunk ) ; } } vtx -> len = 0 ; AN ( vslq -> n_outstanding ) ; vslq -> n_outstanding -- ; if ( vslq -> n_cache < VTX_CACHE ) { VTAILQ_INSERT_HEAD ( & vslq -> cache , vtx , list_child ) ; vslq -> n_cache ++ ; } else FREE_OBJ ( vtx ) ; }
Disuse a vtx and all it's children, freeing any resources held.
Disuse a vtx and all it ' s children freeing any resources held .