lib/libvarnishapi/vsl_dispatch.c
static int
vtx_scan_begin(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
{
	int i;
	enum VSL_transaction_e type;
	enum VSL_reason_e reason;
	unsigned p_vxid;
	struct vtx *p_vtx;

	assert(VSL_TAG(ptr) == SLT_Begin);

	AZ(vtx->flags & VTX_F_READY);

	i = vtx_parse_link(VSL_CDATA(ptr), &type, &p_vxid, &reason);
	if (i != 3)
		return (vtx_diag_tag(vtx, ptr, "parse error"));
	if (type == VSL_t_unknown)
		(void)vtx_diag_tag(vtx, ptr, "unknown vxid type");

	/* Check/set vtx type */
	if (vtx->type != VSL_t_unknown && vtx->type != type)
		/* Type not matching the one previously set by a link
		   record */
		(void)vtx_diag_tag(vtx, ptr, "type mismatch");
	vtx->type = type;
	vtx->reason = reason;

	if (p_vxid == 0)
		/* Zero means no parent */
		return (0);
	if (p_vxid == vtx->key.vxid)
		return (vtx_diag_tag(vtx, ptr, "link to self"));

	if (vslq->grouping == VSL_g_vxid)
		return (0);	/* No links */
	if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_req &&
	    vtx->reason == VSL_r_rxreq)
		return (0);	/* No links */

	if (vtx->parent != NULL) {
		if (vtx->parent->key.vxid != p_vxid) {
			/* This vtx already belongs to a different
			   parent */
			return (vtx_diag_tag(vtx, ptr, "link mismatch"));
		} else
			/* Link already exists */
			return (0);
	}

	p_vtx = vtx_lookup(vslq, p_vxid);
	if (p_vtx == NULL) {
		/* Not seen parent yet. Create it. */
		p_vtx = vtx_add(vslq, p_vxid);
		AN(p_vtx);
	} else {
		CHECK_OBJ_NOTNULL(p_vtx, VTX_MAGIC);
		if (p_vtx->flags & VTX_F_COMPLETE)
			return (vtx_diag_tag(vtx, ptr, "link too late"));
	}

	/* Create link */
	vtx_set_parent(p_vtx, vtx);

	return (0);
}
/* Parse and process a begin record */
Parse and process a begin record
Parse and process a begin record
static int
vtx_scan_begin(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
{
	int i;
	enum VSL_transaction_e type;
	enum VSL_reason_e reason;
	unsigned p_vxid;
	struct vtx *p_vtx;
	assert(VSL_TAG(ptr) == SLT_Begin);
	AZ(vtx->flags & VTX_F_READY);
	i = vtx_parse_link(VSL_CDATA(ptr), &type, &p_vxid, &reason);
	if (i != 3)
		return (vtx_diag_tag(vtx, ptr, "parse error"));
	if (type == VSL_t_unknown)
		(void)vtx_diag_tag(vtx, ptr, "unknown vxid type");
	if (vtx->type != VSL_t_unknown && vtx->type != type)
		(void)vtx_diag_tag(vtx, ptr, "type mismatch");
	vtx->type = type;
	vtx->reason = reason;
	if (p_vxid == 0)
		return (0);
	if (p_vxid == vtx->key.vxid)
		return (vtx_diag_tag(vtx, ptr, "link to self"));
	if (vslq->grouping == VSL_g_vxid)
		return (0);	
	if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_req &&
	    vtx->reason == VSL_r_rxreq)
		return (0);	
	if (vtx->parent != NULL) {
		if (vtx->parent->key.vxid != p_vxid) {
			return (vtx_diag_tag(vtx, ptr, "link mismatch"));
		} else
			return (0);
	}
	p_vtx = vtx_lookup(vslq, p_vxid);
	if (p_vtx == NULL) {
		p_vtx = vtx_add(vslq, p_vxid);
		AN(p_vtx);
	} else {
		CHECK_OBJ_NOTNULL(p_vtx, VTX_MAGIC);
		if (p_vtx->flags & VTX_F_COMPLETE)
			return (vtx_diag_tag(vtx, ptr, "link too late"));
	}
	vtx_set_parent(p_vtx, vtx);
	return (0);
}
static int vtx_scan_begin ( struct VSLQ * vslq , struct vtx * vtx , const uint32_t * ptr ) { int i ; enum VSL_transaction_e type ; enum VSL_reason_e reason ; unsigned p_vxid ; struct vtx * p_vtx ; assert ( VSL_TAG ( ptr ) == SLT_Begin ) ; AZ ( vtx -> flags & VTX_F_READY ) ; i = vtx_parse_link ( VSL_CDATA ( ptr ) , & type , & p_vxid , & reason ) ; if ( i != 3 ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( type == VSL_t_unknown ) ( void ) vtx_diag_tag ( vtx , ptr , " " ) ; if ( vtx -> type != VSL_t_unknown && vtx -> type != type ) ( void ) vtx_diag_tag ( vtx , ptr , " " ) ; vtx -> type = type ; vtx -> reason = reason ; if ( p_vxid == 0 ) return ( 0 ) ; if ( p_vxid == vtx -> key . vxid ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( vslq -> grouping == VSL_g_vxid ) return ( 0 ) ; if ( vslq -> grouping == VSL_g_request && vtx -> type == VSL_t_req && vtx -> reason == VSL_r_rxreq ) return ( 0 ) ; if ( vtx -> parent != NULL ) { if ( vtx -> parent -> key . vxid != p_vxid ) { return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; } else return ( 0 ) ; } p_vtx = vtx_lookup ( vslq , p_vxid ) ; if ( p_vtx == NULL ) { p_vtx = vtx_add ( vslq , p_vxid ) ; AN ( p_vtx ) ; } else { CHECK_OBJ_NOTNULL ( p_vtx , VTX_MAGIC ) ; if ( p_vtx -> flags & VTX_F_COMPLETE ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; } vtx_set_parent ( p_vtx , vtx ) ; return ( 0 ) ; }
Parse and process a begin record
Parse and process a begin record
/* Check/set vtx type */ /* Type not matching the one previously set by a link
		   record */ /* Zero means no parent */ /* No links */ /* No links */ /* This vtx already belongs to a different
			   parent */ /* Link already exists */ /* Not seen parent yet. Create it. */ /* Create link */