CLEANUP: sink: use the generic context to store the forwarder's context

Instead of having a struct that contains a single pointer in the appctx
context, let's directly use the generic context pointer and get rid of
the now unused sft.ptr entry.
This commit is contained in:
Willy Tarreau 2022-05-04 20:42:23 +02:00
parent 0d626a5610
commit 42cc831abf
2 changed files with 8 additions and 8 deletions

View File

@ -138,9 +138,6 @@ struct appctx {
/* all entries below are used by various CLI commands, please /* all entries below are used by various CLI commands, please
* keep the grouped together and avoid adding new ones. * keep the grouped together and avoid adding new ones.
*/ */
struct {
void *ptr;
} sft; /* sink forward target */
struct { struct {
struct httpclient *ptr; struct httpclient *ptr;
} httpclient; } httpclient;

View File

@ -292,14 +292,15 @@ void sink_setup_proxy(struct proxy *px)
} }
/* /*
* IO Handler to handle message push to syslog tcp server * IO Handler to handle message push to syslog tcp server.
* It takes its context from appctx->svcctx.
*/ */
static void sink_forward_io_handler(struct appctx *appctx) static void sink_forward_io_handler(struct appctx *appctx)
{ {
struct conn_stream *cs = appctx->owner; struct conn_stream *cs = appctx->owner;
struct stream *s = __cs_strm(cs); struct stream *s = __cs_strm(cs);
struct sink *sink = strm_fe(s)->parent; struct sink *sink = strm_fe(s)->parent;
struct sink_forward_target *sft = appctx->ctx.sft.ptr; struct sink_forward_target *sft = appctx->svcctx;
struct ring *ring = sink->ctx.ring; struct ring *ring = sink->ctx.ring;
struct buffer *buf = &ring->buf; struct buffer *buf = &ring->buf;
uint64_t msg_len; uint64_t msg_len;
@ -432,13 +433,14 @@ close:
/* /*
* IO Handler to handle message push to syslog tcp server * IO Handler to handle message push to syslog tcp server
* using octet counting frames * using octet counting frames
* It takes its context from appctx->svcctx.
*/ */
static void sink_forward_oc_io_handler(struct appctx *appctx) static void sink_forward_oc_io_handler(struct appctx *appctx)
{ {
struct conn_stream *cs = appctx->owner; struct conn_stream *cs = appctx->owner;
struct stream *s = __cs_strm(cs); struct stream *s = __cs_strm(cs);
struct sink *sink = strm_fe(s)->parent; struct sink *sink = strm_fe(s)->parent;
struct sink_forward_target *sft = appctx->ctx.sft.ptr; struct sink_forward_target *sft = appctx->svcctx;
struct ring *ring = sink->ctx.ring; struct ring *ring = sink->ctx.ring;
struct buffer *buf = &ring->buf; struct buffer *buf = &ring->buf;
uint64_t msg_len; uint64_t msg_len;
@ -593,7 +595,7 @@ void __sink_forward_session_deinit(struct sink_forward_target *sft)
static void sink_forward_session_release(struct appctx *appctx) static void sink_forward_session_release(struct appctx *appctx)
{ {
struct sink_forward_target *sft = appctx->ctx.sft.ptr; struct sink_forward_target *sft = appctx->svcctx;
if (!sft) if (!sft)
return; return;
@ -620,6 +622,7 @@ static struct applet sink_forward_oc_applet = {
/* /*
* Create a new peer session in assigned state (connect will start automatically) * Create a new peer session in assigned state (connect will start automatically)
* It sets its context into appctx->svcctx.
*/ */
static struct appctx *sink_forward_session_create(struct sink *sink, struct sink_forward_target *sft) static struct appctx *sink_forward_session_create(struct sink *sink, struct sink_forward_target *sft)
{ {
@ -638,7 +641,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
if (!appctx) if (!appctx)
goto out_close; goto out_close;
appctx->ctx.sft.ptr = (void *)sft; appctx->svcctx = (void *)sft;
sess = session_new(p, NULL, &appctx->obj_type); sess = session_new(p, NULL, &appctx->obj_type);
if (!sess) { if (!sess) {