lib/libvarnishapi/vsl_dispatch.c
static enum vsl_status
vtx_append(struct VSLQ *vslq, struct vtx *vtx, const struct VSLC_ptr *start,
    size_t len)
{
	struct chunk *chunk;
	enum vsl_check i;

	AN(vtx);
	AN(len);
	AN(start);

	i = VSL_Check(vslq->c, start);
	if (i == vsl_check_e_inval)
		return (vsl_e_overrun);

	if (i == vsl_check_valid && !VTAILQ_EMPTY(&vtx->shmchunks_free)) {
		/* Shmref it */
		chunk = VTAILQ_FIRST(&vtx->shmchunks_free);
		CHECK_OBJ_NOTNULL(chunk, CHUNK_MAGIC);
		assert(chunk->type == chunk_t_shm);
		assert(chunk->vtx == vtx);
		VTAILQ_REMOVE(&vtx->shmchunks_free, chunk, list);
		chunk->shm.start = *start;
		chunk->len = len;
		VTAILQ_INSERT_TAIL(&vtx->chunks, chunk, list);

		/* Append to shmref list */
		VTAILQ_INSERT_TAIL(&vslq->shmrefs, chunk, shm.shmref);
	} else {
		/* Buffer it */
		chunk = VTAILQ_LAST(&vtx->chunks, chunkhead);
		CHECK_OBJ_ORNULL(chunk, CHUNK_MAGIC);
		if (chunk != NULL && chunk->type == chunk_t_buf) {
			/* Tail is a buf chunk, append to that */
			chunk_appendbuf(chunk, start->ptr, len);
		} else {
			/* Append new buf chunk */
			chunk = chunk_newbuf(vtx, start->ptr, len);
			AN(chunk);
			VTAILQ_INSERT_TAIL(&vtx->chunks, chunk, list);
		}
	}
	vtx->len += len;
	return (vsl_more);
}
/* Append a set of records to a vtx structure */
Append a set of records to a vtx structure
Append a set of records to a vtx structure
static enum vsl_status
vtx_append(struct VSLQ *vslq, struct vtx *vtx, const struct VSLC_ptr *start,
    size_t len)
{
	struct chunk *chunk;
	enum vsl_check i;
	AN(vtx);
	AN(len);
	AN(start);
	i = VSL_Check(vslq->c, start);
	if (i == vsl_check_e_inval)
		return (vsl_e_overrun);
	if (i == vsl_check_valid && !VTAILQ_EMPTY(&vtx->shmchunks_free)) {
		chunk = VTAILQ_FIRST(&vtx->shmchunks_free);
		CHECK_OBJ_NOTNULL(chunk, CHUNK_MAGIC);
		assert(chunk->type == chunk_t_shm);
		assert(chunk->vtx == vtx);
		VTAILQ_REMOVE(&vtx->shmchunks_free, chunk, list);
		chunk->shm.start = *start;
		chunk->len = len;
		VTAILQ_INSERT_TAIL(&vtx->chunks, chunk, list);
		VTAILQ_INSERT_TAIL(&vslq->shmrefs, chunk, shm.shmref);
	} else {
		chunk = VTAILQ_LAST(&vtx->chunks, chunkhead);
		CHECK_OBJ_ORNULL(chunk, CHUNK_MAGIC);
		if (chunk != NULL && chunk->type == chunk_t_buf) {
			chunk_appendbuf(chunk, start->ptr, len);
		} else {
			chunk = chunk_newbuf(vtx, start->ptr, len);
			AN(chunk);
			VTAILQ_INSERT_TAIL(&vtx->chunks, chunk, list);
		}
	}
	vtx->len += len;
	return (vsl_more);
}
static enum vsl_status vtx_append ( struct VSLQ * vslq , struct vtx * vtx , const struct VSLC_ptr * start , size_t len ) { struct chunk * chunk ; enum vsl_check i ; AN ( vtx ) ; AN ( len ) ; AN ( start ) ; i = VSL_Check ( vslq -> c , start ) ; if ( i == vsl_check_e_inval ) return ( vsl_e_overrun ) ; if ( i == vsl_check_valid && ! VTAILQ_EMPTY ( & vtx -> shmchunks_free ) ) { chunk = VTAILQ_FIRST ( & vtx -> shmchunks_free ) ; CHECK_OBJ_NOTNULL ( chunk , CHUNK_MAGIC ) ; assert ( chunk -> type == chunk_t_shm ) ; assert ( chunk -> vtx == vtx ) ; VTAILQ_REMOVE ( & vtx -> shmchunks_free , chunk , list ) ; chunk -> shm . start = * start ; chunk -> len = len ; VTAILQ_INSERT_TAIL ( & vtx -> chunks , chunk , list ) ; VTAILQ_INSERT_TAIL ( & vslq -> shmrefs , chunk , shm . shmref ) ; } else { chunk = VTAILQ_LAST ( & vtx -> chunks , chunkhead ) ; CHECK_OBJ_ORNULL ( chunk , CHUNK_MAGIC ) ; if ( chunk != NULL && chunk -> type == chunk_t_buf ) { chunk_appendbuf ( chunk , start -> ptr , len ) ; } else { chunk = chunk_newbuf ( vtx , start -> ptr , len ) ; AN ( chunk ) ; VTAILQ_INSERT_TAIL ( & vtx -> chunks , chunk , list ) ; } } vtx -> len += len ; return ( vsl_more ) ; }
Append a set of records to a vtx structure
Append a set of records to a vtx structure
/* Shmref it */ /* Append to shmref list */ /* Buffer it */ /* Tail is a buf chunk, append to that */ /* Append new buf chunk */