return sample_casts[sample->data.type][req_type](sample);
}
+static inline
+struct sample *smp_set_owner(struct sample *smp, struct proxy *px,
+ struct session *sess, struct stream *strm, int opt)
+{
+ smp->px = px;
+ smp->sess = sess;
+ smp->strm = strm;
+ smp->opt = opt;
+ return smp;
+}
+
#endif /* _PROTO_SAMPLE_H */
memset(&smp, 0, sizeof(smp));
/* Run the sample fetch process. */
- smp.px = hsmp->p;
- smp.sess = hsmp->s->sess;
- smp.strm = hsmp->s;
- smp.opt = hsmp->dir & SMP_OPT_DIR;
+ smp_set_owner(&smp, hsmp->p, hsmp->s->sess, hsmp->s, hsmp->dir & SMP_OPT_DIR);
if (!f->process(args, &smp, f->kw, f->private)) {
if (hsmp->flags & HLUA_F_AS_STRING)
lua_pushstring(L, "");
WILL_LJMP(lua_error(L));
}
+ smp_set_owner(&smp, hsmp->p, hsmp->s->sess, hsmp->s, hsmp->dir & SMP_OPT_DIR);
+
/* Apply expected cast. */
if (!sample_casts[smp.data.type][conv->in_type]) {
hlua_pusherror(L, "invalid input argument: cannot cast '%s' to '%s'",
}
/* Run the sample conversion process. */
- smp.px = hsmp->p;
- smp.sess = hsmp->s->sess;
- smp.strm = hsmp->s;
- smp.opt = hsmp->dir & SMP_OPT_DIR;
if (!conv->process(args, &smp, conv->private)) {
if (hsmp->flags & HLUA_F_AS_STRING)
lua_pushstring(L, "");
memset(p, 0, sizeof(*p));
}
- p->px = px;
- p->sess = sess;
- p->strm = strm;
- p->opt = opt;
+ smp_set_owner(p, px, sess, strm, opt);
if (!expr->fetch->process(expr->arg_p, p, expr->fetch->kw, expr->fetch->private))
return NULL;