lib/libvarnishapi/vsl_dispatch.c
static int
vtx_scan_link(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
{
	int i;
	enum VSL_transaction_e c_type;
	enum VSL_reason_e c_reason;
	unsigned c_vxid;
	struct vtx *c_vtx;

	assert(VSL_TAG(ptr) == SLT_Link);

	AZ(vtx->flags & VTX_F_READY);

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

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

	if (c_vxid == 0)
		return (vtx_diag_tag(vtx, ptr, "illegal link vxid"));
	if (c_vxid == vtx->key.vxid)
		return (vtx_diag_tag(vtx, ptr, "link to self"));

	/* Lookup and check child vtx */
	c_vtx = vtx_lookup(vslq, c_vxid);
	if (c_vtx == NULL) {
		/* Child not seen before. Insert it and create link */
		c_vtx = vtx_add(vslq, c_vxid);
		AN(c_vtx);
		AZ(c_vtx->parent);
		c_vtx->type = c_type;
		c_vtx->reason = c_reason;
		vtx_set_parent(vtx, c_vtx);
		return (0);
	}

	CHECK_OBJ_NOTNULL(c_vtx, VTX_MAGIC);
	if (c_vtx->parent == vtx)
		/* Link already exists */
		return (0);
	if (c_vtx->parent != NULL && c_vtx->parent != vtx)
		return (vtx_diag_tag(vtx, ptr, "duplicate link"));
	if (c_vtx->flags & VTX_F_COMPLETE)
		return (vtx_diag_tag(vtx, ptr, "link too late"));
	if (c_vtx->type != VSL_t_unknown && c_vtx->type != c_type)
		(void)vtx_diag_tag(vtx, ptr, "type mismatch");

	c_vtx->type = c_type;
	c_vtx->reason = c_reason;
	vtx_set_parent(vtx, c_vtx);
	return (0);
}
/* Parse and process a link record */
Parse and process a link record
Parse and process a link record
static int
vtx_scan_link(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
{
	int i;
	enum VSL_transaction_e c_type;
	enum VSL_reason_e c_reason;
	unsigned c_vxid;
	struct vtx *c_vtx;
	assert(VSL_TAG(ptr) == SLT_Link);
	AZ(vtx->flags & VTX_F_READY);
	i = vtx_parse_link(VSL_CDATA(ptr), &c_type, &c_vxid, &c_reason);
	if (i != 3)
		return (vtx_diag_tag(vtx, ptr, "parse error"));
	if (c_type == VSL_t_unknown)
		(void)vtx_diag_tag(vtx, ptr, "unknown vxid type");
	if (vslq->grouping == VSL_g_vxid)
		return (0);	
	if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_sess)
		return (0);	
	if (c_vxid == 0)
		return (vtx_diag_tag(vtx, ptr, "illegal link vxid"));
	if (c_vxid == vtx->key.vxid)
		return (vtx_diag_tag(vtx, ptr, "link to self"));
	c_vtx = vtx_lookup(vslq, c_vxid);
	if (c_vtx == NULL) {
		c_vtx = vtx_add(vslq, c_vxid);
		AN(c_vtx);
		AZ(c_vtx->parent);
		c_vtx->type = c_type;
		c_vtx->reason = c_reason;
		vtx_set_parent(vtx, c_vtx);
		return (0);
	}
	CHECK_OBJ_NOTNULL(c_vtx, VTX_MAGIC);
	if (c_vtx->parent == vtx)
		return (0);
	if (c_vtx->parent != NULL && c_vtx->parent != vtx)
		return (vtx_diag_tag(vtx, ptr, "duplicate link"));
	if (c_vtx->flags & VTX_F_COMPLETE)
		return (vtx_diag_tag(vtx, ptr, "link too late"));
	if (c_vtx->type != VSL_t_unknown && c_vtx->type != c_type)
		(void)vtx_diag_tag(vtx, ptr, "type mismatch");
	c_vtx->type = c_type;
	c_vtx->reason = c_reason;
	vtx_set_parent(vtx, c_vtx);
	return (0);
}
static int vtx_scan_link ( struct VSLQ * vslq , struct vtx * vtx , const uint32_t * ptr ) { int i ; enum VSL_transaction_e c_type ; enum VSL_reason_e c_reason ; unsigned c_vxid ; struct vtx * c_vtx ; assert ( VSL_TAG ( ptr ) == SLT_Link ) ; AZ ( vtx -> flags & VTX_F_READY ) ; i = vtx_parse_link ( VSL_CDATA ( ptr ) , & c_type , & c_vxid , & c_reason ) ; if ( i != 3 ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( c_type == VSL_t_unknown ) ( void ) vtx_diag_tag ( vtx , ptr , " " ) ; if ( vslq -> grouping == VSL_g_vxid ) return ( 0 ) ; if ( vslq -> grouping == VSL_g_request && vtx -> type == VSL_t_sess ) return ( 0 ) ; if ( c_vxid == 0 ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( c_vxid == vtx -> key . vxid ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; c_vtx = vtx_lookup ( vslq , c_vxid ) ; if ( c_vtx == NULL ) { c_vtx = vtx_add ( vslq , c_vxid ) ; AN ( c_vtx ) ; AZ ( c_vtx -> parent ) ; c_vtx -> type = c_type ; c_vtx -> reason = c_reason ; vtx_set_parent ( vtx , c_vtx ) ; return ( 0 ) ; } CHECK_OBJ_NOTNULL ( c_vtx , VTX_MAGIC ) ; if ( c_vtx -> parent == vtx ) return ( 0 ) ; if ( c_vtx -> parent != NULL && c_vtx -> parent != vtx ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( c_vtx -> flags & VTX_F_COMPLETE ) return ( vtx_diag_tag ( vtx , ptr , " " ) ) ; if ( c_vtx -> type != VSL_t_unknown && c_vtx -> type != c_type ) ( void ) vtx_diag_tag ( vtx , ptr , " " ) ; c_vtx -> type = c_type ; c_vtx -> reason = c_reason ; vtx_set_parent ( vtx , c_vtx ) ; return ( 0 ) ; }
Parse and process a link record
Parse and process a link record
/* No links */ /* No links */ /* Lookup and check child vtx */ /* Child not seen before. Insert it and create link */ /* Link already exists */