lib/libvarnishapi/vsl_dispatch.c
static int
vslq_callback(struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func,
    void *priv)
{
	unsigned n = vtx->n_descend + 1;
	struct vtx *vtxs[n];
	struct VSL_transaction trans[n];
	struct VSL_transaction *ptrans[n + 1];
	unsigned i, j;

	AN(vslq);
	CHECK_OBJ_NOTNULL(vtx, VTX_MAGIC);
	AN(vtx->flags & VTX_F_READY);
	AN(func);

	if (vslq->grouping == VSL_g_session &&
	    vtx->type != VSL_t_sess)
		return (0);
	if (vslq->grouping == VSL_g_request &&
	    vtx->type != VSL_t_req)
		return (0);

	/* Build transaction array */
	AN(vslc_vtx_reset(&vtx->c.cursor) == vsl_end);
	vtxs[0] = vtx;
	trans[0].level = 1;
	trans[0].vxid = vtx->key.vxid;
	trans[0].vxid_parent = 0;
	trans[0].type = vtx->type;
	trans[0].reason = vtx->reason;
	trans[0].c = &vtx->c.cursor;
	i = 1;
	j = 0;
	while (j < i) {
		VTAILQ_FOREACH(vtx, &vtxs[j]->child, list_child) {
			assert(i < n);
			AN(vslc_vtx_reset(&vtx->c.cursor) == vsl_end);
			vtxs[i] = vtx;
			if (vtx->reason == VSL_r_restart)
				/* Restarts stay at the same level as parent */
				trans[i].level = trans[j].level;
			else
				trans[i].level = trans[j].level + 1;
			trans[i].vxid = vtx->key.vxid;
			trans[i].vxid_parent = trans[j].vxid;
			trans[i].type = vtx->type;
			trans[i].reason = vtx->reason;
			trans[i].c = &vtx->c.cursor;
			i++;
		}
		j++;
	}
	assert(i == n);

	/* Build pointer array */
	for (i = 0; i < n; i++)
		ptrans[i] = &trans[i];
	ptrans[i] = NULL;

	/* Query test goes here */
	if (vslq->query != NULL && !vslq_runquery(vslq->query, ptrans))
		return (0);

	if (vslq->vsl->R_opt_l != 0 && !vslq_ratelimit(vslq))
		return (0);

	/* Callback */
	return ((func)(vslq->vsl, ptrans, priv));
}
/* Build transaction array, do the query and callback. Returns 0 or the
   return value from func */
Build transaction array, do the query and callback. Returns 0 or the
return value from func
Build transaction array do the query and callback . Returns 0 or the return value from func
static int
vslq_callback(struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func,
    void *priv)
{
	unsigned n = vtx->n_descend + 1;
	struct vtx *vtxs[n];
	struct VSL_transaction trans[n];
	struct VSL_transaction *ptrans[n + 1];
	unsigned i, j;
	AN(vslq);
	CHECK_OBJ_NOTNULL(vtx, VTX_MAGIC);
	AN(vtx->flags & VTX_F_READY);
	AN(func);
	if (vslq->grouping == VSL_g_session &&
	    vtx->type != VSL_t_sess)
		return (0);
	if (vslq->grouping == VSL_g_request &&
	    vtx->type != VSL_t_req)
		return (0);
	AN(vslc_vtx_reset(&vtx->c.cursor) == vsl_end);
	vtxs[0] = vtx;
	trans[0].level = 1;
	trans[0].vxid = vtx->key.vxid;
	trans[0].vxid_parent = 0;
	trans[0].type = vtx->type;
	trans[0].reason = vtx->reason;
	trans[0].c = &vtx->c.cursor;
	i = 1;
	j = 0;
	while (j < i) {
		VTAILQ_FOREACH(vtx, &vtxs[j]->child, list_child) {
			assert(i < n);
			AN(vslc_vtx_reset(&vtx->c.cursor) == vsl_end);
			vtxs[i] = vtx;
			if (vtx->reason == VSL_r_restart)
				trans[i].level = trans[j].level;
			else
				trans[i].level = trans[j].level + 1;
			trans[i].vxid = vtx->key.vxid;
			trans[i].vxid_parent = trans[j].vxid;
			trans[i].type = vtx->type;
			trans[i].reason = vtx->reason;
			trans[i].c = &vtx->c.cursor;
			i++;
		}
		j++;
	}
	assert(i == n);
	for (i = 0; i < n; i++)
		ptrans[i] = &trans[i];
	ptrans[i] = NULL;
	if (vslq->query != NULL && !vslq_runquery(vslq->query, ptrans))
		return (0);
	if (vslq->vsl->R_opt_l != 0 && !vslq_ratelimit(vslq))
		return (0);
	return ((func)(vslq->vsl, ptrans, priv));
}
static int vslq_callback ( struct VSLQ * vslq , struct vtx * vtx , VSLQ_dispatch_f * func , void * priv ) { unsigned n = vtx -> n_descend + 1 ; struct vtx * vtxs [ n ] ; struct VSL_transaction trans [ n ] ; struct VSL_transaction * ptrans [ n + 1 ] ; unsigned i , j ; AN ( vslq ) ; CHECK_OBJ_NOTNULL ( vtx , VTX_MAGIC ) ; AN ( vtx -> flags & VTX_F_READY ) ; AN ( func ) ; if ( vslq -> grouping == VSL_g_session && vtx -> type != VSL_t_sess ) return ( 0 ) ; if ( vslq -> grouping == VSL_g_request && vtx -> type != VSL_t_req ) return ( 0 ) ; AN ( vslc_vtx_reset ( & vtx -> c . cursor ) == vsl_end ) ; vtxs [ 0 ] = vtx ; trans [ 0 ] . level = 1 ; trans [ 0 ] . vxid = vtx -> key . vxid ; trans [ 0 ] . vxid_parent = 0 ; trans [ 0 ] . type = vtx -> type ; trans [ 0 ] . reason = vtx -> reason ; trans [ 0 ] . c = & vtx -> c . cursor ; i = 1 ; j = 0 ; while ( j < i ) { VTAILQ_FOREACH ( vtx , & vtxs [ j ] -> child , list_child ) { assert ( i < n ) ; AN ( vslc_vtx_reset ( & vtx -> c . cursor ) == vsl_end ) ; vtxs [ i ] = vtx ; if ( vtx -> reason == VSL_r_restart ) trans [ i ] . level = trans [ j ] . level ; else trans [ i ] . level = trans [ j ] . level + 1 ; trans [ i ] . vxid = vtx -> key . vxid ; trans [ i ] . vxid_parent = trans [ j ] . vxid ; trans [ i ] . type = vtx -> type ; trans [ i ] . reason = vtx -> reason ; trans [ i ] . c = & vtx -> c . cursor ; i ++ ; } j ++ ; } assert ( i == n ) ; for ( i = 0 ; i < n ; i ++ ) ptrans [ i ] = & trans [ i ] ; ptrans [ i ] = NULL ; if ( vslq -> query != NULL && ! vslq_runquery ( vslq -> query , ptrans ) ) return ( 0 ) ; if ( vslq -> vsl -> R_opt_l != 0 && ! vslq_ratelimit ( vslq ) ) return ( 0 ) ; return ( ( func ) ( vslq -> vsl , ptrans , priv ) ) ; }
Build transaction array, do the query and callback.
Build transaction array do the query and callback .
/* Build transaction array */ /* Restarts stay at the same level as parent */ /* Build pointer array */ /* Query test goes here */ /* Callback */