lib/libvarnishapi/vsl_dispatch.c
static void
vtx_synth_rec(struct vtx *vtx, unsigned tag, const char *fmt, ...)
{
	struct synth *synth, *it;
	va_list ap;
	char *buf;
	int l, buflen;

	ALLOC_OBJ(synth, SYNTH_MAGIC);
	AN(synth);

	buf = (char *)&synth->data[2];
	buflen = sizeof (synth->data) - 2 * sizeof (uint32_t);
	va_start(ap, fmt);
	l = vsnprintf(buf, buflen, fmt, ap);
	assert(l >= 0);
	va_end(ap);
	if (l > buflen - 1)
		l = buflen - 1;
	buf[l++] = '\0';	/* NUL-terminated */
	synth->data[1] = vtx->key.vxid;
	switch (vtx->type) {
	case VSL_t_req:
		synth->data[1] |= VSL_CLIENTMARKER;
		break;
	case VSL_t_bereq:
		synth->data[1] |= VSL_BACKENDMARKER;
		break;
	default:
		break;
	}
	synth->data[0] = (((tag & 0xff) << 24) | l);
	synth->offset = vtx->c.offset;

	VTAILQ_FOREACH_REVERSE(it, &vtx->synth, synthhead, list) {
		/* Make sure the synth list is sorted on offset */
		CHECK_OBJ_NOTNULL(it, SYNTH_MAGIC);
		if (synth->offset >= it->offset)
			break;
	}
	if (it != NULL)
		VTAILQ_INSERT_AFTER(&vtx->synth, it, synth, list);
	else
		VTAILQ_INSERT_HEAD(&vtx->synth, synth, list);

	/* Update cursor */
	CHECK_OBJ_ORNULL(vtx->c.synth, SYNTH_MAGIC);
	if (vtx->c.synth == NULL || vtx->c.synth->offset > synth->offset)
		vtx->c.synth = synth;
}
/* Create a synthetic log record. The record will be inserted at the
   current cursor offset */
Create a synthetic log record. The record will be inserted at the
current cursor offset
Create a synthetic log record . The record will be inserted at the current cursor offset
static void
vtx_synth_rec(struct vtx *vtx, unsigned tag, const char *fmt, ...)
{
	struct synth *synth, *it;
	va_list ap;
	char *buf;
	int l, buflen;
	ALLOC_OBJ(synth, SYNTH_MAGIC);
	AN(synth);
	buf = (char *)&synth->data[2];
	buflen = sizeof (synth->data) - 2 * sizeof (uint32_t);
	va_start(ap, fmt);
	l = vsnprintf(buf, buflen, fmt, ap);
	assert(l >= 0);
	va_end(ap);
	if (l > buflen - 1)
		l = buflen - 1;
	buf[l++] = '\0';	
	synth->data[1] = vtx->key.vxid;
	switch (vtx->type) {
	case VSL_t_req:
		synth->data[1] |= VSL_CLIENTMARKER;
		break;
	case VSL_t_bereq:
		synth->data[1] |= VSL_BACKENDMARKER;
		break;
	default:
		break;
	}
	synth->data[0] = (((tag & 0xff) << 24) | l);
	synth->offset = vtx->c.offset;
	VTAILQ_FOREACH_REVERSE(it, &vtx->synth, synthhead, list) {
		CHECK_OBJ_NOTNULL(it, SYNTH_MAGIC);
		if (synth->offset >= it->offset)
			break;
	}
	if (it != NULL)
		VTAILQ_INSERT_AFTER(&vtx->synth, it, synth, list);
	else
		VTAILQ_INSERT_HEAD(&vtx->synth, synth, list);
	CHECK_OBJ_ORNULL(vtx->c.synth, SYNTH_MAGIC);
	if (vtx->c.synth == NULL || vtx->c.synth->offset > synth->offset)
		vtx->c.synth = synth;
}
static void vtx_synth_rec ( struct vtx * vtx , unsigned tag , const char * fmt , ... ) { struct synth * synth , * it ; va_list ap ; char * buf ; int l , buflen ; ALLOC_OBJ ( synth , SYNTH_MAGIC ) ; AN ( synth ) ; buf = ( char * ) & synth -> data [ 2 ] ; buflen = sizeof ( synth -> data ) - 2 * sizeof ( uint32_t ) ; va_start ( ap , fmt ) ; l = vsnprintf ( buf , buflen , fmt , ap ) ; assert ( l >= 0 ) ; va_end ( ap ) ; if ( l > buflen - 1 ) l = buflen - 1 ; buf [ l ++ ] = ' \0 ' ; synth -> data [ 1 ] = vtx -> key . vxid ; switch ( vtx -> type ) { case VSL_t_req : synth -> data [ 1 ] |= VSL_CLIENTMARKER ; break ; case VSL_t_bereq : synth -> data [ 1 ] |= VSL_BACKENDMARKER ; break ; default : break ; } synth -> data [ 0 ] = ( ( ( tag & 0xff ) << 24 ) | l ) ; synth -> offset = vtx -> c . offset ; VTAILQ_FOREACH_REVERSE ( it , & vtx -> synth , synthhead , list ) { CHECK_OBJ_NOTNULL ( it , SYNTH_MAGIC ) ; if ( synth -> offset >= it -> offset ) break ; } if ( it != NULL ) VTAILQ_INSERT_AFTER ( & vtx -> synth , it , synth , list ) ; else VTAILQ_INSERT_HEAD ( & vtx -> synth , synth , list ) ; CHECK_OBJ_ORNULL ( vtx -> c . synth , SYNTH_MAGIC ) ; if ( vtx -> c . synth == NULL || vtx -> c . synth -> offset > synth -> offset ) vtx -> c . synth = synth ; }
Create a synthetic log record.
Create a synthetic log record .
/* NUL-terminated */ /* Make sure the synth list is sorted on offset */ /* Update cursor */